feat(i18n-ko): core — add ko to UiLocale model - #5011
Draft
heeoneie wants to merge 1 commit into
Draft
Conversation
Add `ko` to UI_LOCALES so the closed locale vocabulary carries Korean: the `isUiLocale`/`isUiLocalePreference` guards accept it, and `resolveSystemUiLocale` recognizes the `ko` prefix through the existing case-insensitive, `_`-normalizing path (`ko`, `ko-KR`, `ko_KR`, `ko_KR.UTF-8`), so an `auto` preference resolves to it without being persisted. `uiLocaleToIntlLocale` stops being identity. Every locale so far was already the tag `Intl` wants; bare `ko` leaves the region open, and the region is what selects Korean date, number, and plural formatting, so it is widened to `ko-KR`. The return type becomes the literal union of the tags actually emitted — `'zh-CN' | 'zh-TW' | 'en' | 'ko-KR'` — rather than `string`, so the set stays visible in the signature. Every call site feeds an `Intl` constructor, `toLocaleString`, or `localeCompare`, all of which take `string`, so narrowing it is safe. The formatter test can no longer assert identity, so it pins the tag table instead and checks each tag is canonical, which keeps a locale added later from reaching `Intl` without a deliberate tag. Refs apache#3975 Generated-by: Claude Code
This was referenced Sep 8, 2026
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.
Do not merge. This is the shared core base for the Korean locale stack, opened as a draft at @me2seeks's request on #3975. It must not land on
mainon its own.Refs #3975. Part of #3974.
Why this cannot merge alone
UiCatalog<T>isRecord<UiLocale, T>, so addingkotoUI_LOCALESmakes every catalog in the repository require akoentry — 126 of them at the time I counted. This branch enables the locale; the catalogs arrive here and in the slice PRs. CI on this branch is expected to be red until every strict catalog is complete. That is the atomic/stacked delivery model working as intended, not a regression.Delivery contract
Per @me2seeks's decision on #3975:
UiCatalog<T>stays strict — no widening to an optional catalog type.What is here now
UI_LOCALESgainsko;isUiLocaleandisUiLocalePreferenceaccept it.resolveSystemUiLocalerecogniseskovia/^ko(?:[-.]|$)/iu, reusing the existing trim and_→-normalisation.uiLocaleToIntlLocalemapsko→ko-KRand returns the literal union'zh-CN' | 'zh-TW' | 'en' | 'ko-KR'rather than widening tostring, so the set of tags we actually emit stays visible in the signature. Adopted from @scs0209's shape in feat(i18n-ko): native surfaces and E2E fixtures #4515 — we reached the same mapping independently.kok-IN → enso that a later simplification of the pattern to/^ko/icannot silently start matching Konkani, and both system-language ordering assertions (['en', 'ko'] → en,['ko', 'en'] → ko).Landing next on this branch
The three core catalogs that block
@maka/corefrom compiling withko, per the delivery decision:redaction.ts(GENERALIZED_ERROR_COPY),relative-time.ts(JUST_NOW) andtool-quiet-preview.ts(STRINGS_BY_LOCALE).Notes
['zh', 'en']in feat(i18n-ko): core — add ko to UiLocale model #3975's body is stale.UI_LOCALESis['zh-CN', 'zh-TW', 'en']onmainsince feat(i18n): add Traditional Chinese locale #3853, andzhsurvives only as a legacy persisted value thatnormalizeUiLocalePreferencefolds intozh-CN.uiLocaleToIntlLocale(locale) === locale.kois the first locale to break that identity, so it is replaced with a pinned tag table plus anew Intl.Locale(tag).baseName === tagcanonicality check.parseLocaleFlag— are not addressed here. @me2seeks asked for them to be assigned before integration; I will open a tracking issue and link it from this PR.@scs0209 @ggbdpq @xiechimon — this is the branch to rebase onto.
Verification
Run on this branch, rebased onto
93a8dd785:npx biome check packages/core/src/ui-locale.ts packages/core/src/__tests__/ui-locale.test.ts— clean.ui-locale.tsand its test were compiled on their own and run undernode --testrather than throughtest:dist.tsc --noEmit -p packages/core/tsconfig.json— 4 errors, all of them the missingkocatalogs inredaction.ts,relative-time.tsandtool-quiet-preview.ts, i.e. exactly the three files listed under "Landing next on this branch". No other error in@maka/core.npm run typecheck— thekogap accounts for 126 catalog sites across 61 files; the remaining errors cascade from@maka/corefailing to emit.Not run:
npm run buildand the fullnpm test, both blocked by the same catalog gap. They are expected to stay red until the strict catalogs are complete.AI use
Select exactly one:
Tool(s) and scope: Claude Code — drafted the
ui-locale.tschange and the locale tests, and this description. Reviewed, verified and submitted by me; the affected commit carries aGenerated-by: Claude Codetrailer, which must survive the eventual squash.Checklist
Lint, format and the locale suite pass. Typecheck does not, and is not expected to on this branch alone — see Verification and "Why this cannot merge alone".
Does this PR entail a change in behavior?