From 56a7b9df29f07ba932e8e53bce6268a6c4d84382 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:39:35 +0800 Subject: [PATCH] fix(i18n): translate security rules in the web console --- web/src/lib/security-types.ts | 9 +- .../gateway/security/exceptions-panel.tsx | 2 +- .../routes/gateway/security/guard-panel.tsx | 19 +- web/src/routes/gateway/security/guard.zh.json | 225 ++++++++++++++++++ web/src/routes/gateway/security/index.tsx | 8 +- web/src/routes/gateway/security/log-panel.tsx | 2 +- web/src/routes/gateway/security/names.test.ts | 36 +-- web/src/routes/gateway/security/names.ts | 55 +++-- web/src/routes/gateway/security/policy.ts | 5 +- .../routes/gateway/security/rule-dialogs.tsx | 12 +- .../routes/gateway/security/security.test.tsx | 21 +- 11 files changed, 317 insertions(+), 77 deletions(-) create mode 100644 web/src/routes/gateway/security/guard.zh.json diff --git a/web/src/lib/security-types.ts b/web/src/lib/security-types.ts index 7f397909..783b20f0 100644 --- a/web/src/lib/security-types.ts +++ b/web/src/lib/security-types.ts @@ -111,19 +111,13 @@ export interface SecurityRuleView { custom: boolean; /** English name. A custom rule's name, in no particular language. */ name: string; - /** Chinese name: every built-in rule has one; custom rules do not. */ - name_zh?: string; /** Why the rule is worth a look (English). Absent where the name says it, and on custom rules. */ why?: string; - /** The same, in Chinese. */ - why_zh?: string; /** * What a built-in redaction rule finds, as a sentence (English); text in * backticks is code. Absent on the other guards and on custom rules. */ about?: string; - /** The same, in Chinese. */ - about_zh?: string; /** * Group: the `slug` of one of the guard's `kinds`. Custom rules: `custom`. */ @@ -144,12 +138,11 @@ export interface SecurityRuleView { replacement?: string | null; } -/** A group of a guard's rule table, named in both languages. */ +/** A group of a guard's rule table, with its English name. */ export interface SecurityKindView { /** What a rule's `kind` says. */ slug: string; name: string; - name_zh: string; } export interface GuardDetail { diff --git a/web/src/routes/gateway/security/exceptions-panel.tsx b/web/src/routes/gateway/security/exceptions-panel.tsx index b2d41844..ffcfd61d 100644 --- a/web/src/routes/gateway/security/exceptions-panel.tsx +++ b/web/src/routes/gateway/security/exceptions-panel.tsx @@ -56,7 +56,7 @@ export function ExceptionsPanel({ detail, canWrite }: { detail: GuardDetail; can const max = query.data?.max ?? 500; const full = items.length >= max; const rule = (e: RedactException) => - e.rule ? ruleName(i18n.language, detail, e.rule, false, e.rule) : t('contentSecurity.exceptions.noRule'); + e.rule ? ruleName(i18n.language, 'redact', detail, e.rule, false, e.rule) : t('contentSecurity.exceptions.noRule'); const addButton = (