From fce0447bfe3329295c788ed66f2b4e54f199aaa2 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 24 Sep 2025 04:44:29 +0800 Subject: [PATCH] FIX: Resolve translation function error in file manager creation components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed "ReferenceError: t is not defined" when creating new files/folders: Problem: - CreateIntentGridItem and CreateIntentListItem components used t() function - But neither component had useTranslation hook imported - Caused runtime error when trying to create new files or folders Solution: - Added const { t } = useTranslation(); to both components - Fixed hardcoded English text in CreateIntentListItem placeholder - Now uses proper i18n translation keys for all UI text Changes: - CreateIntentGridItem: Added useTranslation hook - CreateIntentListItem: Added useTranslation hook + fixed placeholder text - Both components now properly use t('fileManager.folderName') and t('fileManager.fileName') Now file/folder creation works without console errors and supports i18n. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx b/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx index 5c084360..a647b356 100644 --- a/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx +++ b/src/ui/Desktop/Apps/File Manager/FileManagerGrid.tsx @@ -1421,6 +1421,7 @@ function CreateIntentGridItem({ onConfirm?: (name: string) => void; onCancel?: () => void; }) { + const { t } = useTranslation(); const [inputName, setInputName] = useState(intent.currentName); const inputRef = useRef(null); @@ -1474,6 +1475,7 @@ function CreateIntentListItem({ onConfirm?: (name: string) => void; onCancel?: () => void; }) { + const { t } = useTranslation(); const [inputName, setInputName] = useState(intent.currentName); const inputRef = useRef(null); @@ -1509,7 +1511,7 @@ function CreateIntentListItem({ onKeyDown={handleKeyDown} onBlur={() => onConfirm?.(inputName.trim())} className="flex-1 min-w-0 max-w-[200px] rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[2px] outline-none" - placeholder={intent.type === 'directory' ? 'Folder name' : 'File name'} + placeholder={intent.type === 'directory' ? t('fileManager.folderName') : t('fileManager.fileName')} /> );