cap icon indicating copy to clipboard operation
cap copied to clipboard

Optional Simplified Chinese (zh-CN) localization for capd dashboard with English fallback

Open ZASENJC opened this issue 3 weeks ago • 0 comments

What problem would this feature solve, if any?

Following up on #336 — I saw that full dashboard i18n isn't planned right now because translating and maintaining every dashboard string across releases adds overhead.

For teams self-hosting capd whose operators primarily read Simplified Chinese, the standalone dashboard (capd/dashboard), login page, and shared stats view are currently English-only.

Describe the solution you'd like

I put together a concrete, zero-dependency implementation scoped strictly to capd/dashboard designed to reduce translation maintenance overhead:

  • English source strings as automatic fallback: UI copy stays readable inline in Svelte components (t("Instance settings")). When en is active—or when a string has no zh-CN entry—missing or changed translations fall back to the English source string.
  • Zero new dependencies: A ~120-line Svelte 5 rune helper (capd/dashboard/src/lib/i18n.svelte.js) + a flat zh-CN dictionary (capd/dashboard/src/lib/locales/zh-cn.js), keeping en Intl date/number formatting on undefined so existing browser regional formats are unchanged.
  • Explicit opt-in & persistence: English remains the default. Users can switch between English and 简体中文 under Instance settings > Appearance > Language (as well as on the login and shared stats pages), persisted in localStorage (cap_locale) and synced across tabs.
  • Technical values preserved: Site keys, user-defined names, filter syntax (country:US, type:redeem), header/env names, API payloads, and widget data-cap-lang behavior remain untouched.

Describe alternatives you've considered

External i18n libraries (such as Lingui or svelte-i18n) add dependencies, build plugins, or opaque message IDs across .svelte files. Keeping English inline as the fallback key avoids extra tooling and lets new copy work in English without requiring immediate locale updates.

Additional context

I have a ready PR tested against capd and demo-dashboard builds if you're open to reviewing this approach.

ZASENJC avatar Nov 11 '26 17:11 ZASENJC