Skip to content

fix(ui): drop two false/stale static i18n fallbacks in index.html - #200

Merged
argszero merged 1 commit into
mainfrom
fix/ui-static-fallback-text
Sep 13, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/ui-static-fallback-text

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

ui/index.html stores every data-i18n string twice: as the element's static text (the fallback) and in the pack (ui/js/i18n.js). applyStatic() (ui/js/i18n.js:1745) replaces the element with the pack value on DOMContentLoaded, so the static fallback is normally not displayed — but it is still a second source of truth, and two of its entries assert things that are no longer true. This PR fixes exactly those two.

Related Issue

No linked issue — found during repository recon.

Changes

  • ops.hours.sub static text: 按小时用量记录 · 本地时区按小时用量记录 · 服务端 UTC 时区.
    The backend buckets today_hours by UTC (src/routes/ops.rs:5 「按小时用量记录…UTC 小时」, :115 「小时口径 = UTC(库内 time 为 datetime('now'))」) and the pack already said 「服务端 UTC 时区」 — so the fallback asserted a false fact. Introduced already-contradictory in 09e4121 (feat(ui): redesign settings/admin/ops views on the landed component layer #157): the 本地时区 static text and the UTC pack text land in the same commit.
  • settings.ep.note static text: 部署后替换为你的网关域名(原型占位说明) → the pack text 端点来自服务端配置 public_url;生产部署请在 config 中设为你的网关域名.
    The fallback was a verbatim copy of the prototype (docs/prototype/aitokenpool-console.html:705), its 「原型占位说明」 marker included. The endpoint card became config-driven in e74f7fc (feat: configurable gateway public_url for settings endpoints (v0.6.3) #96) and the pack was updated then; only the static fallback was left behind.

Both static strings are now byte-identical to their pack entry. Data-only (HTML text), zero behaviour change — the rendered UI already showed the pack value, so no user-visible output changes.

  • 功能/修复说明:如上
  • 涉及配置/数据结构的改动已同步示例文件:不适用(无配置/数据结构改动;无 i18n 键增删,786 键前后一致)

Tests

  • cargo test 全部通过 — 188 passed(数量不变,正说明没有行为移动)
  • cargo fmt --check 通过
  • cargo clippy --all-targets -- -D warnings 干净
  • Manual check: the two static strings now compare equal to their ZH pack entries; the fallback-vs-pack probe's divergence count drops 16 → 14 and both fixed keys leave the list
  • 未新增单元测试:本次改动只有 HTML 文本,而 src/i18n_pack.rs 门禁的既有不变量是「键可解析」而非「文本相等」——文本相等对其余键本来就不成立(如 view.wallet.sub 的「提现 / 申请加额」两种措辞都成立),因此不适合作为断言。

Checklist

  • 分支命名符合约定(fix/
  • Commit message 使用 Conventional Commits 格式(fix(ui):
  • 单一职责,改动最小化(1 文件 2 行;无新增/删除 i18n 键;未改 JS/CSS,故无需 cache-bust)

Non-goals

  • 不批量对齐其余 fallback 措辞差异(login.emailshare.addview.wallet.sub 等):fallback 保留旧措辞本就是它的用途,只有「假/陈旧」才是缺陷。
  • 不新增「静态文本 = 包值」门禁(理由见上)。

`ui/index.html` carries every `data-i18n` string twice: once as the
element's static text (the fallback) and once in the pack
(`ui/js/i18n.js`). `applyStatic()` overwrites the element with the pack
value on DOMContentLoaded, so the fallback is normally invisible — but it
is still a second source of truth, and two of its entries state things
that are no longer true:

- `ops.hours.sub`: 「按小时用量记录 · 本地时区」. The backend buckets
  `today_hours` by UTC (`src/routes/ops.rs:5`, `:115`) and the pack says
  「服务端 UTC 时区」. Introduced already-contradictory in 09e4121 (#157).
- `settings.ep.note`: 「部署后替换为你的网关域名(原型占位说明)」 — a
  verbatim copy of the prototype (docs/prototype/aitokenpool-console.html:705)
  including the 「原型占位说明」 marker. The endpoint card became
  config-driven in e74f7fc (#96) and the pack was updated then; only the
  static fallback was left behind.

Both static strings are now identical to their pack entry. Data-only
(HTML text), zero behaviour change: the rendered UI already showed the
pack value, so no user-visible output changes. No i18n key added or
removed (786 keys before and after), no JS/CSS touched, so no cache-bust.

The remaining fallback divergences are deliberate older wording (which is
the fallback's purpose) and are left alone; only false/stale text is a
defect.
@argszero
argszero merged commit 3d9abcd into main Sep 13, 2026
1 check passed
@argszero
argszero deleted the fix/ui-static-fallback-text branch September 13, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant