Skip to content

[Feature] i18n: add Simplified Chinese (zh-CN) as an eleventh end-to-end locale #1528

Backlog

Description

@Remedy233

What this asks for

Chinese (Simplified, zh-CN) as a first-class interface locale, held to the standard you applied when Korean landed in #839 — not a message catalog dropped in, but the whole chain: bundle, text folding, LOINC lab names, typography guards, PDF font, OCR, questionnaire wording, and AI prompt skeletons.

I read #839 / #849 (Korean), #1246 (Dutch) and #1251 (pt-BR) before writing this, so the scope below is written to the review you actually give, not to "add a JSON file".

Current state (v1.49.0, main @ 2026-11-25)

  • project.inlang/settings.json ships ["en","de","fr","es","it","pl","ko","nl","pt-BR","ru"] — no zh* of any kind.
  • src/lib/i18n/config.ts matches. localeFromLanguageTag("zh-CN") falls through to English because no shipped locale carries the zh primary subtag, so a Chinese browser gets English with no indication a translation is even planned.
  • messages/en.json is 12,762 leaf keys across 79 top-level groups.
  • Searching the tracker for chinese, zh-CN, 中文 and localization turns up no open request on this topic.

Korean, Dutch and Brazilian Portuguese all arrived through the same door. Chinese is the largest language community that has not.

Why this is more than messages/zh-CN.json

Six places assume a Latin-or-Hangul locale. Each has a Chinese-specific answer and each is a separate decision — which is why this is an issue rather than a surprise 40-file PR.

1. The doctor-report PDF has no CJK ideographs.
src/lib/doctor-report-pdf/fonts.ts embeds ReportSans-{Regular,Bold,Italic} (Latin/Greek/Cyrillic + math) and, since Korean, ReportSansKR-{Regular,Bold} (2.7 MB, merged from Noto Sans KR by scripts/build-pdf-fonts.py), loaded only when reportNeedsHangul() sees a Hangul codepoint. jsPDF has no per-glyph fallback, so a Chinese report today draws .notdef boxes for every 汉字.

Chinese needs the same treatment: a ReportSansSC-* from Noto Sans SC, and a Han-range detector beside HANGUL_RE rather than locale === "zh-CN" alone — a German user's medication name can be Chinese exactly as a German user's note can be Korean. The one open question is subset floor: GB2312's 6,763 Han characters is the pragmatic minimum, GB18030 the honest maximum. Your script already subsets and jsPDF subsets again per document, so the real cost is a fatter image, not a fatter PDF. Your call.

2. fold-for-match.ts needs a full-width fold.
The NFC-recompose note in that file exists because NFD splits Hangul into jamo. Chinese has the mirror problem: a Chinese lab report prints 3.5-5.0 in full-width forms (U+FF10–FF19, U+FF0E, U+FF0D), which will not match the ASCII 3.5-5.0 in a bundle. Also needed: 、 as a list separator where English uses , , and ():; recognized on the same footing as their ASCII forms. Simplified↔Traditional folding I would deliberately leave OUT of the fold — the file's own reasoning (ß is not ss) applies; 折 and 摺 are not the same word.

3. Lab names must still reach LOINC.
src/lib/fhir/__tests__/lab-loinc-locales.test.ts and lab-qualitative-locales.test.ts pin analyte-name → LOINC per locale. LOINC publishes an official Simplified Chinese translation, so the mapping can be built on a real source rather than invented: zh-CN names on the existing keys, not a parallel key set.

4. The typography guards are Latin-centric by construction.
i18n-typography-glyphs, i18n-no-dot-separator and i18n-ellipsis admit en/em-dash forms, · only between letters, and an ellipsis rule built around … vs .... Chinese needs …… (two U+2026), 、 inside enumerations, no space between a numeral and its measure word, and 「」/『』 as a form the guards currently reject. Each is an ALLOWED entry or a bundle-scoped exemption like EM_DASH_BUNDLES; I would rather agree that list with you than discover it inside a large diff.

5. OCR has no Chinese model.
scripts/stage-tesseract-assets.mjs stages the tesseract.js assets. A photographed Chinese lab report needs chi_sim.traineddata (plus chi_tra if Traditional follows). A few MB in the image, gated the way the other per-script assets are — or the local-OCR capability reports "no model for this script" rather than guessing.

6. AI prompts and the safety lexicon.
locale-skeleton-parity.test.ts, coach-prompt-locale.test.ts and locale-bank-liveness.test.ts want a zh-CN prompt skeleton. The part I will not ship untranslated is the safety / red-flag bank: an app that tells a Chinese-reading user to seek care in English has not told them. If native review of that bank is the gate, I would rather ship UI + PDF + labs and leave AI English than ship a half-translated safety bank.

Questionnaire wording — the part #839 shows is the real work

