Repository navigation
feat(web): add Simplified Chinese (zh-CN) UI locale - #41
Conversation
Add catalog-backed i18n for web chrome with English as the source locale and a complete zh-CN catalog. Language can be set via ?lang=, cookie, config locale, or Accept-Language, plus a top-nav switcher.
lroolle
left a comment
There was a problem hiding this comment.
Thanks for this, and sorry for the slow reply. The catalog is thorough, the tests pass, and the zh-CN pages render cleanly on the current Ledger UI. A few things before we can merge:
- Please drop
translate="no"and<meta name="google" content="notranslate">. They are on every page, English included, so they turn off browser translation for every language we don't ship, and for session transcripts. - Accept-Language.
Normalizeonly knowsen,en-us,en-gbanden-au. Soen-CA,zh;q=0.5picks Chinese, and so doesfr,zh;q=0, because aq=0entry ("not acceptable") can still win. Please treat anyen-*as English and skip entries withq<=0. - One path for the translator. The middleware stores it in the request context, but nothing reads it there;
locFromrunsDetectagain. The package-level English wrapper functions are called only from tests; tests can callloc{}.renderX(...)instead. - One escaper.
html.EscapeStringis enough;uiandhtmlTextcan go. Browsers render'correctly. - Small leftovers. Search-result ages still use the English helper ("5m ago"), and a few catalog keys are unused.
Heads-up: the web templates are being reworked on a separate branch. The internal/i18n package and the config plumbing should carry over as they are; the page wiring may need another pass when that lands.
CI is approved and running.
|
CI result: tests pass; |
# Conflicts: # CHANGELOG.md
- Browser translation stays on: drop translate="no" and the notranslate meta, which disabled it for every language ccx does not ship and for session transcripts. - Accept-Language: any en-* region is English (en-CA,zh;q=0.5 picked Chinese), zh-Hans-* is Simplified, and q=0 entries are skipped. - The search API formats ages in the request's language. - One detection path: locFrom detects, the middleware only persists an explicit ?lang= cookie. Request-context plumbing, i18n.Supported and the test-only English wrappers are removed (golangci-lint: unused). - One escaper, html.EscapeString. Catalog values carrying markup end in _markup; a test keeps every other value free of '<'. - Pages inline only the js.* keys client JS reads. Nine unused keys removed; Keys() is sorted as documented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged, thank you. We pushed the review fixes onto your branch rather than send another round:
Details are in c066999 and the "Review changes" section of your devlog. It ships in the next release. |
Add catalog-backed i18n for web chrome with English as the source locale and a complete zh-CN catalog. Language can be set via ?lang=, cookie, config locale, or Accept-Language, plus a top-nav switcher.