refactor(i18n): give every catalogue key an area prefix

Move the ten bare keys (clear, close, hubs, lang, moreOptions, palette,
refresh, search, theme, wordmark) under ui. or shell., and
policy.sectionCount to ui.sectionCount since the node menu uses it
outside the policy pages. check:i18n now rejects a key without an
area. prefix.
This commit is contained in:
Zakk committed 2026-09-30 03:25:28 +10:00
1 parent 01962a19ef
commit f8111c7488
19 files changed
+91 -71

No files matched your search

+6 -6
View File
@@ -30,7 +30,7 @@ test.describe('translated configuration text', () => {
await expect(routing.getByRole('list', {name: translate('zh-TW', 'config.diagnostics')})).toContainText(traditional);
await routing.locator('.cm-lintRange-error').hover();
await expect(page.locator('.cm-tooltip-lint')).toContainText(traditional);
await page.getByRole('button', {name: translate('zh-TW', 'lang'), exact: true}).click();
await page.getByRole('button', {name: translate('zh-TW', 'ui.lang'), exact: true}).click();
await page.getByRole('menuitemradio', {name: 'English'}).click();
const english = translate('en', 'config.diagnostic.unknownOutbound', {name: 'nowhere'});
await expect(routing.getByRole('list', {name: translate('en', 'config.diagnostics')})).toContainText(english);
@@ -135,7 +135,7 @@ test.describe('language loading', () => {
await page.route(localeChunk('zh-CN'), route => route.abort());
await page.goto('/#/activity');
await expect(page.locator('html')).toHaveAttribute('lang', 'en-US');
await page.getByRole('button', {name: translate('en', 'lang'), exact: true}).click();
await page.getByRole('button', {name: translate('en', 'ui.lang'), exact: true}).click();
await page.getByRole('menuitemradio', {name: '简体中文'}).click();
await expect(page.getByText(translate('en', 'shell.langUnavailable', {name: '简体中文'}))).toBeVisible();
await expect(page.locator('html')).toHaveAttribute('lang', 'en-US');
@@ -156,7 +156,7 @@ test.describe('language loading', () => {
observer.disconnect();
}).observe(html, {attributes: true, attributeFilter: ['lang']});
});
await page.getByRole('button', {name: translate('en', 'lang'), exact: true}).click();
await page.getByRole('button', {name: translate('en', 'ui.lang'), exact: true}).click();
await page.getByRole('menuitemradio', {name: '简体中文'}).click();
await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN');
expect(Number(await page.locator('html').getAttribute('data-sc-faces'))).toBeGreaterThan(0);
@@ -179,7 +179,7 @@ test.describe('language loading', () => {
}).observe(html, {attributes: true, attributeFilter: ['lang']});
return count();
});
await page.getByRole('button', {name: translate('en', 'lang'), exact: true}).click();
await page.getByRole('button', {name: translate('en', 'ui.lang'), exact: true}).click();
await page.getByRole('menuitemradio', {name: '繁體中文'}).click();
await expect(page.locator('html')).toHaveAttribute('lang', 'zh-TW');
expect(Number(await page.locator('html').getAttribute('data-tc-faces'))).toBeGreaterThan(latin + 50);
@@ -188,10 +188,10 @@ test.describe('language loading', () => {
test('zh-TW renders the same after zh-CN in one session as after a reload', async ({page}) => {
const family = () => page.evaluate(() => getComputedStyle(document.body).fontFamily);
await page.goto('/#/activity');
await page.getByRole('button', {name: translate('en', 'lang'), exact: true}).click();
await page.getByRole('button', {name: translate('en', 'ui.lang'), exact: true}).click();
await page.getByRole('menuitemradio', {name: '简体中文'}).click();
await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN');
await page.getByRole('button', {name: translate('zh-CN', 'lang'), exact: true}).click();
await page.getByRole('button', {name: translate('zh-CN', 'ui.lang'), exact: true}).click();
await page.getByRole('menuitemradio', {name: '繁體中文'}).click();
await expect(page.locator('html')).toHaveAttribute('lang', 'zh-TW');
const switched = await family();
+1 -1
View File
@@ -281,7 +281,7 @@ function DnsLog({
<ActionGroup
actions={[
// On a phone the first action stays a button, so Refresh keeps its place ahead of Export.
{id: 'refresh', label: t('refresh'), icon: <Refresh className="rp-spin-on-press" />, isPending: vm.refreshing, onAction: vm.refresh},
{id: 'refresh', label: t('ui.refresh'), icon: <Refresh className="rp-spin-on-press" />, isPending: vm.refreshing, onAction: vm.refresh},
{id: 'export', label: t('dns.exportLog'), icon: <Download />, isDisabled: !vm.rows.length, onAction: vm.export},
{
id: 'rule',
+4 -4
View File
@@ -151,11 +151,11 @@ export function Settings({query}: PageProps) {
appearance: (
<Card level={2} title={t(cards.appearance.titleKey)} titleId={cards.appearance.headingId}>
<div className="rp-toolbar">
<LabeledSelect label={t('lang')} value={lang} onChange={value => pickLang(value as Lang)} items={LANGS.map(([id, label]) => ({id, label}))} />
<LabeledSelect label={t('ui.lang')} value={lang} onChange={value => pickLang(value as Lang)} items={LANGS.map(([id, label]) => ({id, label}))} />
<div className="rp-field">
<span className="lbl">{t('palette')}</span>
<span className="lbl">{t('ui.palette')}</span>
<ChoiceMenu
label={t('palette')}
label={t('ui.palette')}
sections={paletteSections.map(section => ({...section, value: ap.palette, onChange: (value: string) => ap.pickPalette(value as PaletteId)}))}
>
{palette}
@@ -172,7 +172,7 @@ export function Settings({query}: PageProps) {
]}
/>
<LabeledSelect
label={t('wordmark')}
label={t('ui.wordmark')}
value={ap.wordmark}
onChange={value => ap.pickWordmark(value as Wordmark)}
items={[
+1 -1
View File
@@ -20,5 +20,5 @@ export function menuViews(nodes: Array<{id?: string; name: string; label?: strin
if (group) group.push(node);
else groups.set(node.region, [node]);
}
return {items, sections: [...groups].map(([title, items]) => ({title, items, count: t('policy.sectionCount', {n: items.length})}))};
return {items, sections: [...groups].map(([title, items]) => ({title, items, count: t('ui.sectionCount', {n: items.length})}))};
}
+11 -11
View File
@@ -159,8 +159,6 @@
"arrange.undoRemove": "Undo removing {name}",
"arrange.undoShort": "Undo",
"arrange.unknown": "No node is named {names} right now; the name takes effect once such a node appears.",
"clear": "Clear",
"close": "Close",
"cm.all": "All",
"cm.byWord": "By word",
"cm.commands": "Editing commands",
@@ -778,8 +776,6 @@
"hub.routing": "Routing",
"hub.settings": "Settings",
"hub.traffic": "Monitor",
"hubs": "Sections",
"lang": "Language",
"lifecycle.degraded": "Degraded",
"lifecycle.draining": "Draining",
"lifecycle.failed": "Failed",
@@ -888,7 +884,6 @@
"mode.direct": "Direct",
"mode.global": "Global",
"mode.rule": "Rule",
"moreOptions": "More options",
"nav.activity": "Activity",
"nav.config": "Configuration",
"nav.connections": "Connections",
@@ -1182,7 +1177,6 @@
"ov.v.real": "Real",
"ov.v.unknown": "Unknown",
"ov.v.userspace": "Userspace",
"palette": "Palette",
"palette.antd": "Ant Design",
"palette.arco": "Arco Design",
"palette.bytedance": "ByteDance",
@@ -1292,7 +1286,6 @@
"policy.releaseOverride": "Back to automatic",
"policy.removeFilter": "Remove filter {n}",
"policy.save": "Apply",
"policy.sectionCount": " ({n})",
"policy.selectedInterrupted": "{name} selected {member}; existing connections interrupted",
"policy.selectedKept": "{name} selected {member}; existing connections kept",
"policy.sort": "Sort",
@@ -1308,7 +1301,6 @@
"policy.updated": "Configuration for {name} written and reloaded",
"policy.viewGroup": "View group",
"policy.viewGroups": "View groups",
"refresh": "Refresh",
"rule.add": "Add rule",
"rule.addApply": "Apply",
"rule.addHelp": "Adds the rule to the source file's routing section, then writes and reloads after validation passes.",
@@ -1489,7 +1481,6 @@
"rule.viewGroup": "View group {name}",
"rule.viewNode": "View node {name}",
"rule.where": "Where",
"search": "Search pages, connections, nodes, groups and sources",
"search.groups": "Groups",
"search.nodeCount": {
"one": "{n} node",
@@ -1675,6 +1666,7 @@
"shell.backend.title": "Backend",
"shell.backendBusy": "Backend busy: retrying in {n} s",
"shell.guide": "Guide",
"shell.hubs": "Sections",
"shell.keyCtrl": "Ctrl",
"shell.keyEnter": "Enter",
"shell.keyEsc": "Esc",
@@ -1686,6 +1678,7 @@
"shell.reloadEngine": "Reload honk",
"shell.reloadHelp": "honk reads its configuration files again and reloads. Held rules are not written.",
"shell.reloadTitle": "Reload honk?",
"shell.search": "Search pages, connections, nodes, groups and sources",
"shell.searchUnavailable": "Could not open search: it did not load.",
"shell.shortcut": "Ctrl K",
"shell.shortcutApply": "Apply",
@@ -1705,7 +1698,6 @@
"shell.shortcuts": "Keyboard shortcuts",
"shell.theme": "Theme: {theme}",
"shell.toActivity": "Back to activity",
"theme": "Theme",
"theme.dark": "Dark",
"theme.light": "Light",
"theme.system": "System",
@@ -1796,7 +1788,9 @@
"ui.cancel": "Cancel",
"ui.changeApplying": "Another change is being applied",
"ui.chartPart": "{label} {value}",
"ui.clear": "Clear",
"ui.clearFilters": "Clear filters",
"ui.close": "Close",
"ui.config": "Configuration",
"ui.current": "Current",
"ui.delete": "Delete",
@@ -1823,6 +1817,7 @@
"ui.helpFor": "About {name}",
"ui.interfaceTextUnavailable": "The interface text could not be loaded.",
"ui.invalidIp": "Enter an IPv4 or IPv6 address.",
"ui.lang": "Language",
"ui.latency": "{n} ms",
"ui.listSeparator": ", ",
"ui.loadFailed": "Could not load data: {error}",
@@ -1830,6 +1825,7 @@
"ui.microseconds": "{n} μs",
"ui.moreActions": "More actions",
"ui.moreActionsFor": "More actions for {name}",
"ui.moreOptions": "More options",
"ui.name": "Name",
"ui.network": "Network protocol",
"ui.newBuild": "A new version is ready; reload the page to use it.",
@@ -1841,11 +1837,13 @@
"ui.operationFailed": "The operation did not succeed",
"ui.operationUnknown": "Could not confirm the result of the operation; the data was reloaded",
"ui.outbound": "Outbound",
"ui.palette": "Palette",
"ui.percent": "{n}%",
"ui.probeUnsupported": "This backend does not provide a TCP probe for this target",
"ui.process": "Process name",
"ui.protocol": "Protocol",
"ui.recordingSettings": "Recording settings",
"ui.refresh": "Refresh",
"ui.refreshFailed": "Could not refresh data",
"ui.refreshed": "Data refreshed.",
"ui.reloadPage": "Reload",
@@ -1856,6 +1854,7 @@
"ui.saved": "Settings saved.",
"ui.seconds": "{n} s",
"ui.sectionChoice": "{section} {item}",
"ui.sectionCount": " ({n})",
"ui.selectRow": "Select a row first",
"ui.separator": ", ",
"ui.share": "{bytes}, {percent}%",
@@ -1866,6 +1865,7 @@
"ui.state": "State",
"ui.target": "Target",
"ui.tcp": "TCP",
"ui.theme": "Theme",
"ui.time": "Time",
"ui.type": "Type",
"ui.udp": "UDP",
@@ -1875,6 +1875,7 @@
"ui.upstream": "Upstream",
"ui.valuePair": "{label}: {value}",
"ui.warning": "Warning",
"ui.wordmark": "Wordmark",
"ui.writeFailed": "Could not write the configuration",
"ui.writeInvalid": {
"one": "Validation found {n} error; nothing written",
@@ -1900,7 +1901,6 @@
"unit.terabitPerSecond": "{n} Tbps",
"unit.terabyte": "{n} TB",
"unit.terabytePerSecond": "{n} TB/s",
"wordmark": "Wordmark",
"wordmark.gradient": "Gradient",
"wordmark.plain": "Plain"
}
+11 -11
View File
@@ -132,8 +132,6 @@
"arrange.undoRemove": "撤销移除 {name}",
"arrange.undoShort": "撤销",
"arrange.unknown": "当前没有名为 {names} 的节点;写入后,该名称在对应节点出现时才会生效。",
"clear": "清除",
"close": "关闭",
"cm.all": "全部",
"cm.byWord": "整词",
"cm.commands": "编辑命令",
@@ -655,8 +653,6 @@
"hub.routing": "路由",
"hub.settings": "设置",
"hub.traffic": "观测",
"hubs": "页面分区",
"lang": "语言",
"lifecycle.degraded": "降级",
"lifecycle.draining": "排空中",
"lifecycle.failed": "失败",
@@ -747,7 +743,6 @@
"mode.direct": "直连",
"mode.global": "全局",
"mode.rule": "规则",
"moreOptions": "更多选项",
"nav.activity": "活动",
"nav.config": "配置",
"nav.connections": "连接",
@@ -1011,7 +1006,6 @@
"ov.v.real": "真实",
"ov.v.unknown": "未知",
"ov.v.userspace": "用户空间",
"palette": "配色",
"palette.antd": "Ant Design",
"palette.arco": "Arco Design",
"palette.bytedance": "ByteDance",
@@ -1112,7 +1106,6 @@
"policy.releaseOverride": "恢复自动选择",
"policy.removeFilter": "移除筛选 {n}",
"policy.save": "应用",
"policy.sectionCount": "({n})",
"policy.selectedInterrupted": "{name} 已选择 {member},现有连接已中断",
"policy.selectedKept": "{name} 已选择 {member},现有连接未中断",
"policy.sort": "排序",
@@ -1128,7 +1121,6 @@
"policy.updated": "{name} 配置已写入并重载",
"policy.viewGroup": "查看组",
"policy.viewGroups": "查看全部组",
"refresh": "刷新",
"rule.add": "新建规则",
"rule.addApply": "应用",
"rule.addHelp": "将规则写入来源文件的 routing 区段;校验通过后写入并重载。",
@@ -1294,7 +1286,6 @@
"rule.viewGroup": "查看组 {name}",
"rule.viewNode": "查看节点 {name}",
"rule.where": "位置",
"search": "搜索页面、连接、节点、组和来源",
"search.groups": "组",
"search.nodeCount": "{n} 个节点",
"search.nodes": "节点",
@@ -1474,6 +1465,7 @@
"shell.backend.title": "后端",
"shell.backendBusy": "后端繁忙:{n} 秒后重试",
"shell.guide": "指南",
"shell.hubs": "页面分区",
"shell.keyCtrl": "Ctrl",
"shell.keyEnter": "Enter",
"shell.keyEsc": "Esc",
@@ -1485,6 +1477,7 @@
"shell.reloadEngine": "重载 honk",
"shell.reloadHelp": "honk 会重新读取配置文件并重载。暂存的规则不会写入。",
"shell.reloadTitle": "重载 honk?",
"shell.search": "搜索页面、连接、节点、组和来源",
"shell.searchUnavailable": "无法打开搜索:搜索功能加载失败。",
"shell.shortcut": "Ctrl K",
"shell.shortcutApply": "应用",
@@ -1504,7 +1497,6 @@
"shell.shortcuts": "键盘快捷键",
"shell.theme": "主题:{theme}",
"shell.toActivity": "回到活动",
"theme": "主题",
"theme.dark": "深色",
"theme.light": "浅色",
"theme.system": "跟随系统",
@@ -1595,7 +1587,9 @@
"ui.cancel": "取消",
"ui.changeApplying": "另一项修改正在应用",
"ui.chartPart": "{label} {value}",
"ui.clear": "清除",
"ui.clearFilters": "清除筛选",
"ui.close": "关闭",
"ui.config": "配置",
"ui.current": "当前",
"ui.delete": "删除",
@@ -1622,6 +1616,7 @@
"ui.helpFor": "关于{name}",
"ui.interfaceTextUnavailable": "无法加载界面文字。",
"ui.invalidIp": "须为 IPv4 或 IPv6 地址。",
"ui.lang": "语言",
"ui.latency": "{n} ms",
"ui.listSeparator": "、",
"ui.loadFailed": "无法加载数据:{error}",
@@ -1629,6 +1624,7 @@
"ui.microseconds": "{n} μs",
"ui.moreActions": "更多操作",
"ui.moreActionsFor": "{name} 的更多操作",
"ui.moreOptions": "更多选项",
"ui.name": "名称",
"ui.network": "网络协议",
"ui.newBuild": "新版本已就绪,重新加载页面后生效。",
@@ -1640,11 +1636,13 @@
"ui.operationFailed": "操作未完成",
"ui.operationUnknown": "无法确认操作结果,已重新加载数据",
"ui.outbound": "出站",
"ui.palette": "配色",
"ui.percent": "{n}%",
"ui.probeUnsupported": "此后端不提供该目标的 TCP 探测",
"ui.process": "进程名称",
"ui.protocol": "协议",
"ui.recordingSettings": "记录设置",
"ui.refresh": "刷新",
"ui.refreshFailed": "无法刷新数据",
"ui.refreshed": "数据已刷新。",
"ui.reloadPage": "重新加载",
@@ -1655,6 +1653,7 @@
"ui.saved": "设置已保存。",
"ui.seconds": "{n} 秒",
"ui.sectionChoice": "{section} {item}",
"ui.sectionCount": "({n})",
"ui.selectRow": "先选一行",
"ui.separator": ",",
"ui.share": "{bytes},{percent}%",
@@ -1665,6 +1664,7 @@
"ui.state": "状态",
"ui.target": "目标",
"ui.tcp": "TCP",
"ui.theme": "主题",
"ui.time": "时间",
"ui.type": "类型",
"ui.udp": "UDP",
@@ -1674,6 +1674,7 @@
"ui.upstream": "上游",
"ui.valuePair": "{label}:{value}",
"ui.warning": "警告",
"ui.wordmark": "字标",
"ui.writeFailed": "无法写入配置",
"ui.writeInvalid": "校验发现 {n} 个错误,未写入",
"ui.writtenNotApplied": "已写入配置文件,但未生效,运行中的配置未变更。请修正文件后重载,或重启 honk",
@@ -1696,7 +1697,6 @@
"unit.terabitPerSecond": "{n} Tbps",
"unit.terabyte": "{n} TB",
"unit.terabytePerSecond": "{n} TB/s",
"wordmark": "字标",
"wordmark.gradient": "渐变",
"wordmark.plain": "纯色"
}
+11 -11
View File
@@ -132,8 +132,6 @@
"arrange.undoRemove": "復原移除 {name}",
"arrange.undoShort": "復原",
"arrange.unknown": "目前沒有名為 {names} 的節點;寫入後,該名稱在對應節點出現時才會生效。",
"clear": "清除",
"close": "關閉",
"cm.all": "全部",
"cm.byWord": "整字",
"cm.commands": "編輯指令",
@@ -655,8 +653,6 @@
"hub.routing": "路由",
"hub.settings": "設定",
"hub.traffic": "觀測",
"hubs": "頁面分區",
"lang": "語言",
"lifecycle.degraded": "降級",
"lifecycle.draining": "排空中",
"lifecycle.failed": "失敗",
@@ -747,7 +743,6 @@
"mode.direct": "直連",
"mode.global": "全域",
"mode.rule": "規則",
"moreOptions": "更多選項",
"nav.activity": "活動",
"nav.config": "組態",
"nav.connections": "連線",
@@ -1011,7 +1006,6 @@
"ov.v.real": "真實",
"ov.v.unknown": "未知",
"ov.v.userspace": "使用者空間",
"palette": "配色",
"palette.antd": "Ant Design",
"palette.arco": "Arco Design",
"palette.bytedance": "ByteDance",
@@ -1112,7 +1106,6 @@
"policy.releaseOverride": "恢復自動選擇",
"policy.removeFilter": "移除篩選 {n}",
"policy.save": "套用",
"policy.sectionCount": "({n})",
"policy.selectedInterrupted": "{name} 已選擇 {member},現有連線已中斷",
"policy.selectedKept": "{name} 已選擇 {member},現有連線未中斷",
"policy.sort": "排序",
@@ -1128,7 +1121,6 @@
"policy.updated": "{name} 組態已寫入並重載",
"policy.viewGroup": "檢視群組",
"policy.viewGroups": "檢視全部群組",
"refresh": "重新整理",
"rule.add": "新增規則",
"rule.addApply": "套用",
"rule.addHelp": "將規則寫入來源檔案的 routing 區段;驗證通過後寫入並重載。",
@@ -1294,7 +1286,6 @@
"rule.viewGroup": "檢視群組 {name}",
"rule.viewNode": "檢視節點 {name}",
"rule.where": "位置",
"search": "搜尋頁面、連線、節點、群組與來源",
"search.groups": "群組",
"search.nodeCount": "{n} 個節點",
"search.nodes": "節點",
@@ -1474,6 +1465,7 @@
"shell.backend.title": "後端",
"shell.backendBusy": "後端忙碌:{n} 秒後重試",
"shell.guide": "指南",
"shell.hubs": "頁面分區",
"shell.keyCtrl": "Ctrl",
"shell.keyEnter": "Enter",
"shell.keyEsc": "Esc",
@@ -1485,6 +1477,7 @@
"shell.reloadEngine": "重載 honk",
"shell.reloadHelp": "honk 會重新讀取組態檔案並重載。暫存的規則不會寫入。",
"shell.reloadTitle": "重載 honk?",
"shell.search": "搜尋頁面、連線、節點、群組與來源",
"shell.searchUnavailable": "無法開啟搜尋:搜尋功能載入失敗。",
"shell.shortcut": "Ctrl K",
"shell.shortcutApply": "套用",
@@ -1504,7 +1497,6 @@
"shell.shortcuts": "鍵盤快捷鍵",
"shell.theme": "主題:{theme}",
"shell.toActivity": "回到活動",
"theme": "主題",
"theme.dark": "暗色",
"theme.light": "亮色",
"theme.system": "跟隨系統",
@@ -1595,7 +1587,9 @@
"ui.cancel": "取消",
"ui.changeApplying": "另一項修改正在套用",
"ui.chartPart": "{label} {value}",
"ui.clear": "清除",
"ui.clearFilters": "清除篩選",
"ui.close": "關閉",
"ui.config": "組態",
"ui.current": "目前",
"ui.delete": "刪除",
@@ -1622,6 +1616,7 @@
"ui.helpFor": "關於{name}",
"ui.interfaceTextUnavailable": "無法載入介面文字。",
"ui.invalidIp": "須為 IPv4 或 IPv6 位址。",
"ui.lang": "語言",
"ui.latency": "{n} ms",
"ui.listSeparator": "、",
"ui.loadFailed": "無法載入資料:{error}",
@@ -1629,6 +1624,7 @@
"ui.microseconds": "{n} μs",
"ui.moreActions": "更多操作",
"ui.moreActionsFor": "{name} 的更多操作",
"ui.moreOptions": "更多選項",
"ui.name": "名稱",
"ui.network": "網路協定",
"ui.newBuild": "新版本已就緒,重新載入頁面後生效。",
@@ -1640,11 +1636,13 @@
"ui.operationFailed": "操作未完成",
"ui.operationUnknown": "無法確認操作結果,已重新載入資料",
"ui.outbound": "出站",
"ui.palette": "配色",
"ui.percent": "{n}%",
"ui.probeUnsupported": "此後端不提供該目標的 TCP 探測",
"ui.process": "行程名稱",
"ui.protocol": "協定",
"ui.recordingSettings": "記錄設定",
"ui.refresh": "重新整理",
"ui.refreshFailed": "無法重新整理資料",
"ui.refreshed": "資料已重新整理。",
"ui.reloadPage": "重新載入",
@@ -1655,6 +1653,7 @@
"ui.saved": "設定已儲存。",
"ui.seconds": "{n} 秒",
"ui.sectionChoice": "{section} {item}",
"ui.sectionCount": "({n})",
"ui.selectRow": "先選一列",
"ui.separator": ",",
"ui.share": "{bytes},{percent}%",
@@ -1665,6 +1664,7 @@
"ui.state": "狀態",
"ui.target": "目標",
"ui.tcp": "TCP",
"ui.theme": "主題",
"ui.time": "時間",
"ui.type": "類型",
"ui.udp": "UDP",
@@ -1674,6 +1674,7 @@
"ui.upstream": "上游",
"ui.valuePair": "{label}:{value}",
"ui.warning": "警告",
"ui.wordmark": "字標",
"ui.writeFailed": "無法寫入組態",
"ui.writeInvalid": "驗證發現 {n} 個錯誤,未寫入",
"ui.writtenNotApplied": "已寫入組態檔,但未生效,執行中的組態未變更。請修正檔案後重載,或重新啟動 honk",
@@ -1696,7 +1697,6 @@
"unit.terabitPerSecond": "{n} Tbps",
"unit.terabyte": "{n} TB",
"unit.terabytePerSecond": "{n} TB/s",
"wordmark": "字標",
"wordmark.gradient": "漸層",
"wordmark.plain": "純色"
}
+3 -3
View File
@@ -26,7 +26,7 @@ export function LanguageMenu({lang, pickLang}: {lang: Lang; pickLang: (lang: Lan
// The icon turns in when the language changes, like the scheme icon; not on first paint.
const [first] = useState(lang);
return (
<ChoiceMenu quiet chevron={false} label={t('lang')} value={lang} onChange={k => pickLang(k as Lang)} items={languageItems}>
<ChoiceMenu quiet chevron={false} label={t('ui.lang')} value={lang} onChange={k => pickLang(k as Lang)} items={languageItems}>
<Translate key={lang} className={lang !== first ? 'rp-icon-in' : undefined} />
</ChoiceMenu>
);
@@ -45,7 +45,7 @@ export function usePaletteChoices({ap, paletteSections, wordmarks}: PaletteMenuP
const t = useT();
return {
palettes: paletteSections.map(section => ({...section, value: ap.palette, onChange: (k: string) => ap.pickPalette(k as PaletteId)})),
wordmarks: {title: t('wordmark'), items: wordmarks, value: ap.wordmark, onChange: (k: string) => ap.pickWordmark(k as Wordmark)}
wordmarks: {title: t('ui.wordmark'), items: wordmarks, value: ap.wordmark, onChange: (k: string) => ap.pickWordmark(k as Wordmark)}
};
}
@@ -56,7 +56,7 @@ export function PaletteMenu(props: PaletteMenuProps) {
// The icon turns in when the palette changes, like the scheme icon; not on first paint.
const [first] = useState(palette);
return (
<ChoiceMenu quiet chevron={false} label={t('palette')} sections={[...palettes, wordmarks]}>
<ChoiceMenu quiet chevron={false} label={t('ui.palette')} sections={[...palettes, wordmarks]}>
<Color key={palette} className={palette !== first ? 'rp-icon-in' : undefined} />
</ChoiceMenu>
);
+1 -1
View File
@@ -29,7 +29,7 @@ export function HubBar({groups}: {groups: NavGroup[]}) {
}
}, [last]);
return (
<nav className="rp-hubbar" aria-label={t('hubs')}>
<nav className="rp-hubbar" aria-label={t('shell.hubs')}>
{groups.map(group => {
const Icon = group.items[0].Icon;
return (
+7 -2
View File
@@ -103,7 +103,12 @@ export function Shortcuts({
}, [go, openSearch, refresh, paths]);
const mod = mac ? '⌘' : `${t('shell.keyCtrl')} `;
return (
<ModalDialog title={t('shell.shortcuts')} isOpen={open} onOpenChange={setOpen} footer={() => <Button onPress={() => setOpen(false)}>{t('close')}</Button>}>
<ModalDialog
title={t('shell.shortcuts')}
isOpen={open}
onOpenChange={setOpen}
footer={() => <Button onPress={() => setOpen(false)}>{t('ui.close')}</Button>}
>
<div className="rp-shortcuts">
<div>
<section>
@@ -111,7 +116,7 @@ export function Shortcuts({
<Row label={t('shell.shortcutSearch')} keys={[t(mac ? 'shell.macShortcut' : 'shell.shortcut')]} />
<Row label={t('shell.shortcutHelp')} keys={['?']} />
<Row label={t('shell.shortcutFilter')} keys={['/']} />
<Row label={t('refresh')} keys={['R']} />
<Row label={t('ui.refresh')} keys={['R']} />
</section>
<section>
<h3>{t('shell.shortcutTables')}</h3>
+14 -10
View File
@@ -84,17 +84,17 @@ export const TopBar = memo(function TopBar({
<div className="rp-search-wrap" onPointerEnter={preloadSearch} onFocus={preloadSearch}>
<Button appearance="plain" className="rp-search" onPress={openSearch}>
<Search />
<span className="grow">{t('search')}</span>
<span className="grow">{t('shell.search')}</span>
<span className="rp-kbd">{mac ? t('shell.macShortcut') : t('shell.shortcut')}</span>
</Button>
</div>
<div className="rp-actions">
<span className="rp-search-compact" onPointerEnter={preloadSearch} onFocus={preloadSearch}>
<Button quiet icon label={t('search')} onPress={openSearch}>
<Button quiet icon label={t('shell.search')} onPress={openSearch}>
<Search />
</Button>
</span>
<Button quiet icon label={t('refresh')} isPending={spinning} onPress={refresh}>
<Button quiet icon label={t('ui.refresh')} isPending={spinning} onPress={refresh}>
<DataRefresh />
</Button>
{commands.apply && (
@@ -127,16 +127,20 @@ export const TopBar = memo(function TopBar({
<ChoiceMenu
quiet
chevron={false}
label={t('moreOptions')}
label={t('ui.moreOptions')}
submenus={[
{label: t('lang'), icon: <Translate />, sections: [{title: t('lang'), items: languageItems, value: lang, onChange: k => pickLang(k as Lang)}]},
{
label: t('theme'),
icon: <Contrast />,
sections: [{title: t('theme'), items: menu.schemes, value: ap.scheme, onChange: k => ap.pickScheme(k as Scheme)}]
label: t('ui.lang'),
icon: <Translate />,
sections: [{title: t('ui.lang'), items: languageItems, value: lang, onChange: k => pickLang(k as Lang)}]
},
{label: t('palette'), icon: <Color />, sections: palettes},
{label: t('wordmark'), icon: <img src={logo} alt="" />, sections: [wordmarks]}
{
label: t('ui.theme'),
icon: <Contrast />,
sections: [{title: t('ui.theme'), items: menu.schemes, value: ap.scheme, onChange: k => ap.pickScheme(k as Scheme)}]
},
{label: t('ui.palette'), icon: <Color />, sections: palettes},
{label: t('ui.wordmark'), icon: <img src={logo} alt="" />, sections: [wordmarks]}
]}
actions={[
...(commands.reload ? [{label: commands.reload.label, icon: <Refresh />, onAction: askReload}] : []),
+4 -4
View File
@@ -10,7 +10,7 @@ export function SearchDialog({onClose, go}: {onClose: () => void; go: PageProps[
const {q, setQ, sections, partial, openConnections, empty, error, retry, loading, select} = useSearch(go, onClose);
return (
<ModalDialog
title={t('search')}
title={t('shell.search')}
hideTitle
isOpen
onOpenChange={open => {
@@ -21,8 +21,8 @@ export function SearchDialog({onClose, go}: {onClose: () => void; go: PageProps[
<Autocomplete inputValue={q} onInputChange={setQ}>
<div className="rp-toolbar">
{/* eslint-disable-next-line jsx-a11y/no-autofocus -- focus moves into the dialog the user just opened */}
<TextField search large label={t('search')} value={q} onChange={setQ} autoFocus className="rp-grow" />
<Button quiet icon onPress={onClose} label={t('close')}>
<TextField search large label={t('shell.search')} value={q} onChange={setQ} autoFocus className="rp-grow" />
<Button quiet icon onPress={onClose} label={t('ui.close')}>
<Close />
</Button>
</div>
@@ -36,7 +36,7 @@ export function SearchDialog({onClose, go}: {onClose: () => void; go: PageProps[
</div>
)}
{empty && (loading ? <Loading /> : <Empty>{t('search.none')}</Empty>)}
<ListBox aria-label={t('search')} className="rp-results" onAction={select}>
<ListBox aria-label={t('shell.search')} className="rp-results" onAction={select}>
{sections.map(section => (
<ListBoxSection key={section.id} id={section.id}>
<Header className="rp-sec-h">{section.title}</Header>
+1 -1
View File
@@ -389,7 +389,7 @@ export function DetailPanel({open, title, onClose, children}: {open: boolean; ti
const head = (
<div className="rp-row">
<h3 className="rp-h3">{title}</h3>
<RButton className="rp-btn quiet icon close" aria-label={t('close')} onPress={onClose}>
<RButton className="rp-btn quiet icon close" aria-label={t('ui.close')} onPress={onClose}>
<Close />
</RButton>
</div>
+1 -1
View File
@@ -274,7 +274,7 @@ function ToastItem({
)}
</div>
</ToastContent>
<RButton slot="close" className="rp-btn quiet icon close" aria-label={t('close')}>
<RButton slot="close" className="rp-btn quiet icon close" aria-label={t('ui.close')}>
<Close />
</RButton>
{(more || action) && (
+1 -1
View File
@@ -158,7 +158,7 @@ export function TextField({
<span className={cx('rp-input', large && 'lg')}>
<Search />
<RInput placeholder={placeholder ?? label} autoComplete={autoComplete} spellCheck={spellCheck} />
<RButton className="clear" aria-label={t('clear')}>
<RButton className="clear" aria-label={t('ui.clear')}>
<Close />
</RButton>
</span>
+1 -1
View File
@@ -43,7 +43,7 @@ const cmPhrases: Array<[string, Key]> = [
['by word', 'cm.byWord'],
['replace', 'cm.replaceOne'],
['replace all', 'cm.replaceAll'],
['close', 'close'],
['close', 'ui.close'],
['Go to line', 'cm.gotoLine'],
['go', 'cm.go'],
['current match', 'cm.currentMatch'],
+2
View File
@@ -20,6 +20,8 @@ const pluralCategories = locale => {
const placeholders = text => [...new Set([...text.matchAll(/\{(\w+)\}/g)].map(match => match[1]))].sort().join(',');
// A message's forms by name; a plain string is the general form, `other`.
const forms = message => (typeof message === 'string' ? {other: message} : message);
// A key names its area first, `area.name`, the way the other keys do; a bare key such as `close` has no area.
export const areaPrefixFailures = keys => keys.filter(key => !/^\w+\.\w/.test(key)).map(key => `Message key has no area prefix: ${key}`);
// Each form of a message against the reference's form of the same name, else its general form, so a plural form that
// drops a placeholder is caught even when another form keeps it.
function placeholderFailures(file, key, message, expected, reference) {
+9 -1
View File
@@ -1,11 +1,19 @@
import {expect, it} from 'vitest';
import {checkCatalogues, missingLanguage, readCatalogues} from './catalogues.mjs';
import {areaPrefixFailures, checkCatalogues, missingLanguage, readCatalogues} from './catalogues.mjs';
// A made-up partial language, xx, beside a two-key reference.
const en = {'a.count': {one: '{n} item', other: '{n} items'}, 'b.title': 'Title {name}'};
const locales = {en: 'en-US', xx: 'en-US', ar: 'ar'};
const check = (xx, complete = new Set(['en'])) => checkCatalogues({en, xx}, 'en', complete, locales);
it('rejects a key without an area prefix', () => {
expect(areaPrefixFailures(['ui.close', 'close', 'ui.', '.close'])).toEqual([
'Message key has no area prefix: close',
'Message key has no area prefix: ui.',
'Message key has no area prefix: .close'
]);
});
it('lets a partial language leave keys out and reports them', () => {
expect(check({'b.title': 'Xx {name}'})).toEqual({failures: [], missing: {en: [], xx: ['a.count']}});
});
+2 -1
View File
@@ -1,6 +1,6 @@
import ts from 'typescript';
import {existsSync, readFileSync, readdirSync} from 'node:fs';
import {checkCatalogues, missingLanguage, readCatalogues} from './catalogues.mjs';
import {areaPrefixFailures, checkCatalogues, missingLanguage, readCatalogues} from './catalogues.mjs';
import {languages, REFERENCE_LANG} from './languages.mjs';
import {startupKeys} from './startup-text.mjs';
@@ -76,6 +76,7 @@ if (!catalogues[REFERENCE_LANG]) {
process.exit(1);
}
const reference = catalogues[REFERENCE_LANG];
failures.push(...areaPrefixFailures(Object.keys(reference)));
const checked = checkCatalogues(
catalogues,
REFERENCE_LANG,