Localizes group and host UI, improves i18n coverage

Replaces hardcoded group and host strings with localized
messages throughout group management, selection panels,
and dialogs. Adds missing English and Chinese translations
for group actions and host panel UI, enhancing usability
for non-English users and improving maintainability.
This commit is contained in:
LAPTOP-O016UC3M\Qi Chen committed 2025-12-17 12:17:38 +08:00
1 parent d8347582b4
commit 477d0cd651
4 files changed
+102 -44

No files matched your search

+25
View File
@@ -86,6 +86,27 @@ const en: Messages = {
'vault.nav.knownHosts': 'Known Hosts',
'vault.nav.logs': 'Logs',
'vault.groups.title': 'Groups',
'vault.groups.total': '{count} total',
'vault.groups.hostsCount': '{count} Hosts',
'vault.groups.newSubgroup': 'New Subgroup',
'vault.groups.rename': 'Rename Group',
'vault.groups.delete': 'Delete Group',
'vault.groups.createSubfolder': 'Create Subfolder',
'vault.groups.createRoot': 'Create Root Group',
'vault.groups.createDialog.desc': 'Create a new group for organizing hosts.',
'vault.groups.renameDialogTitle': 'Rename Group',
'vault.groups.renameDialog.desc': 'Rename an existing group.',
'vault.groups.field.name': 'Group Name',
'vault.groups.placeholder.example': 'e.g. Production',
'vault.groups.parentLabel': 'Parent',
'vault.groups.pathLabel': 'Path',
'vault.groups.errors.required': 'Group name is required.',
'vault.groups.errors.invalidChars': "Group name cannot include '/' or '\\\\'.",
'vault.hosts.header.entries': '{count} entries',
'vault.hosts.header.live': '{count} live',
// Vault hosts header/actions
'vault.hosts.search.placeholder': 'Find a host or ssh user@hostname...',
'vault.hosts.connect': 'Connect',
@@ -164,6 +185,10 @@ const en: Messages = {
'qs.jumpTo': 'Jump To',
'qs.localTerminal': 'Local Terminal',
// Select Host panel
'selectHost.title': 'Select Host',
'selectHost.noHostsFound': 'No hosts found',
// Protocol select dialog
'protocolSelect.chooseProtocol': 'Choose protocol',
'protocolSelect.port': 'port:',
+33 -8
View File
@@ -57,14 +57,14 @@ const zhCN: Messages = {
'settings.appearance.language.desc': '选择界面语言',
// Context menus / common actions
'action.newHost': '新建 Host',
'action.newHost': '新建主机',
'action.newSubfolder': '新建文件夹',
'action.copyPublicKey': '复制公钥',
'action.keyExport': '导出密钥',
'action.edit': '编辑',
'action.delete': '删除',
'action.remove': '移除',
'action.convertToHost': '转换为 Host',
'action.convertToHost': '转换为主机',
// Sync
'sync.cloudSync': '云同步',
@@ -85,6 +85,27 @@ const zhCN: Messages = {
'vault.nav.knownHosts': '已知主机',
'vault.nav.logs': '日志',
'vault.groups.title': '分组',
'vault.groups.total': '共 {count} 个',
'vault.groups.hostsCount': '{count} 台主机',
'vault.groups.newSubgroup': '新建子分组',
'vault.groups.rename': '重命名分组',
'vault.groups.delete': '删除分组',
'vault.groups.createSubfolder': '创建子分组',
'vault.groups.createRoot': '创建根分组',
'vault.groups.createDialog.desc': '创建新的分组用于组织主机。',
'vault.groups.renameDialogTitle': '重命名分组',
'vault.groups.renameDialog.desc': '重命名已有分组。',
'vault.groups.field.name': '分组名称',
'vault.groups.placeholder.example': '例如:Production',
'vault.groups.parentLabel': '父级',
'vault.groups.pathLabel': '路径',
'vault.groups.errors.required': '分组名称不能为空。',
'vault.groups.errors.invalidChars': "分组名称不能包含 '/' 或 '\\\\'.",
'vault.hosts.header.entries': '{count} 条',
'vault.hosts.header.live': '{count} 个在线',
// Vault hosts header/actions
'vault.hosts.search.placeholder': '查找主机或 ssh user@hostname…',
'vault.hosts.connect': '连接',
@@ -163,12 +184,16 @@ const zhCN: Messages = {
'qs.jumpTo': '跳转到',
'qs.localTerminal': '本地终端',
// Select Host panel
'selectHost.title': '选择主机',
'selectHost.noHostsFound': '未找到主机',
// Protocol select dialog
'protocolSelect.chooseProtocol': '选择协议',
'protocolSelect.port': '端口:',
// Host Details
'hostDetails.title.details': 'Host 详情',
'hostDetails.title.new': '新建 Host',
'hostDetails.title.details': '主机详情',
'hostDetails.title.new': '新建主机',
'hostDetails.saveAria': '保存',
'hostDetails.section.address': '地址',
'hostDetails.hostname.placeholder': 'IP 或 主机名',
@@ -227,10 +252,10 @@ const zhCN: Messages = {
'hostForm.placeholder.addTag': '添加标签…',
'hostForm.auth.method': '认证方式',
'hostForm.auth.password': '密码',
'hostForm.auth.sshKey': 'SSH Key',
'hostForm.auth.selectKey': '选择 SSH Key',
'hostForm.auth.noKeys': '暂无 keys',
'hostForm.auth.noKeysHint': 'Keychain 中未找到 SSH keys,请先创建一个。',
'hostForm.auth.sshKey': 'SSH密钥',
'hostForm.auth.selectKey': '选择 SSH密钥',
'hostForm.auth.noKeys': '暂无密钥',
'hostForm.auth.noKeysHint': '钥匙串中未找到 SSH密钥,请先创建一个。',
'hostForm.saveHost': '保存主机',
// Connection logs
+10 -7
View File
@@ -9,6 +9,7 @@ import {
} from "lucide-react";
import React, { useMemo, useState } from "react";
import { cn } from "../lib/utils";
import { useI18n } from "../application/i18n/I18nProvider";
import { Host, SSHKey } from "../types";
import { DistroAvatar } from "./DistroAvatar";
import HostDetailsPanel from "./HostDetailsPanel";
@@ -48,10 +49,12 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
availableKeys = [],
onSaveHost,
onCreateGroup,
title = "Select Host",
title,
subtitle,
className,
}) => {
const { t } = useI18n();
const panelTitle = title ?? t("selectHost.title");
const [searchQuery, setSearchQuery] = useState("");
const [currentPath, setCurrentPath] = useState<string | null>(null);
const [sortMode, setSortMode] = useState<SortMode>("az");
@@ -214,7 +217,7 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
<ArrowLeft size={18} />
</button>
<div className="min-w-0">
<h3 className="text-sm font-semibold">{title}</h3>
<h3 className="text-sm font-semibold">{panelTitle}</h3>
{subtitle && (
<p className="text-xs text-muted-foreground">{subtitle}</p>
)}
@@ -279,7 +282,7 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
onClick={() => setCurrentPath(null)}
className="text-primary hover:underline"
>
All hosts
{t("vault.hosts.allHosts")}
</button>
{breadcrumbs.map((crumb, index) => (
<React.Fragment key={crumb.path}>
@@ -301,7 +304,7 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
)}
{groupsWithCounts.length > 0 && (
<div>
<h4 className="text-sm font-semibold mb-3">Groups</h4>
<h4 className="text-sm font-semibold mb-3">{t("vault.groups.title")}</h4>
<div className="space-y-1">
{groupsWithCounts.map((group) => (
<div
@@ -315,7 +318,7 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
<div className="flex-1 min-w-0">
<div className="font-medium">{group.name}</div>
<div className="text-xs text-muted-foreground">
{group.count} Host{group.count !== 1 ? "s" : ""}
{t("vault.groups.hostsCount", { count: group.count })}
</div>
</div>
</div>
@@ -327,7 +330,7 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
{/* Hosts Section */}
{filteredHosts.length > 0 && (
<div>
<h4 className="text-sm font-semibold mb-3">Hosts</h4>
<h4 className="text-sm font-semibold mb-3">{t("vault.nav.hosts")}</h4>
<div className="space-y-1">
{filteredHosts.map((host) => {
const isSelected = selectedHostIds.includes(host.id);
@@ -367,7 +370,7 @@ const SelectHostPanel: React.FC<SelectHostPanelProps> = ({
{/* Empty state */}
{groupsWithCounts.length === 0 && filteredHosts.length === 0 && (
<div className="text-center py-12 text-muted-foreground">
<p>No hosts found</p>
<p>{t("selectHost.noHostsFound")}</p>
</div>
)}
</div>
+34 -29
View File
@@ -482,11 +482,11 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
const nextName = renameGroupName.trim();
if (!nextName) {
setRenameGroupError("Group name is required.");
setRenameGroupError(t("vault.groups.errors.required"));
return;
}
if (nextName.includes("/") || nextName.includes("\\")) {
setRenameGroupError("Group name cannot include '/' or '\\'.");
setRenameGroupError(t("vault.groups.errors.invalidChars"));
return;
}
@@ -608,7 +608,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
setSelectedGroupPath(null);
}}
>
<LayoutGrid size={16} /> Hosts
<LayoutGrid size={16} /> {t("vault.nav.hosts")}
</Button>
<Button
variant={currentSection === "keys" ? "secondary" : "ghost"}
@@ -864,10 +864,10 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
<>
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-muted-foreground">
Groups
{t("vault.groups.title")}
</h3>
<div className="text-xs text-muted-foreground">
{displayedGroups.length} total
{t("vault.groups.total", { count: displayedGroups.length })}
</div>
</div>
</>
@@ -934,7 +934,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
{node.name}
</div>
<div className="text-[11px] text-muted-foreground">
{node.hosts.length} Hosts
{t("vault.groups.hostsCount", { count: node.hosts.length })}
</div>
</div>
</div>
@@ -947,8 +947,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
setIsNewFolderOpen(true);
}}
>
<FolderPlus className="mr-2 h-4 w-4" /> New
Subgroup
<FolderPlus className="mr-2 h-4 w-4" /> {t("vault.groups.newSubgroup")}
</ContextMenuItem>
<ContextMenuItem
onClick={() => {
@@ -958,13 +957,13 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
setIsRenameGroupOpen(true);
}}
>
<Edit2 className="mr-2 h-4 w-4" /> Rename Group
<Edit2 className="mr-2 h-4 w-4" /> {t("vault.groups.rename")}
</ContextMenuItem>
<ContextMenuItem
className="text-destructive"
onClick={() => deleteGroupPath(node.path)}
>
<Trash2 className="mr-2 h-4 w-4" /> Delete Group
<Trash2 className="mr-2 h-4 w-4" /> {t("vault.groups.delete")}
</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
@@ -975,12 +974,14 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
<section className="space-y-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-muted-foreground">
Hosts
{t("vault.nav.hosts")}
</h3>
<div className="flex items-center gap-2 text-xs text-muted-foreground">
<span>{displayedHosts.length} entries</span>
<span>
{t("vault.hosts.header.entries", { count: displayedHosts.length })}
</span>
<div className="bg-secondary/80 border border-border/70 rounded-md px-2 py-1 text-[11px]">
{sessions.length} live
{t("vault.hosts.header.live", { count: sessions.length })}
</div>
</div>
</div>
@@ -1211,36 +1212,39 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
/>
)}
<Dialog open={isNewFolderOpen} onOpenChange={setIsNewFolderOpen}>
<Dialog open={isNewFolderOpen} onOpenChange={setIsNewFolderOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>
{targetParentPath ? `Create Subfolder` : "Create Root Group"}
{targetParentPath
? t("vault.groups.createSubfolder")
: t("vault.groups.createRoot")}
</DialogTitle>
<DialogDescription className="sr-only">
Create a new group for organizing hosts.
{t("vault.groups.createDialog.desc")}
</DialogDescription>
</DialogHeader>
<div className="py-4">
<Label>Group Name</Label>
<Label>{t("vault.groups.field.name")}</Label>
<Input
value={newFolderName}
onChange={(e) => setNewFolderName(e.target.value)}
placeholder="e.g. Production"
placeholder={t("vault.groups.placeholder.example")}
autoFocus
onKeyDown={(e) => e.key === "Enter" && submitNewFolder()}
/>
{targetParentPath && (
<p className="text-xs text-muted-foreground mt-2">
Parent: <span className="font-mono">{targetParentPath}</span>
{t("vault.groups.parentLabel")}:{" "}
<span className="font-mono">{targetParentPath}</span>
</p>
)}
</div>
<DialogFooter>
<Button variant="ghost" onClick={() => setIsNewFolderOpen(false)}>
Cancel
{t("common.cancel")}
</Button>
<Button onClick={submitNewFolder}>Create</Button>
<Button onClick={submitNewFolder}>{t("common.create")}</Button>
</DialogFooter>
</DialogContent>
</Dialog>
@@ -1256,28 +1260,29 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
}
}}
>
<DialogContent>
<DialogContent>
<DialogHeader>
<DialogTitle>Rename Group</DialogTitle>
<DialogTitle>{t("vault.groups.renameDialogTitle")}</DialogTitle>
<DialogDescription className="sr-only">
Rename an existing group.
{t("vault.groups.renameDialog.desc")}
</DialogDescription>
</DialogHeader>
<div className="py-4 space-y-2">
<Label>Group Name</Label>
<Label>{t("vault.groups.field.name")}</Label>
<Input
value={renameGroupName}
onChange={(e) => {
setRenameGroupName(e.target.value);
setRenameGroupError(null);
}}
placeholder="e.g. Production"
placeholder={t("vault.groups.placeholder.example")}
autoFocus
onKeyDown={(e) => e.key === "Enter" && submitRenameGroup()}
/>
{renameTargetPath && (
<p className="text-xs text-muted-foreground">
Path: <span className="font-mono">{renameTargetPath}</span>
{t("vault.groups.pathLabel")}:{" "}
<span className="font-mono">{renameTargetPath}</span>
</p>
)}
{renameGroupError && (
@@ -1286,9 +1291,9 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
</div>
<DialogFooter>
<Button variant="ghost" onClick={() => setIsRenameGroupOpen(false)}>
Cancel
{t("common.cancel")}
</Button>
<Button onClick={submitRenameGroup}>Rename</Button>
<Button onClick={submitRenameGroup}>{t("common.rename")}</Button>
</DialogFooter>
</DialogContent>
</Dialog>