FIX: Resolve translation function error in file manager creation components
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 <noreply@anthropic.com>
This commit is contained in:
@@ -1421,6 +1421,7 @@ function CreateIntentGridItem({
|
|||||||
onConfirm?: (name: string) => void;
|
onConfirm?: (name: string) => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
}) {
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
const [inputName, setInputName] = useState(intent.currentName);
|
const [inputName, setInputName] = useState(intent.currentName);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@@ -1474,6 +1475,7 @@ function CreateIntentListItem({
|
|||||||
onConfirm?: (name: string) => void;
|
onConfirm?: (name: string) => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
}) {
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
const [inputName, setInputName] = useState(intent.currentName);
|
const [inputName, setInputName] = useState(intent.currentName);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@@ -1509,7 +1511,7 @@ function CreateIntentListItem({
|
|||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onBlur={() => onConfirm?.(inputName.trim())}
|
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"
|
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')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user