Skip to content

feat(browser): script-subtag locale support (zho-Hant, zh-Hans-SG, fr-CA) - #50

Merged
ronaldtse merged 1 commit into
mainfrom
feat/script-subtag-locales
Jul 22, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
feat/script-subtag-locales

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

normalizeUiLocale now preserves the script subtag instead of truncating composite codes to their first 3 chars. The lift on the documented limitation from PR #46's README note.

Changed

  • src/i18n/ui.ts
    • normalizeUiLocale delegates to a new toCanonical helper: 2-char folding (en → eng), bare 3-char passthrough, composite codes preserved (zh-Hant → zho-hant).
    • t() walks a localeChain(code) — <full> then <base> — so script-bearing locales fall back to the base language before English.
    • meetingTypeLabel() walks the same chain for terminology.meetingTypes overrides.
    • isRtl() walks the chain so ara-Latn still resolves to RTL via ara.

Added

  • src/i18n/script-subtag.spec.ts — 10 tests covering normalization (bare 3-char, 2-char fold, composite codes, case-insensitivity), fallback (built-in base, consumer override, English last resort), per-script terminology override, RTL detection.

README

  • Removed the "Script variants note" callout that flagged this as a known limitation.
  • Replaced with a working description of the fallback chain + how to register script-bearing locales.

Test plan

  • pnpm -F @edoxen/browser typecheck — clean.
  • pnpm -F @edoxen/browser test — 193 passed (was 183; +10 new).
  • pnpm -F @edoxen/browser test:e2e — 51 passed.

Migration notes

No breaking changes for existing consumers. Bare 3-char codes (eng, fra) behave identically. 2-char codes (en, fr) still fold to 3-char. The only behavioral change is that composite codes (zho-Hant) no longer collapse to their base — which was the documented limitation this lifts.

Post-merge

Consumes the changeset; will release as @edoxen/browser@0.11.0 (minor — new public behavior, no API break).

…-CA)

normalizeUiLocale now preserves the script subtag instead of truncating to the first 3 chars. Composite codes resolve to distinct buckets so consumers can register Simplified + Traditional as separate routed locales. t(), meetingTypeLabel(), and isRtl() walk a fallback chain (zho-hant -> zho -> English) so script-specific overrides win, the base-language built-in is the next fallback, then English.

10 new tests in script-subtag.spec.ts cover normalization, fallback, per-script override, RTL detection. No breaking changes — bare 3-char codes and 2-char folding behave identically. README limitation note removed.
@ronaldtse
ronaldtse merged commit 2448c29 into main Jul 22, 2026
2 checks passed
@ronaldtse
ronaldtse deleted the feat/script-subtag-locales branch July 22, 2026 14:57
ronaldtse added a commit that referenced this pull request Jul 22, 2026
Consumes the changeset from PR #50. Bumps @edoxen/browser 0.10.0 -> 0.11.0 (minor: locale normalization now preserves script subtags).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant