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:
attacker committed 2026-07-03 02:14:20 +08:00
1 parent 72bfb0e12d
commit 55f216cfbb
131 files changed
+4049 -1908

No files matched your search

@@ -2,6 +2,7 @@
import { useState, useEffect, useCallback } from 'react';
import { toast } from 'sonner';
import { auditSettingsApi, type AuditSettings } from '@/api';
import i18n from '@/i18n';
const RETENTION_OPTIONS = [7, 15, 30, 90, 180, 365] as const;
@@ -20,7 +21,7 @@ export function useAuditSettings() {
setRetentionDays(String(data.retention_days || 180));
setRecordAll(data.record_all !== false);
} catch {
toast.error('加载审计设置失败');
toast.error(i18n.t('system.useauditsetting.s32e8a76e'));
} finally {
setLoading(false);
}
@@ -33,7 +34,7 @@ export function useAuditSettings() {
const handleApply = async () => {
const days = Number(retentionDays);
if (!RETENTION_OPTIONS.includes(days as (typeof RETENTION_OPTIONS)[number])) {
toast.error('请选择有效的保留天数');
toast.error(i18n.t('system.useauditsetting.s51680af0'));
return;
}
setApplying(true);
@@ -52,7 +53,7 @@ export function useAuditSettings() {
: `已应用 ${days} 天保留策略,暂无超期记录需清理`,
);
} catch (e: unknown) {
toast.error(e instanceof Error ? e.message : '应用失败');
toast.error(e instanceof Error ? e.message : i18n.t('kubernetes.msg.applyFailed'));
} finally {
setApplying(false);
}
@@ -66,7 +67,7 @@ export function useAuditSettings() {
try {
const s = JSON.parse(settings.last_cleanup_summary) as { total?: number };
if (typeof s.total === 'number') {
detail = s.total > 0 ? `,清理 ${s.total} 条` : ',无超期记录';
detail = s.total > 0 ? `,清理 ${s.total} 条` : i18n.t('system.useauditsetting.s7d55bd57');
}
} catch {
// ignore