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 <noreply@anthropic.com>
This commit is contained in:
ZacharyZcR
2025-09-02 21:08:58 +08:00
parent c6bc2a6f9c
commit 511e4e7db3
4 changed files with 102 additions and 14 deletions

View File

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

View File

@@ -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": "主机名",

View File

@@ -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<typeof Badge> & {
status: 'online' | 'offline' | 'maintenance' | 'degraded';
@@ -48,15 +49,18 @@ export const StatusLabel = ({
className,
children,
...props
}: StatusLabelProps) => (
<span className={cn('text-muted-foreground', className)} {...props}>
{children ?? (
<>
<span className="hidden group-[.online]:block">Online</span>
<span className="hidden group-[.offline]:block">Offline</span>
<span className="hidden group-[.maintenance]:block">Maintenance</span>
<span className="hidden group-[.degraded]:block">Degraded</span>
</>
)}
</span>
);
}: StatusLabelProps) => {
const { t } = useTranslation();
return (
<span className={cn('text-muted-foreground', className)} {...props}>
{children ?? (
<>
<span className="hidden group-[.online]:block">{t('common.online')}</span>
<span className="hidden group-[.offline]:block">{t('common.offline')}</span>
<span className="hidden group-[.maintenance]:block">{t('common.maintenance')}</span>
<span className="hidden group-[.degraded]:block">{t('common.degraded')}</span>
</>
)}
</span>
);
};

View File

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