Skip to content

Commit 1272faa

Browse files
committed
fix(spec,core): resolve locales through the platform table's read aliases
Claude-Session: https://claude.ai/code/session_01L6bhgXFwZkpwurAYNxGpAb Co-authored-by: Claude <noreply@anthropic.com>
1 parent b25cdd9 commit 1272faa

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/core': minor
4+
---
5+
6+
fix(spec,core): the server locale resolvers read the platform locale table, so a `zh-TW` / `zh-HK` / `zh-MO` reader gets a registered `zh-Hant` bundle instead of Simplified Chinese
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: semantic
10+
11+
`resolveBundleLocale` (`@objectstack/spec/system`) and `resolveLocale` (`@objectstack/core`) now run one ladder, the new `resolveLocaleAmong(requested, available)` export of `@objectstack/spec/system`: exact, case-insensitive, then **the same platform locale table language**, then base language, then the first registered variant. The new step maps the requested code and each available key through `platformLocaleTagOf` (the table's read aliases) and picks the key spelled as the table tag, else the first key the table maps to that tag.
12+
13+
What changes for a reader: a request for `zh-TW`, `zh-HK` or `zh-MO` reaches a registered `zh-Hant` key, and `zh`, `zh-CN`, `zh-SG` or `zh-Hans` reaches `zh-CN` (or `zh-Hans`), whatever order the bundle registered them in. Before, the first registered `zh-*` key answered both, so a Traditional reader got the Simplified bundle (and with `zh-Hant` registered first, a Simplified reader got the Traditional one). A bare `zh` key now counts as Simplified for a `zh-TW` request, which the base-language step used to hand it. The step also applies to `ja` → `ja-JP`, `es` → `es-ES`, `en` → `en-US` and `pt` → `pt-BR`, which answer as before against today's alias-spelled bundles.
14+
15+
Unchanged: a code the table does not know (`es-MX`, `en-GB`, `pt-PT`) falls back through base language and variant expansion exactly as before, and a `zh-TW` request still reaches `zh-CN` when no Traditional key is registered. No call that matched before stops matching. Every caller of either function moves with it, among them the i18n REST door, built-in validation and operation messages, email template locale folding, hook, flow and approval copy, and plugin-auth's refusal copy.

‎content/docs/automation/email-templates.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ one `EmailServicePlugin` wires), walks:
257257
1. **this locale, folded** against the locale tags the template's bundle carries
258258
by `resolveBundleLocale` (`@objectstack/spec/system`, the BCP-47 fold
259259
plugin-email imports rather than copying): exact, then case-insensitive
260-
(`zh-cn` → `zh-CN`), then base language (`en-GB` → `en`), then variant
261-
expansion (`zh` and `zh-TW` → `zh-CN`), the first match in ascending tag
260+
(`zh-cn` → `zh-CN`), then the same platform locale table language (`zh-TW`
261+
→ a `zh-Hant` row, `zh` → a `zh-CN` row, in any tag order), then base
262+
language (`en-GB` → `en`), then variant expansion (`zh-TW` → `zh-CN` when
263+
the bundle has no Traditional row), the first match in ascending tag
262264
order;
263265
2. **the stack's declared fallback locale**, as
264266
`II18nService.getFallbackLocale()` answers it (`i18n.fallbackLocale`, else

‎packages/spec/src/contracts/email-service.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ export interface SendTemplateInput {
192192
* 1. this locale, folded against the locale tags the template's bundle
193193
* carries by `resolveBundleLocale` (`@objectstack/spec/system`, the
194194
* BCP-47 fold plugin-email imports rather than copying): exact, then
195-
* case-insensitive (`zh-cn` → `zh-CN`), then base language (`en-GB` →
196-
* `en`), then variant expansion (`zh` and `zh-TW` → `zh-CN`), the first
197-
* match in ascending tag order;
195+
* case-insensitive (`zh-cn` → `zh-CN`), then the same platform locale
196+
* table language (`zh-TW` → a `zh-Hant` row, `zh` → a `zh-CN` row, in
197+
* any tag order), then base language (`en-GB` → `en`), then variant
198+
* expansion (`zh-TW` → `zh-CN` when the bundle has no Traditional
199+
* row), the first match in ascending tag order;
198200
* 2. the stack's declared fallback locale, as
199201
* `II18nService.getFallbackLocale()` answers it (`i18n.fallbackLocale`,
200202
* else `defaultLocale`), folded the same way. A host whose i18n service

‎packages/spec/src/stack.zod.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6045,7 +6045,8 @@ const warnedEmailTemplateFloors = new Set<string>();
60456045
* `IEmailService.sendTemplate` reads one row at one tag exactly. For a call
60466046
* that NAMES a locale, over the built-in registry template loader, it folds
60476047
* that locale against the bundle's tags (`resolveBundleLocale`: exact,
6048-
* case-insensitive, base language, variant expansion), then the stack's
6048+
* case-insensitive, platform table language, base language, variant
6049+
* expansion), then the stack's
60496050
* declared fallback locale (`i18n.fallbackLocale`, else `defaultLocale`) the
60506051
* same way, then the literal `en-US` (#28880); a replacement `TemplateLoader`
60516052
* matches the named tag exactly and retries only `en-US`. So a bundle with no

0 commit comments

Comments
 (0)