Skip to content

feat(web): add Simplified Chinese (zh-CN) UI locale - #41

Merged
lroolle merged 3 commits into
thevibeworks:mainfrom
vmuu:feat/web-zh-cn-locale
Oct 17, 2026
Merged

lroolle merged 3 commits into
thevibeworks:mainfrom
vmuu:feat/web-zh-cn-locale

Conversation

@vmuu

@vmuu vmuu commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

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.

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 lroolle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.
  2. Accept-Language. Normalize only knows en, en-us, en-gb and en-au. So en-CA,zh;q=0.5 picks Chinese, and so does fr,zh;q=0, because a q=0 entry ("not acceptable") can still win. Please treat any en-* as English and skip entries with q<=0.
  3. One path for the translator. The middleware stores it in the request context, but nothing reads it there; locFrom runs Detect again. The package-level English wrapper functions are called only from tests; tests can call loc{}.renderX(...) instead.
  4. One escaper. html.EscapeString is enough; ui and htmlText can go. Browsers render &#39; correctly.
  5. 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.

@lroolle

lroolle commented Oct 17, 2026

Copy link
Copy Markdown
Member

CI result: tests pass; golangci-lint fails on the items in point 3 above. The page-level English wrappers (renderIndexPage, renderProjectPage, renderSearchPage, renderSettingsPage, renderMemoryPage, renderSessionsPage, pageHeader) are flagged unused, and label at internal/web/locale.go:99 is an ineffectual assignment. Fixing point 3 should turn lint green.

lroolle and others added 2 commits October 17, 2026 03:25
- 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>
@lroolle
lroolle merged commit e257baa into thevibeworks:main Oct 17, 2026
2 checks passed
@lroolle

lroolle commented Oct 17, 2026

Copy link
Copy Markdown
Member

Merged, thank you. We pushed the review fixes onto your branch rather than send another round:

  • browser translation stays on (no translate="no" / notranslate)
  • any en-* region is English, zh-Hans-* is Simplified, q=0 entries are skipped
  • search-result ages follow the page language
  • one detection path (locFrom), one escaper (html.EscapeString), test-only wrappers removed
  • catalog values that carry markup end in _markup, with a test guarding the rest
  • pages inline only the js.* keys

Details are in c066999 and the "Review changes" section of your devlog. It ships in the next release.

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.

2 participants