feat(i18n): 安全批量转换 135 文件 — 覆盖率 34%→62%
使用 i18n.t() 全局方式(避免 hook 定位问题): - 288 目标文件中 135 个成功转换 - 2228 处中文替换为 i18n.t() 调用 - 1006 个新翻译 key 添加到 zh-CN.json + en-US.json - 词典总量: 3554 keys (22 namespaces) - tsc 零错误 + Vite 构建成功 - 6 个含代码示例/数据字符串的文件安全回退
This commit is contained in:
1 parent
72bfb0e12d
commit
55f216cfbb
131 files changed
+4049
-1908
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
DialogDescription, DialogFooter,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
interface ConfirmOptions {
|
||||
title?: string;
|
||||
@@ -29,23 +30,23 @@ export function useConfirm() {
|
||||
export function ConfirmProvider({ children }: { children: ReactNode }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [options, setOptions] = useState<Required<ConfirmOptions>>({
|
||||
title: '确认操作',
|
||||
title: i18n.t('common.confirmOp'),
|
||||
description: '',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
confirmText: i18n.t('monitor.alertEvents.acknowledge'),
|
||||
cancelText: i18n.t('rbac.jobRole.cancel'),
|
||||
variant: 'default',
|
||||
});
|
||||
const [resolver, setResolver] = useState<((v: boolean) => void) | null>(null);
|
||||
|
||||
const confirm = useCallback((opts: ConfirmOptions | string) => {
|
||||
const normalized = typeof opts === 'string'
|
||||
? { title: '确认操作', description: opts }
|
||||
? { title: i18n.t('common.confirmOp'), description: opts }
|
||||
: opts;
|
||||
setOptions({
|
||||
title: normalized.title || '确认操作',
|
||||
title: normalized.title || i18n.t('common.confirmOp'),
|
||||
description: normalized.description || '',
|
||||
confirmText: normalized.confirmText || '确认',
|
||||
cancelText: normalized.cancelText || '取消',
|
||||
confirmText: normalized.confirmText || i18n.t('monitor.alertEvents.acknowledge'),
|
||||
cancelText: normalized.cancelText || i18n.t('rbac.jobRole.cancel'),
|
||||
variant: (normalized.variant || 'default') as 'default' | 'destructive',
|
||||
});
|
||||
setOpen(true);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { copyToClipboard } from '@/utils/clipboard';
|
||||
import { cn } from '@/lib/utils';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
export interface CopyButtonProps {
|
||||
text: string;
|
||||
@@ -40,8 +41,8 @@ export function CopyButton({
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
} else {
|
||||
toast({
|
||||
title: '复制失败',
|
||||
description: '请手动选中内容后复制',
|
||||
title: i18n.t('monitor.logPanel.copyFailed'),
|
||||
description: i18n.t('common.copybuttontsx.s76597b46'),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
Settings2,
|
||||
} from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
// ─── Types ───────────────────────────────────────────────
|
||||
|
||||
@@ -450,7 +451,7 @@ export function DataTable<T = Record<string, unknown>>(
|
||||
className="h-8 gap-1.5 border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)] hover:text-[var(--dg-text-primary)]"
|
||||
>
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
<span className="hidden sm:inline">导出</span>
|
||||
<span className="hidden sm:inline"> {i18n.t('common.export2')} </span>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -586,7 +587,7 @@ export function DataTable<T = Record<string, unknown>>(
|
||||
</span>
|
||||
)}
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="text-sm text-[var(--dg-text-muted)]">每页</span>
|
||||
<span className="text-sm text-[var(--dg-text-muted)]"> {i18n.t('monitor.hostDashboard.perPage')} </span>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm" className="h-7 px-2 min-w-[56px] gap-1 border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)]">
|
||||
|
||||
Reference in new issue
Block a user