src/lib/mental-health/wording/{phq9,gad7,who5,sci}/{locale}.ts carries one file per language with validated and source, and the Korean review turned on exactly this: PHQ-9 and GAD-7 verbatim from the instrument owners' own sheets, WHO-5 from a redistributable published translation with its validation-sample caveat stated in the definition, SCI back to English when nothing validated may be reproduced.

For Simplified Chinese, my expectation — to be verified against each document's terms before anything is embedded:

  • PHQ-9 / GAD-7 — Simplified Chinese versions are distributed by the instruments' own rights holders; the open question is whether their terms permit verbatim reproduction in software. That is a check I would do and report, not an assumption.
  • WHO-5 — no single WHO-distributed Chinese version; published Mandarin translations exist (mainland and Hong Kong), each needing the same licence and validation scrutiny the Korean thread applied.
  • SCI — following the Korean precedent, English unless a validated Chinese version with reproducible terms turns up.

If the answer on any instrument is "no reproducible validated version", the existing validated: false arm covers it: note beside it, English original one tap away, recorded on the result. That is your decision, and it is the reason this is an issue first.

Proposed scope

Phase 1 — zh-CN, the locale proper. messages/zh-CN.json complete against en.json; locales in config.ts and project.inlang/settings.json; localeLabels endonym 简体中文; ReportSansSC font + Han detector; full-width fold; Intl behaviour for zh-CN (2026年11月25日, 24-hour clock, Monday week start, and Intl.Collator("zh-CN") for the metric-catalog sort so 汉字 names order by pinyin rather than codepoint); typography exemptions; chi_sim OCR asset; AI prompt skeleton; safety bank only with native review.

Phase 2 — zh-TW / zh-Hant, if you want it: same chain, Traditional wording, chi_tra. Deliberately not bundled into phase 1 — one honest locale beats two half-reviewed ones, and localeFromLanguageTag would otherwise route every zh-* tag at one of them arbitrarily.

What I can bring

The mechanical and the hard parts: the full bundle from en.json (machine first draft, then a line-by-line pass), the font build, the fold, the LOINC names, the guard exemptions, and the questionnaire sourcing write-up in the shape your review asks for. What I cannot supply alone is native review of clinical wording — if that is the gate, say so and I will scope phase 1 to UI + PDF + labs and leave the questionnaires English until a reviewer is found.

Not asking for

  • Not a docs translation request. docs.healthlog.dev is a separate surface; happy to treat it as its own issue.
  • Not asking you to maintain it as a project-maintained locale like en/de. Community-reviewed with the maintainership banner is the honest starting state.
  • No change to the default locale.

Happy to split this into a tracking issue plus per-area PRs if that fits the monthly release cadence better than one large PR.

Activity

  1. MBombeck commented on Nov 27, 2026

    @MBombeck
    Owner

    Thank you, @Remedy233. This is about as well prepared as a locale request gets, and you've read the Korean, Dutch and Portuguese threads more closely than most people who worked on them.

    Yes, I'd like zh-CN in, as a community locale with the banner, split the way you suggest. A few decisions so you don't have to guess:

    • PDF font: GB2312 plus CJK punctuation, loaded only when a report contains Han characters, the same way the Korean font works.
    • Full-width fold: yes, as its own small PR first, since it helps every locale that reads a Chinese or Japanese lab sheet. Simplified and Traditional stay apart, as you say.
    • Typography guards: ……, 、 in lists, no space before measure words, 「」 and 『』 as exemptions scoped to the zh-CN bundle. Put the list in the PR description and I'll agree it there.
    • OCR: the fast chi_sim model, staged like the other script assets.
    • Locale matching: only zh-CN, zh-Hans and zh-SG route to the new locale. zh-TW and zh-HK keep English until there is a Traditional locale, so nobody gets the wrong script.
    • Safety wording and questionnaires: they stay English until a native speaker with a clinical background has read them. The validated: false path you describe is the right fallback.

    A new language is a feature, so it ships in a monthly feature release. Please open the PRs against release/v1.50.0, smallest first. If they are in with green checks by Wednesday 2 December, zh-CN ships in 1.50.0 on Saturday 5 December. If that's too tight, nothing is lost: the same PRs move to the January release (1.51.0, 2 January).

    Refs #1528

  2. MBombeck commented on Nov 28, 2026

    @MBombeck
    Owner

    Thank you, @Remedy233. #1664 is merged into release/v1.50.0, so Simplified Chinese ships in 1.50.0 on Saturday, December 5, as a community locale with the banner. Until then you can try it on :nightly.

    You did the hard part: thirteen thousand strings, a safety bank written for how Chinese actually puts a dose sentence together, and the routing that keeps Traditional readers on English. I added the PDF font for Han text, fixed the Wallet pass and the boot catalog that a new language trips over, and brought the bundle level with release. The details are in the PR.

    Still open from the plan above: the typography guard with its list (by Wednesday evening if you'd like it in 1.50.0, otherwise January), the chi_sim OCR pack, and the Wallet pass in Chinese, which needs a change on the signing service's side first. That last one is mine.

    Refs #1528

  3. added
    enhancement
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions