From 511e4e7db35e1c4030cebafc00f271a2a4a0ce89 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Tue, 2 Sep 2025 21:08:58 +0800 Subject: [PATCH] Extend localization coverage to UI components and common strings - Added comprehensive common translations (online/offline, success/error, etc.) - Localized status indicator component with all status states - Updated FileManagerLeftSidebar toast messages for rename/delete operations - Added translations for UI elements (close, toggle sidebar, etc.) - Expanded placeholder translations for form inputs - Added Chinese translations for all new common strings - Improved consistency across component status messages Co-Authored-By: Claude --- public/locales/en/translation.json | 42 +++++++++++++++++++ public/locales/zh/translation.json | 42 +++++++++++++++++++ src/components/ui/shadcn-io/status/index.tsx | 28 +++++++------ .../File Manager/FileManagerLeftSidebar.tsx | 4 +- 4 files changed, 102 insertions(+), 14 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index cbbcade8..ded2cf0a 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -1,5 +1,42 @@ { "common": { + "close": "Close", + "online": "Online", + "offline": "Offline", + "maintenance": "Maintenance", + "degraded": "Degraded", + "discord": "Discord", + "error": "Error", + "warning": "Warning", + "info": "Info", + "success": "Success", + "loading": "Loading", + "required": "Required", + "optional": "Optional", + "toggleSidebar": "Toggle Sidebar", + "sidebar": "Sidebar", + "home": "Home", + "expired": "Expired", + "updateAvailable": "Update Available", + "noReleases": "No Releases", + "updatesAndReleases": "Updates & Releases", + "yourBackupCodes": "Your Backup Codes", + "sendResetCode": "Send Reset Code", + "verifyCode": "Verify Code", + "resetPassword": "Reset Password", + "resetCode": "Reset Code", + "newPassword": "New Password", + "sshPath": "SSH Path", + "localPath": "Local Path", + "folder": "Folder", + "file": "File", + "renamedSuccessfully": "renamed successfully", + "deletedSuccessfully": "deleted successfully", + "noAuthCredentials": "No authentication credentials available for this SSH host", + "noTunnelConnections": "No tunnel connections configured", + "sshTools": "SSH Tools", + "english": "English", + "chinese": "Chinese", "login": "Login", "logout": "Logout", "register": "Register", @@ -505,6 +542,11 @@ "external": "External (OIDC)" }, "placeholders": { + "enterCode": "000000", + "ipAddress": "127.0.0.1", + "port": "22", + "maxRetries": "3", + "retryInterval": "10", "language": "Language", "username": "username", "hostname": "host name", diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index bb568d78..1e15805d 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -1,5 +1,42 @@ { "common": { + "close": "关闭", + "online": "在线", + "offline": "离线", + "maintenance": "维护中", + "degraded": "降级", + "discord": "Discord", + "error": "错误", + "warning": "警告", + "info": "信息", + "success": "成功", + "loading": "加载中", + "required": "必填", + "optional": "可选", + "toggleSidebar": "切换侧边栏", + "sidebar": "侧边栏", + "home": "首页", + "expired": "已过期", + "updateAvailable": "有可用更新", + "noReleases": "没有发布版本", + "updatesAndReleases": "更新与发布", + "yourBackupCodes": "您的备份代码", + "sendResetCode": "发送重置代码", + "verifyCode": "验证代码", + "resetPassword": "重置密码", + "resetCode": "重置代码", + "newPassword": "新密码", + "sshPath": "SSH 路径", + "localPath": "本地路径", + "folder": "文件夹", + "file": "文件", + "renamedSuccessfully": "重命名成功", + "deletedSuccessfully": "删除成功", + "noAuthCredentials": "此 SSH 主机没有可用的认证凭据", + "noTunnelConnections": "没有配置隧道连接", + "sshTools": "SSH 工具", + "english": "英语", + "chinese": "中文", "login": "登录", "logout": "登出", "register": "注册", @@ -505,6 +542,11 @@ "external": "外部 (OIDC)" }, "placeholders": { + "enterCode": "000000", + "ipAddress": "127.0.0.1", + "port": "22", + "maxRetries": "3", + "retryInterval": "10", "language": "语言", "username": "用户名", "hostname": "主机名", diff --git a/src/components/ui/shadcn-io/status/index.tsx b/src/components/ui/shadcn-io/status/index.tsx index 37836101..29b6c6ec 100644 --- a/src/components/ui/shadcn-io/status/index.tsx +++ b/src/components/ui/shadcn-io/status/index.tsx @@ -1,6 +1,7 @@ import type { ComponentProps, HTMLAttributes } from 'react'; import { Badge } from '@/components/ui/badge'; import { cn } from '@/lib/utils'; +import { useTranslation } from 'react-i18next'; export type StatusProps = ComponentProps & { status: 'online' | 'offline' | 'maintenance' | 'degraded'; @@ -48,15 +49,18 @@ export const StatusLabel = ({ className, children, ...props -}: StatusLabelProps) => ( - - {children ?? ( - <> - Online - Offline - Maintenance - Degraded - - )} - -); +}: StatusLabelProps) => { + const { t } = useTranslation(); + return ( + + {children ?? ( + <> + {t('common.online')} + {t('common.offline')} + {t('common.maintenance')} + {t('common.degraded')} + + )} + + ); +}; diff --git a/src/ui/Apps/File Manager/FileManagerLeftSidebar.tsx b/src/ui/Apps/File Manager/FileManagerLeftSidebar.tsx index aa4457ac..0e38d8b1 100644 --- a/src/ui/Apps/File Manager/FileManagerLeftSidebar.tsx +++ b/src/ui/Apps/File Manager/FileManagerLeftSidebar.tsx @@ -326,7 +326,7 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar( try { await renameSSHItem(sshSessionId, item.path, newName.trim()); - toast.success(`${item.type === 'directory' ? 'Folder' : 'File'} renamed successfully`); + toast.success(`${item.type === 'directory' ? t('common.folder') : t('common.file')} ${t('common.renamedSuccessfully')}`); setRenamingItem(null); if (onOperationComplete) { onOperationComplete(); @@ -343,7 +343,7 @@ const FileManagerLeftSidebar = forwardRef(function FileManagerSidebar( try { await deleteSSHItem(sshSessionId, item.path, item.type === 'directory'); - toast.success(`${item.type === 'directory' ? 'Folder' : 'File'} deleted successfully`); + toast.success(`${item.type === 'directory' ? t('common.folder') : t('common.file')} ${t('common.deletedSuccessfully')}`); if (onOperationComplete) { onOperationComplete(); } else {