Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

feat(i18n): expand locale coverage to 9 languages - #241

Merged
Jocs merged 1 commit into
masterfrom
feat/i18n-9-locales
May 21, 2026
Merged

feat(i18n): expand locale coverage to 9 languages#241
Jocs merged 1 commit into
masterfrom
feat/i18n-9-locales

Conversation

@Jocs

@Jocs Jocs commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Add 6 new locale packs (zh-TW, es, fr, de, ko, pt) and rename zhzhCN to align with BCP 47 ('zh-CN').
  • Fix two ja.ts strings that had leaked Simplified Chinese ('Image src placeholder' and 'Confirm Text').
  • Sync the demo (examples/) and the e2e host (e2e/host/) language switchers to surface all 9 locales; refactor the e2e host's if/else dispatch into a map. Update README + e2e specs.

Breaking change

import { zh } from '@muyajs/core' no longer resolves — use import { zhCN } from '@muyajs/core'. muya.i18n.lang reports 'zh-CN' (not 'zh') after muya.locale(zhCN). The full bundled set is now en, zhCN, zhTW, ja, ko, es, fr, de, pt (plus a newly re-exported ILocale type for consumers registering custom locales).

Translation policy

  • Brand/product names kept verbatim (Mermaid, Plantuml, Vega Chart, HTML Block).
  • Front Matter left in English where no settled native term exists.
  • zh-TW derived from zh-CN with Taiwan-idiom adjustments (e.g. 行內程式碼 over straight S→T 行內代碼, 區塊 over ).
  • I18n.t still falls back to English then to raw key, so partial locales are safe; all 73 keys are present in every shipped locale.

Test plan

  • pnpm lint — 0 errors (25 pre-existing warnings)
  • pnpm lint:types (turbo) — passes
  • pnpm test — 386 tests across 43 files pass
  • pnpm check-circular — no circular deps
  • pnpm --filter @muyajs/core build — emits lib/types/locales/{en,ja,zh-CN,zh-TW,es,fr,de,ko,pt}.d.ts
  • CI e2e (.github/workflows/ci-e2e.yml) — locale-switch + public-api specs updated from 'zh''zh-CN'; the pinyin literal in e2e/tests/typing/ime.spec.ts:284 is intentionally untouched (IME input string, not a locale code)
  • Manual: pnpm dev, cycle the <select> through all 9 languages, verify slash menu / format toolbar / image edit placeholder / emoji category labels render in the chosen language

Notes

  • Filenames use the BCP 47 tag literally (zh-CN.ts, zh-TW.ts); the JS identifiers are camelCase (zhCN, zhTW) since export const zh-CN is invalid.
  • The LOCALES maps in examples/src/main.ts and e2e/host/main.ts are keyed by BCP 47 string and must stay in sync with the <option value> strings in their respective index.html — a comment marks this invariant.
  • The pre-existing zh translation 'Symbols': '抽象' was preserved verbatim in zh-CN.ts even though '符号' would be a more accurate rendering of the emoji category; flagging for potential follow-up.

🤖 Generated with Claude Code

Add zh-TW, es, fr, de, ko, pt locale packs and rename the existing zh
export to zhCN (BCP 47 form) alongside a new zhTW (Traditional Chinese).
Fix two ja.ts entries that had leaked Simplified Chinese strings. Sync
the examples demo and e2e host language switchers, refactor the e2e
host dispatch to a map, and update e2e specs + README.

BREAKING CHANGE: the bundled `zh` export is renamed to `zhCN`, and
`muya.i18n.lang` now reports 'zh-CN' instead of 'zh' after
`muya.locale(zhCN)`. Consumers using `import { zh } from '@muyajs/core'`
must update to `import { zhCN } from '@muyajs/core'`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 05:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR expands Muya’s built-in i18n support from 3 to 9 bundled locales, aligning Simplified Chinese with BCP 47 (zh-CN) via a zhzhCN rename, and wiring the demo/e2e host language switchers and e2e assertions to the new locale identifiers.

Changes:

  • Added 6 new locale packs (zh-TW, es, fr, de, ko, pt) and renamed the Simplified Chinese export from zh to zhCN (with name: 'zh-CN').
  • Updated README and public exports (including re-exporting ILocale) to reflect the new locale surface area.
  • Synced demo + e2e host language selectors and updated e2e specs to assert 'zh-CN' instead of 'zh'.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
README.md Updates documentation/examples to use zhCN and lists all 9 bundled locales.
packages/core/src/locales/zh-TW.ts Adds Traditional Chinese (zh-TW) locale resource bundle.
packages/core/src/locales/zh-CN.ts Renames export to zhCN and updates locale name to zh-CN.
packages/core/src/locales/pt.ts Adds Portuguese locale resource bundle.
packages/core/src/locales/ko.ts Adds Korean locale resource bundle.
packages/core/src/locales/ja.ts Fixes two Japanese strings that were incorrectly in Simplified Chinese.
packages/core/src/locales/index.ts Re-exports the expanded locale set, including zhCN/zhTW.
packages/core/src/locales/fr.ts Adds French locale resource bundle.
packages/core/src/locales/es.ts Adds Spanish locale resource bundle.
packages/core/src/locales/de.ts Adds German locale resource bundle.
packages/core/src/index.ts Re-exports ILocale type and the expanded locale exports from the package root.
examples/src/main.ts Expands demo LOCALES map to 9 locales and switches default locale key to en.
examples/index.html Updates the demo language <select> to include all 9 locales (using BCP 47 tags).
e2e/tests/smoke/public-api.spec.ts Updates locale-switch assertion from 'zh' to 'zh-CN'.
e2e/tests/i18n/locale-switch.spec.ts Updates locale-switch tests/labels to use 'zh-CN'.
e2e/host/main.ts Refactors locale dispatch from if/else to a locale map and includes all 9 locales.
e2e/host/index.html Updates the e2e host language <select> to include all 9 locales.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jocs
Jocs merged commit f7c083b into master May 21, 2026
6 of 8 checks passed
@Jocs
Jocs deleted the feat/i18n-9-locales branch May 21, 2026 11:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants