Repository navigation
fix(app-shell): name the language menu's built-in locales from the platform locale table - #31053
Merged
Merged
Conversation
LocaleSwitcher's localeLabel() read a hand-kept name list keyed by the retired zh and pt pack tags, so zh-Hans, zh-Hant and pt-BR fell through to Intl.DisplayNames. Index PLATFORM_LOCALES by tag instead and pin that every row's label is what localeLabel(tag) returns, with and without Intl.DisplayNames. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzTyA5TRApD5ko4rtq
Contributor
Author
|
domain:ui#2 · os-tesla · session_01L9qibw7DekEe3wx5f3zphf 席位核对 · ACCEPT · 2026-11-06T22:09Z · head
|
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.
Requested by Tesla · project thread
Fixes #31045
domain:ui#2 · os-tesla · session_01L9qibzTyA5TRApD5ko4rtq
Clause-②: no
Metadata-protocol: none
维护者速读
PLATFORM_LOCALES每行的label(如 简体中文、繁體中文、Português (Brasil)),删掉LocaleSwitcher里按旧代码zh/pt手写的第二份名称表。zh-Hans、zh-Hant、pt-BR)之后,手写表对不上这三个标签,它们的名称落到浏览器的Intl.DisplayNames,随浏览器与 ICU 版本变化,缺Intl.DisplayNames的运行时直接显示裸代码zh-Hans。Intl.DisplayNames的运行时。回滚即 revert 本 PR。ui/packages/app-shell/src/layout/LocaleSwitcher.tsx的BUILT_IN_LABEL_BY_TAG与localeLabel;LocaleSwitcher.appLocales.test.tsx末尾新增的 describe。pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/LocaleSwitcher.appLocales.test.tsx,预期 12 个测试全绿;把手写表放回去重跑,预期「without Intl.DisplayNames」一例转红,点名zh-Hans。fe26b46f的 diff 复核:3 个文件、+87 / −39,无受治理路径。语言菜单的内置语言名改由平台语言表PLATFORM_LOCALES的label提供(如 简体中文、繁體中文、Português (Brasil)),删去按旧zh/pt代码手写的名单;表外代码仍走Intl.DisplayNames,菜单提供哪些语言不变。新测试含「没有 Intl.DisplayNames」一档,恢复手写名单即红。CI 全绿,Clause-② no,不欠契约复审。同意落地。What changes
localeLabel()names a platform locale table tag by its row'slabel. The lookup is aMapbuilt fromPLATFORM_LOCALES(tag→label), so a code likeconstructoror__proto__still cannot pick up a label.BUILT_IN_LABELS, the hand list keyed by the old ten codes (zh,ptamong them), is deleted; there is no second list of names.Intl.DisplayNamesstays the fallback for every code that is not a table tag (an app-shippedth, or a barezh/ptan app might still list), with the same capitalization and the same degradation to the bare code.pt-BRan app-shipped locale and say where the built-in names come from.@objectstack/specwas already a dependency of@object-ui/app-shell(useUserLocale.tsimports@objectstack/spec/system), so no manifest or lockfile change..changeset/31045-locale-switcher-table-labels.md:@object-ui/app-shellpatch.The menu's option set is not touched (that is #30514, phase 4). #30514's body carries no separate "drop the dead
zh/ptrows" line; the deadzhandptlabel rows that PR #30902's acceptance notes pointed at ("Its hand-kept names are keyedzhandpt") are removed here, so nothing of that remains for #30514.Tests
LocaleSwitcher.appLocales.test.tsx(the existing harness file, new top-level describe):PLATFORM_LOCALESrow'slabelis whatlocaleLabel(tag)returns;Intl.DisplayNamesremoved from the runtime (and an app code such asthstill degrades to the bare code);constructorand__proto__answer the bare code.The fixtures that modelled an app shipping the retired
zhtag and expected the hand list's中文now shipzh-Hansand expect the table's简体中文. The phantom-label comment no longer sayspt-BRis named byIntl.DisplayNames.Acceptance notes
main@115a43ad: the three tags missed the hand list and were named by the runtime. The visible names did not differ on the two runtimes measured (Node v22.23.4 with ICU 78.3, Chromium 153.0.8010.12): there CLDR happens to give the table's strings after capitalization. They differ whereIntl.DisplayNamesis missing (barezh-Hans,zh-Hant,pt-BR) and on any runtime whose CLDR names them otherwise. Table below.Intl.DisplayNamesleg goes red. That leg is the one that proves the name comes from the table.ui/apps/console/src/pages/system/ProfilePage.tsx'snativeLanguageNamedocblock still mentions app-shell's "hand-keptBUILT_IN_LABELSmap". It is outside this card's file surface and is left alone; the profile page's language card nameszh-Hans,zh-Hantandpt-BRthroughIntl.DisplayNames, the same runtime dependence this PR removes from the menu, becauselocaleLabelis not on the@object-ui/app-shellentry. Noted for the seat; not filed.Verification
Before / after label table (Node v22.23.4, ICU 78.3; base 115a43a, head fe26b46)
labelIntl.DisplayNamesIntl.DisplayNamesOff-table codes, before → after:
zh中文 → 中文,ptPortuguês → Português,thไทย → ไทย (all throughIntl.DisplayNamesafter).Chromium 153.0.8010.12 raw
Intl.DisplayNames([tag]).of(tag): zh-Hans 简体中文, zh-Hant 繁體中文, pt-BR português (Brasil) (capitalized bylocaleLabel).Ablation (head fe26b46)
node scripts/ablation-replace.mjsreplaced thePLATFORM_LOCALES.map(...)initializer with the deleted ten-row hand list (anchor 1 → 0, blob dfc65564 → 7b64fa58) and ran the appLocales file: 1 failed / 11 passed,zh-Hans: expected 'zh-Hans' to be '简体中文'in "names every table tag with its row label on a runtime without Intl.DisplayNames". Restored: blob == HEAD,git diff HEADempty. The test imports the component by relative source path, so no build leg applies.Suites, type-check and gates (head fe26b46)
pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/layout/ packages/app-shell/src/hooks/__tests__/userLocale-10059.test.tsx: 141 files, 938 tests passed.pnpm --filter @object-ui/app-shell run type-check: exit 0.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 36 derived families, all exit 0, includingnode scripts/check-sdui-manifest.mjs,pnpm check:undeclared-dep-imports,pnpm check:test-source-aliasandpnpm --dir ui exec vitest run scripts/(170 files passed, 2 skipped).--ran: 36 derived, 36 run, 0 NOT-MEASURED, 0 UNRUN.