feat(browser): script-subtag locale support (zho-Hant, zh-Hans-SG, fr-CA) - #50
Merged
Merged
Conversation
…-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
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).
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
normalizeUiLocalenow 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.tsnormalizeUiLocaledelegates to a newtoCanonicalhelper: 2-char folding (en→eng), bare 3-char passthrough, composite codes preserved (zh-Hant→zho-hant).t()walks alocaleChain(code)—<full>then<base>— so script-bearing locales fall back to the base language before English.meetingTypeLabel()walks the same chain forterminology.meetingTypesoverrides.isRtl()walks the chain soara-Latnstill resolves to RTL viaara.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
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).