Skip to content

feat(dashboard): add Simplified Chinese (zh) translations#86

Open
whtis wants to merge 1 commit into
rmyndharis:mainfrom
whtis:night-shift/20260519-i18n-zh-cn
Open

feat(dashboard): add Simplified Chinese (zh) translations#86
whtis wants to merge 1 commit into
rmyndharis:mainfrom
whtis:night-shift/20260519-i18n-zh-cn

Conversation

@whtis
Copy link
Copy Markdown

@whtis whtis commented May 18, 2026

Description

Adds a Simplified Chinese (zh) locale to the dashboard, following the i18n pattern introduced by #64. Chinese is now selectable from the sidebar language switcher alongside English and Hebrew.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

What's included

  • dashboard/src/i18n/locales/zh.json — new locale file mirroring the structure of en.json. All 404 leaf keys translated; one new common.chinese label added for the language menu.
  • dashboard/src/i18n/index.tszh registered in supportedLanguages and resources so i18next-browser-languagedetector picks up zh-* browsers automatically.
  • dashboard/src/components/Layout.tsx — replaced the he / EN ternary in languageLabel with a Record<SupportedLanguage, string> lookup. zh displays as 中文. The lookup makes the next locale a single-line addition.
  • dashboard/src/i18n/locales/en.json — added common.chinese: "中文" for parity with the existing common.english / common.hebrew entries.

Why

The Hebrew i18n PR (#64) just added the language switcher and a second locale. This drops in a Simplified Chinese translation so the Chinese-speaking community can use the dashboard without falling back to English, and to validate that the existing i18n module scales to a third language without infrastructure changes (no RTL, no font, no CSS).

How tested

  • npm run build in dashboard/tsc -b clean, vite build succeeds.
  • npm run lint — 0 errors, 3 pre-existing warnings unrelated to this change.
  • Key parity check: en.json and zh.json have identical key trees apart from the intentional common.chinese addition. Script:
    import json
    en = json.load(open('dashboard/src/i18n/locales/en.json'))
    zh = json.load(open('dashboard/src/i18n/locales/zh.json'))
    # … flatten & diff -> only extra key is common.chinese
  • Chinese strings present in the production bundle (grep "审计日志\|仪表盘" dist/assets/index-*.js).

Notes

  • Backwards compatible. English remains the fallback (fallbackLng: 'en'). Existing users see no change unless their browser is zh-* or they pick 中文 from the switcher.
  • Translation choices:
    • Brand / product names kept in English: OpenWA, WhatsApp, BullMQ, MinIO, PostgreSQL, SQLite, Redis, S3, TypeORM, Webhook (very widely used as-is in zh-CN tech writing — translating to "网络钩子" reads worse than keeping it).
    • Common terms translated: Session → 会话, Dashboard → 仪表盘, API Key → API 密钥, QR Code → 二维码, Audit Logs → 审计日志.
    • Placeholders ({{count}}, {{name}}, {{message}}) and inline HTML (<strong>, <code>, <br/>) preserved exactly.
  • No RTL support needed (Chinese is LTR), so rtlLanguages is unchanged.

Screenshots

N/A — visible change is the sidebar language button cycling to 中文 and dashboard labels rendering in Chinese; reviewers can verify locally via npm run dev and clicking the language toggle.

Related Issues

None.

Drafted with AI assistance; verified by author before publishing.

Add a Simplified Chinese locale to the dashboard, following the i18n
pattern introduced in rmyndharis#64. Chinese is now available alongside English
and Hebrew via the existing sidebar language switcher.

What's included:
- New `src/i18n/locales/zh.json` mirroring the structure of `en.json`,
  covering all pages, components, and toast messages (404 keys + a new
  `common.chinese` label, identical hierarchy to `en.json`)
- `zh` registered in `src/i18n/index.ts` (`supportedLanguages`,
  `resources`) so the language detector picks up `zh-*` browsers
  automatically and the cycle-language button rotates through it
- Language label in `Layout.tsx` switched from a binary `he`/EN ternary
  to a `SupportedLanguage` lookup, so adding more languages later only
  requires extending the map; `zh` shows as `中文`
- `common.chinese` key added to `en.json` for parity with the existing
  `common.english` / `common.hebrew` entries

No code, API, schema, or styling changes outside i18n. RTL list is
unchanged (Chinese is LTR). Existing users see no behavior change
unless their browser is set to `zh-*` or they pick 中文 from the
sidebar.

Verified:
- `npm run build` passes (tsc -b clean, vite build succeeds)
- `npm run lint` reports no new errors (3 pre-existing warnings)
- Key parity check: `en.json` and `zh.json` have identical key sets
  apart from the intentional new `common.chinese`
- Chinese strings present in the production bundle (verified via grep
  on `dist/assets/index-*.js`)
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