From 478787ce91723e5efe2ccab158d215dfbcc3b7b8 Mon Sep 17 00:00:00 2001 From: argszero Date: Sat, 12 Sep 2026 02:41:08 +0800 Subject: [PATCH] fix(ui): translate aria-label attributes and repair the search-clear tooltips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `applyStatic()` rewrites exactly three hooks - `[data-i18n]` (text), `[data-i18n-ph]` (placeholder) and `[data-i18n-title]` (title). There was no hook for `aria-label`, so the nine `aria-label` attributes written in the static markup stayed Chinese in English mode. Because `aria-label` outranks `title` when the accessible name is computed, an English screen-reader user heard Chinese while the visible tooltip was English - the two attributes contradicted each other on the same element. Add a fourth pass to `applyStatic()`: `[data-i18n-label]` -> `setAttribute( "aria-label", t(key))`, mirroring the existing title pass, and tag the nine sites. All three keys involved already exist in both packs, so no translations are added - this was missing wiring, not missing text: - `#login-theme-toggle`, `#theme-toggle` -> `theme.toggle.title` - six `button.search-clear` -> `mk.clear` - `#help-panel` (role="dialog") -> `help.title` While wiring those up, two adjacent defects on the same buttons surfaced and are fixed here: - the clear button inside `#ak-search` carried `data-i18n-title= "common.search"`, so its tooltip read "Search" (搜索) on a *clear* button - wrong in both languages; its sibling on `#mk-search` correctly uses `mk.clear`. - four clear buttons (`#emp-search`, `#od-search`, `#model-search`, `#ops-search`) had a bare `title="清空搜索"` with no i18n hook at all and stayed Chinese in English mode. Cache-bust bump `?v=20260911-11` -> `?v=20260911-12` (5 references). Verified in a headless browser against a baseline built by the same generator (`git archive HEAD ui`), EN and ZH, on two surfaces (login and an authenticated view), with the pre-existing `[data-i18n-title]` hook kept as a built-in negative control (CJK-free in EN in the *baseline* too, so the probe demonstrably sees translations). 24/24 assertions pass: - EN aria-label sites still Chinese: 9 -> 0; sites carrying the hook: 0 -> 9 - EN unhooked Chinese titles: 4 -> 0; hooked title sites: 10 -> 14 - ZH aria-labels still Chinese (9) - no regression - EN values: theme toggles `Toggle light / dark theme`, clear buttons `Clear search`, help panel `Shortcuts`; ZH now matches each element's own tooltip - the mislabel is gone: no `search-clear` aria-label says "Search" A runtime `I18n.setLang("en")` switch with no reload confirms the baseline keeps Chinese while its `title` goes English (the contradiction), and the fixed attributes follow the switch. --- ui/index.html | 28 ++++++++++++++-------------- ui/js/i18n.js | 10 +++++++++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ui/index.html b/ui/index.html index 1b58c92..0294015 100644 --- a/ui/index.html +++ b/ui/index.html @@ -5,13 +5,13 @@ AITokenPool - +
- @@ -154,7 +154,7 @@

进入平台

点数余额 0
- @@ -220,7 +220,7 @@

模型市场

- + - +
@@ -593,7 +593,7 @@

成员列表

- +
@@ -632,7 +632,7 @@

按部门用量

- + @@ -670,7 +670,7 @@

添加部门

- + @@ -782,7 +782,7 @@

用户充值

- +
@@ -799,7 +799,7 @@

用户充值

-