refactor(i18n): U29 phantom key 全项目清零 — 28 个 phantom key → 0
AlertRuleDialog.tsx (9处) + DeployTargetFields.tsx (3处) + HealthProbeSection.tsx (2处+1处硬编码) + PodLogsViewer.tsx (2处终端ANSI字符串) + AlertChannelDialog.tsx (2处) + PodMetricsPage.tsx/CapacityPage.tsx (各1处) + PodExecTerminal.tsx (1处终端ANSI) + BuildNodesManager.tsx (1处) + HostDetailDialog.tsx (1处)
修复类型:
- 批量正则损坏的 i18n.t('>中文 <span className=') → 语义化键
- 终端 ANSI 转义字符串 (PodLogsViewer/PodExecTerminal) → 移除 i18n.t() 包裹改纯字符串
- 硬编码中文 (取消/通知渠道提示/日志数据源提示) → i18n.t() 调用
新增 16 个翻译键 (monitor.alertRuleDialog2.* + monitor.alertChannel.name + agent.portCount + monitor.lbl.noProbeHint)
zh/en 7358→7375 +17 键对齐
phantom key 28→0 (全项目零 phantom key)
tsc -b=0, npm build✓ (17.00s), ESLint=0/53/0, go build=0, 17/17 测试通过
This commit is contained in:
1 parent
b2715ca3bd
commit
064b6c4ec2
12 files changed
+71
-37
No files matched your search
@@ -94,7 +94,7 @@ export function HostDetailDialog({
|
||||
<InfoCell label={i18n.t('agent.agentIp')} value={host.ip || '--'} />
|
||||
<InfoCell label={i18n.t('agent.agentOs')} value={host.os || host.platform || '--'} />
|
||||
<InfoCell label={i18n.t('agent.agentLastSeen')} value={timeAgo(host.last_report || host.last_reported_at || host.updated_at)} />
|
||||
<InfoCell label={i18n.t('端口数')} value={String(ports.length)} />
|
||||
<InfoCell label={i18n.t('agent.portCount')} value={String(ports.length)} />
|
||||
</div>
|
||||
|
||||
{/* 趋势图 */}
|
||||
|
||||
@@ -293,7 +293,7 @@ export default function BuildNodesManager({ embedded = false }: { embedded?: boo
|
||||
<Input value={name} onChange={(e) => setName(e.target.value)} className="h-8 text-xs dg-input" placeholder="build-node-01" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('>标签 <span className=')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('common.tag')} </Label>
|
||||
<Select value={serverId || '__none'} onValueChange={(v) => setServerId(v === '__none' ? '' : v)}>
|
||||
<SelectTrigger className="h-8 text-xs dg-input"><SelectValue placeholder={i18n.t('deploy.buildNodes.selectServer')} /></SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -245,7 +245,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
<p className="text-[10px] text-[var(--dg-text-muted)]"> {i18n.t('pipeline.deploytargetfie.sb2b6db98')} </p>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('>容器名 <span className=')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('kubernetes.container.containerName')} </Label>
|
||||
<Input
|
||||
value={value.deployRemotePath}
|
||||
onChange={(e) => onChange({ deployRemotePath: e.target.value })}
|
||||
@@ -254,7 +254,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('>容器名 <span className=')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('kubernetes.container.containerName')} </Label>
|
||||
<Input
|
||||
value={value.deployScript}
|
||||
onChange={(e) => onChange({ deployScript: e.target.value })}
|
||||
@@ -292,7 +292,7 @@ export function DeployTargetFields({ value, onChange, requireTarget = true }: De
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs"> {i18n.t('>容器名 <span className=')} </Label>
|
||||
<Label className="text-xs"> {i18n.t('kubernetes.container.containerName')} </Label>
|
||||
<Input
|
||||
readOnly
|
||||
value={value.k8sDeployment ? `${value.k8sNamespace}/${value.k8sDeployment}` : ''}
|
||||
|
||||
@@ -121,7 +121,7 @@ export default function CapacityPage() {
|
||||
</TableRow></TableHeader>
|
||||
<TableBody>
|
||||
{rows.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-8">{i18n.t('>暂无数据{loading ? <span className=')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={8} className="text-center dg-text-muted py-8">{i18n.t('common.noData')}</TableCell></TableRow>
|
||||
) : rows.map((r, i) => (
|
||||
<TableRow key={`${r.deployment}-${r.container}-${i}`} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)] text-sm">{r.deployment}</TableCell>
|
||||
|
||||
@@ -151,7 +151,7 @@ export function PodExecTerminal({
|
||||
console.error('[PodExec:connect] WS error event fired, readyState=', ws.readyState, 'type=', ev.type);
|
||||
setConnState('error');
|
||||
setHasOutput(true);
|
||||
term.write(i18n.t('\\r\\n\\x1b[31m[连接发生错误]\\x1b[0m\\r\\n'));
|
||||
term.write('\r\n\x1b[31m[连接发生错误]\x1b[0m\r\n');
|
||||
};
|
||||
}, [clusterId, namespace, podName, container, shell]);
|
||||
|
||||
|
||||
@@ -183,11 +183,11 @@ export function PodLogsViewer({
|
||||
}
|
||||
}
|
||||
flush();
|
||||
appendLines([i18n.t('\\x1b[33m— 流式结束 —\\x1b[0m')]);
|
||||
appendLines(['\x1b[33m— 流式结束 —\x1b[0m']);
|
||||
} catch (e) {
|
||||
const errName = (e as { name?: string })?.name;
|
||||
if (errName === 'AbortError') {
|
||||
appendLines([i18n.t('\\x1b[33m— 已停止 —\\x1b[0m')]);
|
||||
appendLines(['\x1b[33m— 已停止 —\x1b[0m']);
|
||||
} else {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
appendLines([`\x1b[31m[流式连接中断: ${msg}]\x1b[0m`]);
|
||||
|
||||
@@ -132,7 +132,7 @@ export default function PodMetricsPage() {
|
||||
</TableRow></TableHeader>
|
||||
<TableBody>
|
||||
{rows.length === 0 ? (
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-8">{i18n.t('>暂无数据{loading ? <span className=')}</TableCell></TableRow>
|
||||
<TableRow><TableCell colSpan={5} className="text-center dg-text-muted py-8">{i18n.t('common.noData')}</TableCell></TableRow>
|
||||
) : rows.map((r, i) => (
|
||||
<TableRow key={`${r.pod}-${r.container}-${i}`} className="border-[var(--dg-border)] hover:bg-[var(--dg-bg-hover)]">
|
||||
<TableCell className="font-medium text-[var(--dg-text-primary)] text-sm">{r.pod}</TableCell>
|
||||
|
||||
@@ -131,7 +131,7 @@ export function AlertChannelDialog({
|
||||
{/* 渠道列表 */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('>渠道名称 <span className=')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)] text-sm"> {i18n.t('monitor.alertChannel.name')} </Label>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
@@ -210,7 +210,7 @@ export function AlertChannelDialog({
|
||||
{editingChannel ? i18n.t('monitor.alertChannelDialog2.editChannel') : i18n.t('monitor.alertChannelDialog2.newChannel')}
|
||||
</Label>
|
||||
<div className="space-y-1.5">
|
||||
<Label className="dg-text-secondary text-xs"> {i18n.t('>渠道名称 <span className=')} <span className="dg-text-red">*</span></Label>
|
||||
<Label className="dg-text-secondary text-xs"> {i18n.t('monitor.alertChannel.name')} <span className="dg-text-red">*</span></Label>
|
||||
<Input
|
||||
value={channelForm.name}
|
||||
onChange={(e) => setChannelForm({ ...channelForm, name: e.target.value })}
|
||||
|
||||
@@ -147,7 +147,7 @@ export function AlertRuleDialog({
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('aiops.llmModelDesc')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertRuleDialog2.ruleDesc')} </Label>
|
||||
<Textarea
|
||||
value={ruleForm.description}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, description: e.target.value })}
|
||||
@@ -159,7 +159,7 @@ export function AlertRuleDialog({
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertRuleDialog2.alertType')} </Label>
|
||||
<select
|
||||
value={ruleForm.type}
|
||||
onChange={(e) => {
|
||||
@@ -169,9 +169,9 @@ export function AlertRuleDialog({
|
||||
}}
|
||||
className="w-full h-9 px-3 rounded-md bg-[var(--dg-bg-tertiary)]/50 border border-[var(--dg-border)] text-[var(--dg-text-primary)] text-sm"
|
||||
>
|
||||
<option value="metric"> {i18n.t('>请先前往「日志库」添加 {ruleForm.source === ')} </option>
|
||||
<option value="metric"> {i18n.t('monitor.alertRuleDialog2.metricAlert')} </option>
|
||||
<option value="log"> {i18n.t('monitor.alertHelper.srcLog')} </option>
|
||||
<option value="event"> {i18n.t('>请先前往「日志库」添加 {ruleForm.source === ')} </option>
|
||||
<option value="event"> {i18n.t('monitor.alertRuleDialog2.eventAlert')} </option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
@@ -199,25 +199,25 @@ export function AlertRuleDialog({
|
||||
|
||||
{ruleForm.type === 'log' && (
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} <span className="dg-text-red">*</span></Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertRuleDialog2.logDatasource')} <span className="dg-text-red">*</span></Label>
|
||||
<select
|
||||
value={ruleForm.datasource_id || ''}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, datasource_id: Number(e.target.value) || undefined })}
|
||||
className="w-full h-9 px-3 rounded-md bg-[var(--dg-bg-tertiary)]/50 border border-[var(--dg-border)] text-[var(--dg-text-primary)] text-sm"
|
||||
>
|
||||
<option value=""> {i18n.t('PromQL 或指标表达式,例如 cpu_usage > 80')} </option>
|
||||
<option value=""> {i18n.t('monitor.alertRuleDialog2.selectLogSource')} </option>
|
||||
{logSources.map((s) => (
|
||||
<option key={s.id} value={s.id}>{s.name}{s.is_default ? i18n.t('monitor.logPanel.defaultSuffix') : ''}</option>
|
||||
))}
|
||||
</select>
|
||||
{logSources.length === 0 && (
|
||||
<p className="text-xs dg-text-yellow/80">请先前往「日志库」添加 {ruleForm.source === 'loki' ? 'Loki' : 'Elasticsearch'} 数据源</p>
|
||||
<p className="text-xs dg-text-yellow/80">{i18n.t('monitor.alertRuleDialog2.addLogSourceFirst', { type: ruleForm.source === 'loki' ? 'Loki' : 'Elasticsearch' })}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>规则名称 <span className=')} <span className="dg-text-red">*</span></Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertRuleDialog2.expression')} <span className="dg-text-red">*</span></Label>
|
||||
<Input
|
||||
value={ruleForm.expression}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, expression: e.target.value })}
|
||||
@@ -226,14 +226,14 @@ export function AlertRuleDialog({
|
||||
/>
|
||||
<p className="text-xs dg-text-muted">
|
||||
{ruleForm.type === 'log'
|
||||
? (ruleForm.source === 'loki' ? i18n.t('LogQL 查询或 count_over_time 表达式') : i18n.t('Elasticsearch Lucene 查询'))
|
||||
: i18n.t('PromQL 或指标表达式,例如 cpu_usage > 80')}
|
||||
? (ruleForm.source === 'loki' ? i18n.t('monitor.alertRuleDialog2.logqlHint') : i18n.t('monitor.alertRuleDialog2.esHint'))
|
||||
: i18n.t('monitor.alertRuleDialog2.promqlHint')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertRuleDialog2.severity')} </Label>
|
||||
<select
|
||||
value={ruleForm.severity}
|
||||
onChange={(e) => setRuleForm({ ...ruleForm, severity: e.target.value })}
|
||||
@@ -245,7 +245,7 @@ export function AlertRuleDialog({
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('>日志数据源 <span className=')} </Label>
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.alertRuleDialog2.duration')} </Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={ruleForm.duration}
|
||||
@@ -259,7 +259,7 @@ export function AlertRuleDialog({
|
||||
<Label className="text-[var(--dg-text-secondary)]"> {i18n.t('monitor.notificationChannel')} </Label>
|
||||
{notifyChannels.length === 0 ? (
|
||||
<div className="text-xs dg-text-yellow/80 bg-amber-500/5 border border-amber-500/20 rounded-md px-3 py-2">
|
||||
暂无已配置的通知渠道,请先在「通知渠道配置」中添加
|
||||
{i18n.t('monitor.alertRuleDialog2.noChannels')}
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-wrap gap-3 pt-1">
|
||||
@@ -295,7 +295,7 @@ export function AlertRuleDialog({
|
||||
className="border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-hover)]"
|
||||
onClick={() => onOpenChange(false)}
|
||||
>
|
||||
取消
|
||||
{i18n.t('common.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white"
|
||||
|
||||
Reference in new issue
Block a user