Repository navigation
fix(ui): render the raise-request table header in the active language - #166
Merged
Merged
Conversation
The admin "raise requests" table built its `<thead>` from Chinese string
literals inside `renderRaiseRequests()` (app.js). Because that markup is
injected after boot and carries no `data-i18n`, `applyStatic()` had no path to
it, so the header stayed Chinese in English mode. The same table's body cells
were already translated by C1991 (`data-label` via `T(admin.raise.col.*)`), so
the language fix was only half applied - which inverted the result on narrow
screens:
1400px, English: th = 成员 / 申请点数 / 原因 / 状态 (Chinese, visible)
390px, English: th hidden, td::before = Member / Requested pts / ... (English)
Resolve the four header cells with `T()` at render time instead of embedding
literals. Render-time lookup (rather than a `data-i18n` attribute) is required
because the table is re-injected by the existing `atp:langchange` ->
`renderView` path, so the header must be produced already translated and must
re-read the language on every rebuild. This mirrors the existing precedent in
this file: the transaction table resolves headers via `col.title()` in
`tableTheadHtml()`.
No new i18n keys: `admin.raise.col.member/amount/reason/status` already exist
in both packs (they were used by the `data-label` attributes right below).
Verified in a headless browser against a baseline built from the same
generator, EN and ZH, at 1400px and 390px: baseline header = 10 CJK chars in
EN (negative control `#emp-body` = 0, proving the probe sees translations),
fixed header = 0 CJK with exactly `Member / Requested pts / Reason / Status`;
ZH output byte-identical to baseline; body `data-label`s and row count
unchanged. A runtime `I18n.setLang("en")` switch with no reload confirms the
baseline keeps a Chinese header while its `data-label`s go English (the
inversion), and the fixed header follows the switch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The admin "raise requests" table (US-20) rendered its
<thead>from Chinese string literals insiderenderRaiseRequests()(ui/js/app.js). That markup is injected viainnerHTMLafter boot and carries nodata-i18n, soapplyStatic()had no hook to reach it — the header stayed Chinese in English mode.The same table's body cells had already been i18n-ised (
data-label+T("admin.raise.col.*")), so the translation was only half applied. On narrow screens this inverted the result:成员 / 申请点数 / 原因 / 状态— Chinesedisplay:none,td::before)Member / Requested pts / Reason / Status— Englishi.e. the table was correctly translated exactly where it is invisible, and untranslated exactly where it is visible.
Related Issue
(No issue — reported and fixed directly; small, self-contained bug.)
Changes
<th>cells withT("admin.raise.col.member"/"amount"/"reason"/"status")at render time instead of embedding Chinese literals. The deliberately empty 5th column header is unchanged.?v=20260911-10→?v=20260911-11(5 references inui/index.html).Why render-time
T()rather than adata-i18nattribute: the table is re-injected by the existingatp:langchange→renderViewpath, so the header must be produced already translated and must re-read the language on every rebuild. An attribute-only fix would still show Chinese until the next language switch. This follows the established precedent in the same file — the transaction table resolves its headers throughcol.title()intableTheadHtml().No new i18n keys. The four
admin.raise.col.*keys already exist in both packs (they were used by thedata-labelattributes in the very same function), so this is missing wiring, not a missing translation.Tests
cargo test— 148 passed, 0 failedcargo fmt --check— cleancargo clippy --all-targets -- -D warnings— cleannode --check ui/js/app.js— cleani18n.jsmodule, not by regex) with zero added keysVerified in a headless browser. Baseline and fixed trees were produced by the same generator (baseline =
git archive HEAD ui), measured in EN and ZH at 1400px and 390px:Member / Requested pts / Reason / Status#emp-body(index.html-authored header carryingdata-i18n) renders in English in the baseline too — so the probe demonstrably sees translations, and the baseline differential is real rather than a blind probedata-labels (5) and row count (3) unchanged vs baseline — no regressiontddata-labels (inversion gone)I18n.setLang("en")switch with no reload: baseline keeps a Chinese header while itsdata-labels become English (the inversion), fixed header follows the switchChecklist
fix/)fix(ui): ...)