Skip to content

Translation: Add Simplified Chinese (zh) support - #151

Open
IBeanCN wants to merge 1 commit into
WJDDesigns:mainfrom
IBeanCN:main
Open

IBeanCN wants to merge 1 commit into
WJDDesigns:mainfrom
IBeanCN:main

Conversation

@IBeanCN

@IBeanCN IBeanCN commented Sep 30, 2026

Copy link
Copy Markdown

Translation Contribution

Language: Chinese (Simplified) (zh.json)
Type: New language

Changes Made:

  • Add src/translations/zh.json: a complete Simplified Chinese translation of all 5,088 keys in en.json, keeping the same structure, section order and key order.
  • Add src/translations/zh.meta.json: the per-locale AI-translation sidecar that scripts/translate-locale.js reads and updates on incremental runs.
  • Register the locale in src/localize/localize.ts. Home Assistant reports Simplified Chinese as zh-Hans; the existing resolveLoaderKey() strips the region, so a single zh.json covers zh, zh-Hans and any other zh-* variant.
  • Add zh: 'Simplified Chinese' to LANG_NAMES in scripts/translate-locale.js, so npm run translations:fill -- --all keeps the new locale in sync as keys are added.
  • Add a per_lang.zh entry to src/translations/_glossary.json with Simplified Chinese guidance (concise Home Assistant style labels, never_translate terms preserved).
  • Add README.zh-CN.md with a full Chinese README, link it from the README header, and list Chinese Simplified in the Translations section of both README.md and CONTRIBUTING_TRANSLATIONS.md.

Testing:

  • JSON syntax validated
  • Placeholders preserved
  • Appropriate terminology used

node scripts/validate-translations.js reports no missing and no extra keys for zh (exit code 0).
node scripts/translation-coverage.js reports 100% structural coverage and 99.1% translated strings for the new locale.

Notes:

  • 47 strings intentionally stay in English: product and vendor names (Ultra Card Pro, FreeSpace, Google Maps, OctoPrint, Moonraker, Bambu Lab, Smart Cards, Living Canvas), units and unit-like labels (px, km, h, W, °, 6mo+), and code identifiers such as my_variable_name and entity_id.
  • Terminology follows the Home Assistant zh-Hans glossary: 实体 / 设备 / 区域 / 自动化 / 蓝图 / 场景; 卡片 / 仪表盘 / 模块 / 预设 / 模板.
  • zh, zh-Hans and zh-CN all resolve to this one file, so no regional variant file was added; no runtime change beyond the loader entry was required.
  • Only src/translations/, src/localize/, scripts/ and the two docs were touched. dist/ is left to the maintainer's build.
  • Happy to adjust wording anywhere. If a specific term should follow a different convention, point at the key and I will update zh.json.

Add src/translations/zh.json covering all 5088 keys of en.json, plus the
zh.meta.json AI-translation sidecar used by scripts/translate-locale.js.

Wire the locale into the runtime and tooling:
- src/localize/localize.ts: register the zh loader; Home Assistant reports
  Simplified Chinese as zh-Hans, which resolveLoaderKey already strips down
  to zh.
- scripts/translate-locale.js: add zh so --all keeps it in sync.
- src/translations/_glossary.json: per-language Simplified Chinese guidance.

Documentation:
- README.zh-CN.md: full Chinese README.
- README.md and CONTRIBUTING_TRANSLATIONS.md: list Chinese Simplified and
  note that zh-Hans maps to zh.

Coverage is 100% structural and 99.1% translated; the 47 strings left in
English are product names, units and code identifiers. Placeholders and HTML
tags verified intact by scripts/validate-translations.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