Skip to content

i18n(zh-TW): Adds Chinese (Traditional) translation#559

Merged
ascorbic merged 20 commits intoemdash-cms:mainfrom
ayfl269:main
Apr 15, 2026
Merged

i18n(zh-TW): Adds Chinese (Traditional) translation#559
ascorbic merged 20 commits intoemdash-cms:mainfrom
ayfl269:main

Conversation

@ayfl269
Copy link
Copy Markdown
Contributor

@ayfl269 ayfl269 commented Apr 14, 2026

What does this PR do?

Adds Chinese (Traditional) (zh-TW) translation for the admin UI. This includes:

  • Complete message catalog for zh-TW locale
  • Enables zh-TW as a selectable locale in the admin UI
  • Adds locale configuration and test coverage

Closes #

Type of change

  • Bug fix
  • Feature (requires https://github.com/emdash-cms/emdash/discussions/categories/ideas )
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md#internationalization-i18n and pnpm locale:extract has been run (if applicable)
  • I have added a https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md#changesets (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

N/A - Translation add only, no visual changes or functional modifications.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: 00177c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/plugin-embeds Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

Scope check

This 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@559

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@559

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@559

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@559

emdash

npm i https://pkg.pr.new/emdash@559

create-emdash

npm i https://pkg.pr.new/create-emdash@559

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@559

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@559

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@559

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@559

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@559

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@559

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@559

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@559

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@559

commit: 00177c5

Comment on lines -116 to +117
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");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed to another language pair so it can test fallback logic. pt-PT/pt-BR would be my suggestion

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-TW to the admin’s canonical locale list and enables it in the UI.
  • Updates resolveLocale() tests to expect exact Accept-Language: zh-TW matching.
  • Introduces a full zh-TW Lingui 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.

Comment thread packages/admin/tests/lib/locales.test.ts
ayfl269 and others added 6 commits April 15, 2026 00:18
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.
Comment thread packages/admin/src/locales/config.ts Outdated
Comment on lines +59 to +64
// 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");
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.
Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks

@ascorbic ascorbic merged commit a2d5afb into emdash-cms:main Apr 15, 2026
26 checks passed
@emdashbot emdashbot bot mentioned this pull request Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants