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
Conversation
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>
There was a problem hiding this comment.
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 zh → zhCN 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 fromzhtozhCN(withname: '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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zh-TW,es,fr,de,ko,pt) and renamezh→zhCNto align with BCP 47 ('zh-CN').ja.tsstrings that had leaked Simplified Chinese ('Image src placeholder'and'Confirm Text').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 — useimport { zhCN } from '@muyajs/core'.muya.i18n.langreports'zh-CN'(not'zh') aftermuya.locale(zhCN). The full bundled set is nowen,zhCN,zhTW,ja,ko,es,fr,de,pt(plus a newly re-exportedILocaletype for consumers registering custom locales).Translation policy
Mermaid,Plantuml,Vega Chart,HTML Block).Front Matterleft in English where no settled native term exists.zh-TWderived fromzh-CNwith Taiwan-idiom adjustments (e.g.行內程式碼over straight S→T行內代碼,區塊over块).I18n.tstill 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) — passespnpm test— 386 tests across 43 files passpnpm check-circular— no circular depspnpm --filter @muyajs/core build— emitslib/types/locales/{en,ja,zh-CN,zh-TW,es,fr,de,ko,pt}.d.ts.github/workflows/ci-e2e.yml) — locale-switch + public-api specs updated from'zh'→'zh-CN'; the pinyin literal ine2e/tests/typing/ime.spec.ts:284is intentionally untouched (IME input string, not a locale code)pnpm dev, cycle the<select>through all 9 languages, verify slash menu / format toolbar / image edit placeholder / emoji category labels render in the chosen languageNotes
zh-CN.ts,zh-TW.ts); the JS identifiers are camelCase (zhCN,zhTW) sinceexport const zh-CNis invalid.LOCALESmaps inexamples/src/main.tsande2e/host/main.tsare keyed by BCP 47 string and must stay in sync with the<option value>strings in their respectiveindex.html— a comment marks this invariant.'Symbols': '抽象'was preserved verbatim inzh-CN.tseven though'符号'would be a more accurate rendering of the emoji category; flagging for potential follow-up.🤖 Generated with Claude Code