Fix hardcoded text and add missing i18n translations in file manager
- Add 18 new translation keys for file manager sidebar and context menu operations - Replace hardcoded Chinese text with t() function calls in FileManagerSidebar.tsx: * Toast messages for remove/unpin/clear operations * Context menu items for recent files, pinned files, and shortcuts - Replace hardcoded Chinese text with t() function calls in FileManagerContextMenu.tsx: * Pin/unpin file menu items * Add to shortcuts menu item * Save to system menu items with dynamic count support - Add bilingual support for all new strings (English and Chinese) - Improve consistency with existing i18n patterns
This commit is contained in:
@@ -262,10 +262,10 @@ export function FileManagerContextMenu({
|
||||
menuItems.push({
|
||||
icon: <ExternalLink className="w-4 h-4" />,
|
||||
label: isMultipleFiles
|
||||
? `保存 ${files.length} 个文件到系统`
|
||||
: "保存到系统",
|
||||
? t("fileManager.saveFilesToSystem", { count: files.length })
|
||||
: t("fileManager.saveToSystem"),
|
||||
action: () => onDragToDesktop(),
|
||||
shortcut: isModernBrowser ? "选择位置保存" : "下载到默认位置"
|
||||
shortcut: isModernBrowser ? t("fileManager.selectLocationToSave") : t("fileManager.downloadToDefaultLocation")
|
||||
});
|
||||
}
|
||||
|
||||
@@ -276,13 +276,13 @@ export function FileManagerContextMenu({
|
||||
if (isCurrentlyPinned && onUnpinFile) {
|
||||
menuItems.push({
|
||||
icon: <Star className="w-4 h-4 fill-yellow-400" />,
|
||||
label: "取消固定",
|
||||
label: t("fileManager.unpinFile"),
|
||||
action: () => onUnpinFile(files[0])
|
||||
});
|
||||
} else if (!isCurrentlyPinned && onPinFile) {
|
||||
menuItems.push({
|
||||
icon: <Star className="w-4 h-4" />,
|
||||
label: "固定文件",
|
||||
label: t("fileManager.pinFile"),
|
||||
action: () => onPinFile(files[0])
|
||||
});
|
||||
}
|
||||
@@ -292,7 +292,7 @@ export function FileManagerContextMenu({
|
||||
if (isSingleFile && files[0].type === 'directory' && onAddShortcut) {
|
||||
menuItems.push({
|
||||
icon: <Bookmark className="w-4 h-4" />,
|
||||
label: "添加到快捷方式",
|
||||
label: t("fileManager.addToShortcuts"),
|
||||
action: () => onAddShortcut(files[0].path)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,10 +134,10 @@ export function FileManagerSidebar({
|
||||
try {
|
||||
await removeRecentFile(currentHost.id, item.path);
|
||||
loadQuickAccessData(); // 重新加载数据
|
||||
toast.success(`已从最近访问中移除"${item.name}"`);
|
||||
toast.success(t("fileManager.removedFromRecentFiles", { name: item.name }));
|
||||
} catch (error) {
|
||||
console.error('Failed to remove recent file:', error);
|
||||
toast.error('移除失败');
|
||||
toast.error(t("fileManager.removeFailed"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,10 +147,10 @@ export function FileManagerSidebar({
|
||||
try {
|
||||
await removePinnedFile(currentHost.id, item.path);
|
||||
loadQuickAccessData(); // 重新加载数据
|
||||
toast.success(`已取消固定"${item.name}"`);
|
||||
toast.success(t("fileManager.unpinnedSuccessfully", { name: item.name }));
|
||||
} catch (error) {
|
||||
console.error('Failed to unpin file:', error);
|
||||
toast.error('取消固定失败');
|
||||
toast.error(t("fileManager.unpinFailed"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -160,10 +160,10 @@ export function FileManagerSidebar({
|
||||
try {
|
||||
await removeFolderShortcut(currentHost.id, item.path);
|
||||
loadQuickAccessData(); // 重新加载数据
|
||||
toast.success(`已移除快捷方式"${item.name}"`);
|
||||
toast.success(t("fileManager.removedShortcut", { name: item.name }));
|
||||
} catch (error) {
|
||||
console.error('Failed to remove shortcut:', error);
|
||||
toast.error('移除快捷方式失败');
|
||||
toast.error(t("fileManager.removeShortcutFailed"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -176,10 +176,10 @@ export function FileManagerSidebar({
|
||||
recentItems.map(item => removeRecentFile(currentHost.id, item.path))
|
||||
);
|
||||
loadQuickAccessData(); // 重新加载数据
|
||||
toast.success(`已清除所有最近访问记录`);
|
||||
toast.success(t("fileManager.clearedAllRecentFiles"));
|
||||
} catch (error) {
|
||||
console.error('Failed to clear recent files:', error);
|
||||
toast.error('清除失败');
|
||||
toast.error(t("fileManager.clearFailed"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -463,7 +463,7 @@ export function FileManagerSidebar({
|
||||
}}
|
||||
>
|
||||
<Clock className="w-4 h-4" />
|
||||
<span>从最近访问中移除</span>
|
||||
<span>{t("fileManager.removeFromRecentFiles")}</span>
|
||||
</button>
|
||||
{recentItems.length > 1 && (
|
||||
<>
|
||||
@@ -476,7 +476,7 @@ export function FileManagerSidebar({
|
||||
}}
|
||||
>
|
||||
<Clock className="w-4 h-4" />
|
||||
<span>清除所有最近访问</span>
|
||||
<span>{t("fileManager.clearAllRecentFiles")}</span>
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
@@ -492,7 +492,7 @@ export function FileManagerSidebar({
|
||||
}}
|
||||
>
|
||||
<Star className="w-4 h-4" />
|
||||
<span>取消固定</span>
|
||||
<span>{t("fileManager.unpinFile")}</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
@@ -505,7 +505,7 @@ export function FileManagerSidebar({
|
||||
}}
|
||||
>
|
||||
<Bookmark className="w-4 h-4" />
|
||||
<span>移除快捷方式</span>
|
||||
<span>{t("fileManager.removeShortcut")}</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user