You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1089e9e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(console): a user with no personal language gets their browser's language when the app ships it, else the app default (#34399)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X5Dqh7NEiHRd1ETkL7pny2w)_Fixes#33985
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:没有设置个人语言的用户打开 Console
时,浏览器语言在应用的支持列表里就用浏览器语言;不在列表里才用应用默认语言。个人语言(`sys_user.locale`)和在本设备上手动选的语言仍然优先。
- 为什么改:18.5.0
把应用默认语言放在浏览器语言之前,而应用总有默认语言,结果中文浏览器在「默认英文、也支持中文」的应用里一律看到英文(hotclm、duly、hotcrm
三家实测)。你裁定 B「浏览器语言受支持就优先」。
- 风险与回滚:只改 Console 前端两处语言请求头的取值,不改服务端和协议;回滚即 revert 本
PR。设备上已缓存的语言种子会在下次启动时被刷新为新答案。
- 先看:`ui/apps/console/src/languageSeed.ts` 的
`pickPreferredLocale`(匹配规则:走服务端同一条 `resolveLocaleAmong`
阶梯,精确、大小写不敏感、平台别名 `ja`→`ja-JP`、基础语言 `en-US`→`en`、变体
`es-MX`→`es-ES`、`zh`→`zh-CN`);`LocalizationFetchProvider.tsx` 的取值改名处。
- 两分钟验证:`cd ui && pnpm exec vitest run
apps/console/src/languageSeed.test.ts` 应全绿,其中「zh-CN 浏览器 + 支持 en/zh-CN +
默认 en → zh-CN」与「fr 浏览器 → en」两条即裁决的钉子。
- 需要你做的:无,席位落地。
## What changes
For a signed-in user with no personal language, the Console's language
is now the user's own `sys_user.locale`, else the browser's language
when the app lists it in discovery `locale.supported`, else the app's
declared default (discovery `locale.default`), else `en`. This carries
out ruling 6915665005 on #33985 (letter B, maintainer 「B 浏览器语言受支持就优先」),
unchanged.
- `ui/apps/console/src/languageSeed.ts`: `loadAppDefaultLocale` becomes
`loadPreferredLocale`, which reads discovery `locale.default` and
`locale.supported` through the console's one shared discovery request
and states `pickPreferredLocale(navigator.language, supported, default)`
as the `Accept-Language` of the boot's `/api/v1/auth/me/localization`
read. `startedAppDefaultLocale` and the test seam are renamed to match.
The module docblock's #33231 section is rewritten to the ruling.
- `pickPreferredLocale` (new, exported for the tests): the browser's top
tag (`navigator.language`) is matched against `locale.supported` through
`resolveLocaleAmong` (`@objectstack/spec/system`), the server's own
`Accept-Language` ladder: exact, case-insensitive, platform table
aliases (`ja` → `ja-JP`, `zh-TW` → `zh-Hant`), base language (`en-US` →
`en`), variant (`es-MX` → `es-ES`, `zh` → `zh-CN`); no match ⇒ the app
default. The answer is the app's own spelling of the entry.
- `ui/apps/console/src/LocalizationFetchProvider.tsx`: the every-boot
read states the same value (`startedPreferredLocale`), so the seed read
and this read still share one request on a first visit. Unchanged: an
explicit device choice is stated as before; with discovery answering
nothing, the browser's own header goes out.
- No server, spec or protocol change; `locale.supported` was already
served.
The ruling's finding 3 (the organization's Localization setting never
reaches the Console's language, because the Console always states a
language and the server's deployment-default rung never answers) is not
in this PR, per the ruling. Confirmed from the code (discovery
`locale.default` is the i18n service's `getDefaultLocale()`, the app's
`i18n.defaultLocale`) and filed as #34392.
## Tests
- `languageSeed.test.ts`: the #33231 block is rewritten per the ruling's
"After the ruling". Rendered boot pins (seed → `preloadBootstrapLocale`
→ `I18nProvider` probe of `common.cancel` and `<html lang>`): a `zh-CN`
browser with `supported: ['en','zh-CN']` and default `en` gets `zh-CN`;
CONTROL, an `fr` browser on the same app gets `en`; the #33231 pin,
rewritten to the case it still owns: an `en-US` browser on a
`zh-CN`-only app gets `zh-CN`; an `en-US` browser on a `zh-CN` app that
also ships `en` gets `en` (the ruling's stated cost of B); a personal
locale still outranks both; with no locale block served the browser's
own header goes. Plus unit pins of `pickPreferredLocale`.
- `LocalizationFetchProvider.test.tsx`: the read states a supported
browser language (`zh-CN` on an `en`-default app), and states the app
default for an unsupported one (`fr` on a `zh-CN` app).
- `__tests__/localizationBootDedup.test.tsx`: the one-request pin now
runs on the browser-language path (both reads state `zh-CN`, one
localization request).
<details><summary>Test run and ablation at
<code>b8ce00c8</code></summary>
- `cd ui && pnpm exec vitest run apps/console/src/languageSeed.test.ts
apps/console/src/LocalizationFetchProvider.test.tsx
apps/console/src/__tests__/localizationBootDedup.test.tsx` (under
`os-verify-lock.sh`, after the `@object-ui/console^...` closure build):
`Test Files 3 passed (3)`, `Tests 47 passed (47)`, `VERDICT command-exit
0`.
- Ablation (one, through `scripts/ablation-replace.mjs`, fix committed
first): `languageSeed.ts` anchor `const tag = typeof browserTag ===
'string' ? browserTag.trim().toLowerCase() : '';` replaced by `const tag
= '';` (anchor x1 -> x0, blob `210683d22911` -> `25f7a6f1e9b3`), which
is the 18.5.0 behaviour (app default always). Same three files: `Tests 6
failed | 41 passed (47)`; red: the zh-CN browser pin, the en-US-to-en
pin, both `pickPreferredLocale` match pins, the provider's
supported-browser pin, the one-request pin. The CONTROL (`fr` → `en`)
and the unsupported-language pins stayed green, as they should.
Restored: blob == HEAD (`210683d22911`), `git diff HEAD` empty.
</details>
## Acceptance notes
- Matching rule: the ruling says "the browser's language when the app
lists it". This PR reads it as follows: the browser's top tag
(`navigator.language`) is matched against `locale.supported` through
`resolveLocaleAmong` (`@objectstack/spec/system`), the server's own
`Accept-Language` ladder: exact, case-insensitive, platform table
aliases (`ja` → `ja-JP`, `zh-TW` → `zh-Hant`), base language (`en-US` →
`en`), variant (`es-MX` → `es-ES`, `zh` → `zh-CN`); no match ⇒ the app
default. Changed in fix round 1 (L1 REWORK 6917299693) from a two-step
matcher, so `ja`, `zh-TW` and `es-MX` browsers get the language the app
ships.
- Out of scope, filed: #34392 (finding 3 of the ruling record).
## Verification
<details><summary>Local gates at <code>b8ce00c8</code> (38 derived +
console type-check, all exit 0)</summary>
- `pnpm --filter @object-ui/console type-check` :: exit 0 (`tsc --noEmit
&& tsc -b tsconfig.node.json --force`, after the closure build; compiles
the test files).
- `node scripts/pm/dispatch-gates.mjs --commands` derived 38 families;
all 38 run, each exit 0; `--ran` reconciliation: `38 derived famil(ies)
accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero — all 38 recorded
an exit code and none of them is 3)`. Families:
check-adr-0087-registration (base + self-test),
check-changeset-no-major, check-closing-keyword-parity (+ self-test),
check-comment-mask-corpus, check-empty-changeset (base + self-test),
check-sdui-manifest (+ self-test), snapshot-next,
check-governed-queue-guard, release-rehearsal-clone,
release-pending-publish self-tests, `pnpm --dir ui exec vitest run
scripts/`, spec check:duration-unit-keys, check:adr-anchors,
check:changeset-gate-self-tests, check:closed-ceremony-text,
check:cross-package-test-inputs, check:dispatcher-error-vocabulary,
check:driver-memory-census, check:engine-double-contract,
check:error-status-conformance, check:gitlink-declared, check:nul-bytes,
check:published-files, check:query-options-erasure,
check:refd-timer-probe, check:registry-log-declared,
check:rest-log-spy-declared, check:test-source-alias,
check:tier-file-adoption, check:type-check-coverage,
check:type-check-debt, check:undeclared-dep-imports,
check:watch-hint-literal, check:where-matcher.
- Not run locally (CI-owned): the whole console vitest project, `pnpm
lint`, `test:repo`, and the families outside the derivation. Full
dogfood not owed (no `!` in the title, no `(narrowing)` arm).
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (CI-owned run).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English (the maintainer brief
excepted).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5mV676uKv5vXZ12fc8
<!-- signed: repo:objectstack#1 · os-project-manager ·
session_01FEkQ5pmEYLVFDcQ1Z1CS8H -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(console): a user with no personal language gets their browser's language when the app ships it, and the app's default language otherwise
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
Since 18.5.0 the Console stated the app's declared default (discovery `locale.default`) as the `Accept-Language` of its language reads whenever the device held no explicit choice. Discovery always serves a default, so the browser's language was never asked: a zh-CN browser on an app with `i18n: { defaultLocale: 'en', supportedLocales: ['en', 'zh-CN'] }` booted an English Console, where 18.3.0 booted Chinese.
11
+
12
+
For a signed-in user with no `sys_user.locale`, the Console's language is now the browser's language when the app lists it in discovery `locale.supported`, else the app's declared default, else `en` (maintainer ruling, letter B). The browser's language is its top tag (`navigator.language`), and "the app lists it" is answered by the platform's one locale ladder (`resolveLocaleAmong`), the same matcher the server's `Accept-Language` rung uses: `ja` matches `ja-JP`, `zh-TW` matches `zh-Hant`, `en-US` matches `en`, `es-MX` matches `es-ES`. The Console states the app's own spelling of that entry. A browser language the app does not ship still gets the app's default, as in 18.5.0. A stored `sys_user.locale` or a language picked on the device still wins over both. No server or protocol change.
0 commit comments