i18n(zh-TW): Adds Chinese (Traditional) translation#559
i18n(zh-TW): Adds Chinese (Traditional) translation#559ascorbic merged 20 commits intoemdash-cms:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 00177c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Scope checkThis PR changes 5,525 lines across 4 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
| test("falls back to base language (zh-TW -> zh-CN)", () => { | ||
| expect(resolveLocale(makeRequest({ "accept-language": "zh-TW" }))).toBe("zh-CN"); | ||
| test("matches exact accept-language tag with region (zh-TW)", () => { | ||
| expect(resolveLocale(makeRequest({ "accept-language": "zh-TW" }))).toBe("zh-TW"); |
There was a problem hiding this comment.
This needs to be changed to another language pair so it can test fallback logic. pt-PT/pt-BR would be my suggestion
There was a problem hiding this comment.
Pull request overview
Adds a new Traditional Chinese (zh-TW) locale to the admin UI i18n system, updating locale resolution behavior/tests and introducing a full PO catalog so the locale can be selected at runtime.
Changes:
- Adds
zh-TWto the admin’s canonical locale list and enables it in the UI. - Updates
resolveLocale()tests to expect exactAccept-Language: zh-TWmatching. - Introduces a full
zh-TWLingui PO catalog and a changeset for@emdash-cms/admin.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/admin/tests/lib/locales.test.ts | Updates locale negotiation test coverage for zh-TW Accept-Language matching. |
| packages/admin/src/locales/zh-TW/messages.po | Adds the Traditional Chinese translation catalog. |
| packages/admin/src/locales/locales.ts | Adds zh-TW as an enabled locale definition. |
| .changeset/i18n-zh-tw-translation.md | Publishes the change as a patch release for @emdash-cms/admin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added support for matching Chinese script codes (zh-Hant, zh-Hans), enabling mapping zh-Hant to zh-TW and zh-Hans to zh-CN.
Removed tests for various Chinese locale matching scenarios.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add SCRIPT_LANGUAGE_MAP and populate script-to-locale mappings (e.g. zh-Hant -> zh-TW, zh-Hans -> zh-CN) while building supported locales. Extend matchLocale to check exact matches, then try script-based matching using Intl.Locale.script, and finally fall back to the base-language map. Keeps existing canonicalization via Intl.Locale and base-language fallback behavior.
| // Build script mapping for Chinese locales | ||
| if (l.code === "zh-TW") { | ||
| SCRIPT_LANGUAGE_MAP.set("zh-hant", "zh-TW"); | ||
| } else if (l.code === "zh-CN") { | ||
| SCRIPT_LANGUAGE_MAP.set("zh-hans", "zh-CN"); | ||
| } |
There was a problem hiding this comment.
| // Build script mapping for Chinese locales | |
| if (l.code === "zh-TW") { | |
| SCRIPT_LANGUAGE_MAP.set("zh-hant", "zh-TW"); | |
| } else if (l.code === "zh-CN") { | |
| SCRIPT_LANGUAGE_MAP.set("zh-hans", "zh-CN"); | |
| } | |
| const maximized = new Intl.Locale(l.code).maximize(); | |
| if (maximized.script) { | |
| const scriptKey = `${maximized.language}-${maximized.script}`.toLowerCase(); | |
| if (!SCRIPT_LANGUAGE_MAP.has(scriptKey)) { | |
| SCRIPT_LANGUAGE_MAP.set(scriptKey, l.code); | |
| } | |
| } |
Rather than hard-coding, you can use maximize()
Refactor Chinese locale mapping to use Intl.Locale for script handling.
What does this PR do?
Adds Chinese (Traditional) (zh-TW) translation for the admin UI. This includes:
Closes #
Type of change
https://github.com/emdash-cms/emdash/discussions/categories/ideas)Checklist
https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.mdpnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runhttps://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md#internationalization-i18nandpnpm locale:extracthas been run (if applicable)https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md#changesets(if this PR changes a published package)https://github.com/emdash-cms/emdash/discussions/...AI-generated code disclosure
Screenshots / test output
N/A - Translation add only, no visual changes or functional modifications.