Repository navigation
fix(app-shell): match sys_user.locale in the server resolveLocale order - #30150
Merged
objectstack-fleet[bot] merged 1 commit intoNov 5, 2026
Merged
Conversation
Exact, then case-insensitive, then base language, then the first offered variant, so a legacy mis-cased row and a bare or script-tagged tag reach the offered locale instead of rendering English. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYpFBMr917PmVkG9up7
This was referenced Nov 4, 2026
Contributor
Author
|
domain:ui#3 · os-justin · session_01QSeKYpFBMr917PmVkG9up7 Progress · 2026-11-04T20:02Z · answering triage's
Generated by Claude Code |
This was referenced Nov 4, 2026
objectstack-fleet
Bot
deleted the
claude/issue-30050-console-locale-match
branch
November 5, 2026 01:05
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.
Refs #30050 (half 2)
Clause-②: no
Metadata-protocol: none
维护者速读
sys_user.locale选界面语言时,改用与服务端resolveLocale相同的匹配顺序(精确 → 忽略大小写 → 基础语言 → 同语言变体)。zh-cn的历史行,或zh/zh-Hans-CN这类标签,在部署只提供zh-CN时匹配不到,中文用户看到的是英文界面。pickRenderableLocale一个纯函数,不碰服务端和数据;回滚即还原这一个提交。匹配不到的语言仍然什么都不切换,与原行为一致。ui/packages/app-shell/src/hooks/useUserLocale.ts的pickRenderableLocale(四步匹配);ui/packages/app-shell/src/hooks/__tests__/userLocale-10059.test.tsx末尾新增的 describe。ui/下跑pnpm exec vitest run packages/app-shell/src/hooks/__tests__/userLocale-10059.test.tsx,预期 18 条全部通过,其中zh-cn、zh、zh-Hans-CN都解析到zh-CN,en-GB解析到en。What changes
pickRenderableLocalepicks the console's UI language for a signed-in user'ssys_user.locale. It now resolves in the same order as the server's i18n routes, which useresolveLocaleinpackages/corefallbacks/memory-i18n.ts:zh-cn→zh-CN). This covers a row written before the server door folded case: such rows are not migrated and are served as stored;en-GB→en;zh-CN→zhwhen azhpack is offered);zh→zh-CN,zh-Hans-CN→zh-CN).A match returns the offered spelling. A tag that shares no language with any offered locale still matches nothing, so the device language keeps deciding, as before.
The matcher stays in app-shell.
@objectstack/coreexportsresolveLocale, but app-shell does not depend on it, and it is a server kernel package. The@object-ui/i18nmatchLanguageTagtakes a predicate, not a list, so it cannot express the variant step. Widening it would also change the seed and catalogue lookups, which this card does not cover.Tests
A new top-level
describein the existing harnessuserLocale-10059.test.tsxpins these cases:I18nProvidermounted withloadLocalesanswering['en', 'zh-CN']and a column ofzhrenderszh-CN.The existing
pickRenderableLocalecases are kept unchanged: exactpt-BR,zh-CN→zh,threfused, and the list still in flight.All runs below are on head
218415004(git rev-parse --short HEAD), from the worktree, after the final commit.app-shell locale suite: 18/18 pass
pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/hooks/__tests__/userLocale-10059.test.tsx(fromui/, under the verify lock)Reverse verification: the origin/main matcher turns 6 of the 8 new pins red
With the fix committed,
useUserLocale.tswas restored from merge base55337f4cein the tree only. On disk that left 0caseMatchlines and 1offerable.includes(base)line. The suite was re-run, then the file was restored withgit checkout HEAD --under a trap. After the restore, the file hash matched the HEAD blobdd0da66eandgit diff HEADwas empty.Two of the new pins are expected to stay green on the old code, because both behaviours already held before: base over variant (
pt-PT→pt) and no match (th-TH,xx-YY, empty list).Type-check: app-shell
pnpm exec turbo run type-check --concurrency=2 --filter=./ui/packages/app-shellrantsc --noEmit && tsc -p tsconfig.test.json. Result:Tasks: 68 successful, 68 total,VERDICT command-exit 0.Acceptance notes
resolveLocale's order rather than importing it, for the dependency reasons given under What changes.@object-ui/i18n's seed and catalogue lookup (matchLanguageTag) still matches exact, then base, with no case fold. The built-in packs are keyed by base language (zh), so a mis-cased seed such aszh-cnstill reacheszhthrough the base step. No wrong answer was reproduced, so this is noted here and not filed.plugin-auth) is not touched. Triage did not file it.Verification
The gate list was derived with
node scripts/pm/dispatch-gates.mjs --commands, which took the change set from the merge base55337f4ce(3 paths). It named 35 families. All 35 ran locally on head218415004and every one exited 0; exit codes were captured before any pipe. The--ranreconciliation reads35 derived, 35 run, 0 NOT-MEASURED, 0 UNRUN.Per-family exit codes
The derivation lists five CI type-check lanes that it cannot place locally. Those are left to CI.
Generated by Claude Code