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:
ZacharyZcR
2025-09-17 10:32:06 +08:00
parent 2a8133dc36
commit 8fd46f2383
4 changed files with 56 additions and 20 deletions

View File

@@ -729,7 +729,25 @@
"noHostSelected": "No host selected",
"starred": "Starred",
"shortcuts": "Shortcuts",
"directories": "Directories"
"directories": "Directories",
"removedFromRecentFiles": "Removed \"{{name}}\" from recent files",
"removeFailed": "Remove failed",
"unpinnedSuccessfully": "Unpinned \"{{name}}\" successfully",
"unpinFailed": "Unpin failed",
"removedShortcut": "Removed shortcut \"{{name}}\"",
"removeShortcutFailed": "Remove shortcut failed",
"clearedAllRecentFiles": "Cleared all recent files",
"clearFailed": "Clear failed",
"removeFromRecentFiles": "Remove from recent files",
"clearAllRecentFiles": "Clear all recent files",
"unpinFile": "Unpin file",
"removeShortcut": "Remove shortcut",
"saveFilesToSystem": "Save {{count}} files to system",
"saveToSystem": "Save to system",
"pinFile": "Pin file",
"addToShortcuts": "Add to shortcuts",
"selectLocationToSave": "Select location to save",
"downloadToDefaultLocation": "Download to default location"
},
"tunnels": {
"title": "SSH Tunnels",

View File

@@ -736,7 +736,25 @@
"cannotSaveFile": "无法保存文件",
"starred": "收藏",
"shortcuts": "快捷方式",
"directories": "目录"
"directories": "目录",
"removedFromRecentFiles": "已从最近访问中移除\"{{name}}\"",
"removeFailed": "移除失败",
"unpinnedSuccessfully": "已取消固定\"{{name}}\"",
"unpinFailed": "取消固定失败",
"removedShortcut": "已移除快捷方式\"{{name}}\"",
"removeShortcutFailed": "移除快捷方式失败",
"clearedAllRecentFiles": "已清除所有最近访问记录",
"clearFailed": "清除失败",
"removeFromRecentFiles": "从最近访问中移除",
"clearAllRecentFiles": "清除所有最近访问",
"unpinFile": "取消固定",
"removeShortcut": "移除快捷方式",
"saveFilesToSystem": "保存 {{count}} 个文件到系统",
"saveToSystem": "保存到系统",
"pinFile": "固定文件",
"addToShortcuts": "添加到快捷方式",
"selectLocationToSave": "选择位置保存",
"downloadToDefaultLocation": "下载到默认位置"
},
"tunnels": {
"title": "SSH 隧道",

View File

@@ -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)
});
}

View File

@@ -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>