refactor(i18n): merge duplicate catalogue messages

about.close, ov.configHelp and arrange.policy.{fastest,score,fallback,manual}
repeated ui.close, config.revisionHelp and policy.kind.* word for word in
every catalogue; the call sites use the shared keys.
This commit is contained in:
Zakk committed 2026-09-30 03:25:28 +10:00
1 parent f8111c7488
commit 4e569a71ff
9 files changed
+11 -29

No files matched your search

+4 -4
View File
@@ -62,11 +62,11 @@ export function policyKind(native: string): Group['policy']['kind'] | undefined
export const policies = ['select', 'urltest', 'roundrobin', 'fallback', 'score', 'fixed', 'min_moving_avg', 'min_avg10', 'min_last_delay', 'loadbalance'];
// The policies a new group can start with, in the order the picker offers them.
export const newGroupPolicies: Array<{id: string; label: Key; description: Key}> = [
{id: 'min_moving_avg', label: 'arrange.policy.fastest', description: 'arrange.policy.fastestHint'},
{id: 'score', label: 'arrange.policy.score', description: 'arrange.policy.scoreHint'},
{id: 'fallback', label: 'arrange.policy.fallback', description: 'arrange.policy.fallbackHint'},
{id: 'min_moving_avg', label: 'policy.kind.urltest', description: 'arrange.policy.fastestHint'},
{id: 'score', label: 'policy.kind.score', description: 'arrange.policy.scoreHint'},
{id: 'fallback', label: 'policy.kind.fallback', description: 'arrange.policy.fallbackHint'},
{id: 'roundrobin', label: 'arrange.policy.spread', description: 'arrange.policy.spreadHint'},
{id: 'select', label: 'arrange.policy.manual', description: 'arrange.policy.manualHint'}
{id: 'select', label: 'policy.kind.selector', description: 'arrange.policy.manualHint'}
];
// Built-in outbounds, as nodes, groups and rules name them; a rule may add `(must)`, which keeps DNS traffic from
// being hijacked for that rule.
+1 -1
View File
@@ -87,7 +87,7 @@ it('names a policy by what it does, whatever the native spelling', async () => {
const notes = (native: string) => tileViews(routingTree([], [{...group, policy: {...group.policy, native}}], [], undefined), t, 'en')[0].notes;
expect(notes('min_avg10')).toContainEqual({text: t('policy.kind.urltest')});
expect(notes('min_last_delay')).toContainEqual({text: t('policy.kind.urltest')});
expect(notes('min_moving_avg')).toContainEqual({text: t('arrange.policy.fastest')});
expect(notes('min_moving_avg')).toContainEqual({text: t('policy.kind.urltest')});
expect(notes('')).toContainEqual({text: t('policy.kind.urltest')});
});
+1 -1
View File
@@ -168,7 +168,7 @@ export function overviewView(
return {
status: engineStatus(state, datapath?.state, t(loading.capabilities || loading.runtime ? 'ov.loading' : 'ov.unknown'), t),
strip: [
{label: t('ov.config'), value: shortId(revision), full: revision, help: {title: t('ov.config'), text: t('ov.configHelp')}},
{label: t('ov.config'), value: shortId(revision), full: revision, help: {title: t('ov.config'), text: t('config.revisionHelp')}},
[t('ov.uptime'), formatDuration(runtime?.lifecycle.uptime_seconds ?? null, locale)],
[t('ov.cpu'), formatCpu(runtime?.process.cpu_percent, locale, t)],
[t('ov.lastReload'), reload ? localTime(reload.finished_at, locale) : '—']
+1 -1
View File
@@ -80,7 +80,7 @@ it('counts worst probe outcome once per member and reports selection changes', (
it('names the policy as the picker does and keeps the engine spelling for the tooltip', () => {
const group = nodeFixtures(0).groups[0];
const card = (native: string) => policyCardView({...group, policy: {kind: 'urltest', native}}, [], 'both', t).policy;
expect(card('min_moving_avg')).toEqual({label: t('arrange.policy.fastest'), id: 'min_moving_avg'});
expect(card('min_moving_avg')).toEqual({label: t('policy.kind.urltest'), id: 'min_moving_avg'});
expect(card('min_avg10')).toEqual({label: t('policy.kind.urltest'), id: 'min_avg10'});
expect(card('')).toEqual({label: t('policy.kind.urltest'), id: 'urltest'});
});
+3 -3
View File
@@ -4,8 +4,8 @@ import {groupEditSafe, groupPolicyText, policyChoices, policyLabel} from './poli
const t: Translator = (key, params) => translate('en', key, params);
it('names offered policies in words and keeps any other as written', () => {
expect(policyLabel('fallback', t)).toBe(t('arrange.policy.fallback'));
expect(policyLabel(null, t)).toBe(t('arrange.policy.manual'));
expect(policyLabel('fallback', t)).toBe(t('policy.kind.fallback'));
expect(policyLabel(null, t)).toBe(t('policy.kind.selector'));
expect(policyLabel('fixed(0)', t)).toBe('fixed(0)');
});
@@ -20,7 +20,7 @@ it('offers a policy the picker does not list as its own choice', () => {
it('names a live policy the picker does not offer by its kind, with the engine spelling beside it', () => {
expect(groupPolicyText({kind: 'urltest', native: 'min_avg10'}, t)).toEqual({label: t('policy.kind.urltest'), id: 'min_avg10'});
expect(groupPolicyText({kind: 'selector', native: 'fixed(0)'}, t)).toEqual({label: t('policy.kind.selector'), id: 'fixed(0)'});
expect(groupPolicyText({kind: 'urltest', native: 'min_moving_avg'}, t)).toEqual({label: t('arrange.policy.fastest'), id: 'min_moving_avg'});
expect(groupPolicyText({kind: 'urltest', native: 'min_moving_avg'}, t)).toEqual({label: t('policy.kind.urltest'), id: 'min_moving_avg'});
expect(groupPolicyText({kind: 'fallback', native: ''}, t)).toEqual({label: t('policy.kind.fallback'), id: 'fallback'});
});
-6
View File
@@ -1,6 +1,5 @@
{
"about.api": "API",
"about.close": "Close",
"about.contract": "Contract commit",
"about.credits": "Fonts Noto Sans TC/SC (OFL); icons Adobe Spectrum (Apache-2.0); palettes from Rosé Pine, Catppuccin, Nord, Kary Pro Colors, Ant Design, Arco Design and Semi Design.",
"about.duck": "Pet me",
@@ -114,13 +113,9 @@
},
"arrange.pendingRegion": "Changes not applied",
"arrange.policy": "Selection policy",
"arrange.policy.fallback": "First available",
"arrange.policy.fallbackHint": "Uses the current node until it fails, then the next in order",
"arrange.policy.fastest": "Fastest on average",
"arrange.policy.fastestHint": "Uses the node with the lowest recent average latency (recommended)",
"arrange.policy.manual": "Manual",
"arrange.policy.manualHint": "The node is selected by hand on the Groups tab",
"arrange.policy.score": "Score",
"arrange.policy.scoreHint": "Picks a node by its observed reliability and recent connection quality",
"arrange.policy.spread": "Round robin",
"arrange.policy.spreadHint": "Spreads connections across all nodes in turn",
@@ -1028,7 +1023,6 @@
"ov.cgroupHelp.service": "This cgroup holds only this service. Its used memory counts toward this service, and usage is the used memory against the limit.",
"ov.cgroupHelp.shared": "This cgroup also holds other processes, and its used memory and usage include them.",
"ov.config": "Config version",
"ov.configHelp": "Identifies the version of the configuration in effect. It changes when changed content takes effect.",
"ov.counters": "Traffic counters",
"ov.countersSince": "Since {t}, {scope}",
"ov.cpu": "CPU usage",
-6
View File
@@ -1,6 +1,5 @@
{
"about.api": "API",
"about.close": "关闭",
"about.contract": "契约提交",
"about.credits": "字体 Noto Sans TC/SC(OFL);图标 Adobe Spectrum(Apache-2.0);配色来自 Rosé Pine、Catppuccin、Nord、Kary Pro Colors、Ant Design、Arco Design 与 Semi Design。",
"about.duck": "摸摸我",
@@ -99,13 +98,9 @@
"arrange.pending": "{n} 项更改尚未应用",
"arrange.pendingRegion": "待应用的更改",
"arrange.policy": "选择方式",
"arrange.policy.fallback": "按顺序备用",
"arrange.policy.fallbackHint": "使用当前节点直到失效,再按顺序切换",
"arrange.policy.fastest": "平均最快",
"arrange.policy.fastestHint": "自动使用近期平均延迟最低的节点(推荐)",
"arrange.policy.manual": "手动选择",
"arrange.policy.manualHint": "在“组”标签页中自行选定节点",
"arrange.policy.score": "综合评分",
"arrange.policy.scoreHint": "根据节点的可靠性与近期连接质量自动选择",
"arrange.policy.spread": "轮流分散",
"arrange.policy.spreadHint": "将连接轮流分配到所有节点",
@@ -866,7 +861,6 @@
"ov.cgroupHelp.service": "此 cgroup 只含本服务;已用内存计入本服务,使用率按已用量与上限计算。",
"ov.cgroupHelp.shared": "此 cgroup 还包含其他进程,已用内存和使用率包括这些进程。",
"ov.config": "配置版本",
"ov.configHelp": "当前生效的配置内容的版本标识,内容变更并生效后会改变。",
"ov.counters": "流量计数",
"ov.countersSince": "自 {t} 起,{scope}",
"ov.cpu": "CPU 使用率",
-6
View File
@@ -1,6 +1,5 @@
{
"about.api": "API",
"about.close": "關閉",
"about.contract": "契約提交",
"about.credits": "字型 Noto Sans TC/SC(OFL);圖示 Adobe Spectrum(Apache-2.0);配色來自 Rosé Pine、Catppuccin、Nord、Kary Pro Colors、Ant Design、Arco Design 與 Semi Design。",
"about.duck": "摸摸我",
@@ -99,13 +98,9 @@
"arrange.pending": "{n} 項變更尚未套用",
"arrange.pendingRegion": "待套用的變更",
"arrange.policy": "選擇方式",
"arrange.policy.fallback": "依序備援",
"arrange.policy.fallbackHint": "使用目前節點直到失效,再依序切換",
"arrange.policy.fastest": "平均最快",
"arrange.policy.fastestHint": "自動使用近期平均延遲最低的節點(建議)",
"arrange.policy.manual": "手動選擇",
"arrange.policy.manualHint": "在「群組」分頁中自行選定節點",
"arrange.policy.score": "綜合評分",
"arrange.policy.scoreHint": "依節點的可靠度與近期連線品質自動選擇",
"arrange.policy.spread": "輪流分散",
"arrange.policy.spreadHint": "將連線輪流分配到所有節點",
@@ -866,7 +861,6 @@
"ov.cgroupHelp.service": "此 cgroup 只含本服務;已用記憶體計入本服務,使用率依已用量與上限計算。",
"ov.cgroupHelp.shared": "此 cgroup 還包含其他行程,已用記憶體和使用率包括這些行程。",
"ov.config": "組態版本",
"ov.configHelp": "目前生效的組態內容的版本識別碼,內容變更並生效後會改變。",
"ov.counters": "流量計數",
"ov.countersSince": "自 {t} 起,{scope}",
"ov.cpu": "CPU 使用率",
+1 -1
View File
@@ -159,7 +159,7 @@ export function shellView(
shortcutPaths: Object.fromEntries(shortcuts.map(item => [item.key, item.path])),
about: {
title: t('about.title'),
close: t('about.close'),
close: t('ui.close'),
duck: t('about.duck'),
quack: t('about.quack'),
tagline: t('about.tagline', {engine: org.split('/').pop()!}),