Skip to content

Commit 5e21830

Browse files
committed
docs(spec): the email template and validation ladders name the platform table step
Claude-Session: https://claude.ai/code/session_01L6bhgXFwZkpwurAYNxGpAb Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9f692b7 commit 5e21830

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎packages/spec/src/system/email-template.zod.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ import { strictObject } from '../shared/strict-object';
3535
*
3636
* Named because those two roles are the same fact and authors keep reading it
3737
* as neither. Over the built-in registry template loader the resolver folds a
38-
* named locale against the bundle's own tags (exact, case-insensitive, base
39-
* language, variant expansion) and then tries the stack's declared fallback
38+
* named locale against the bundle's own tags (exact, case-insensitive,
39+
* platform locale table language, base language, variant expansion) and then
40+
* tries the stack's declared fallback
4041
* (`i18n.fallbackLocale`, else `defaultLocale`) folded the same way, so an `en`
4142
* row is reached, absent a row of their own, from `en-GB`, and from any tag on
4243
* a stack whose declared fallback is `en`. This literal is the one rung that
@@ -178,12 +179,14 @@ export const EmailTemplateDefinitionSchema = lazySchema(() => strictObject({
178179
* (`IEmailService.sendTemplate`) reads one row at one tag **exactly**, rung
179180
* by rung; what it folds is the tag it asks for (#28880). For a call that
180181
* NAMES a locale, over the built-in registry template loader, it folds that
181-
* locale against the bundle's own tags (exact, case-insensitive, base
182-
* language, then variant expansion, the first match in ascending tag order),
182+
* locale against the bundle's own tags (exact, case-insensitive, platform
183+
* locale table language, base language, then variant expansion, the first
184+
* match in ascending tag order),
183185
* then folds the stack's declared fallback locale (`i18n.fallbackLocale`,
184186
* else `defaultLocale`) the same way, then tries the literal
185187
* {@link EMAIL_TEMPLATE_FLOOR_LOCALE}. So, absent a row of their own, `en-GB`
186-
* and `en-US` reach an `en` row and `zh-TW` reaches `zh-CN`, while `fr`
188+
* and `en-US` reach an `en` row and `zh-TW` reaches `zh-Hant` (else
189+
* `zh-CN`), while `fr`
187190
* reaches an `en` row only through the declared fallback.
188191
*
189192
* ⚠️ `en-US` is still the bundle's FLOOR: the one rung that holds whatever
@@ -221,8 +224,9 @@ export const EmailTemplateDefinitionSchema = lazySchema(() => strictObject({
221224
'BCP-47 locale (e.g. en-US, zh-CN) — the bundle key. Each rung of the resolver reads one row at '
222225
+ 'one tag exactly, so `en` and `en-US` are different ROWS of one bundle. A call that NAMES a '
223226
+ "locale, over the built-in template loader, folds it against the bundle's tags (exact, "
224-
+ 'case-insensitive, base language, then variant expansion: `en-GB` reaches `en`, `zh-TW` '
225-
+ "reaches `zh-CN`), then folds the stack's declared fallback locale (`i18n.fallbackLocale`, "
227+
+ 'case-insensitive, platform locale table language, base language, then variant expansion: '
228+
+ '`en-GB` reaches `en`, `zh-TW` reaches `zh-Hant`, else `zh-CN`), then folds the stack\'s '
229+
+ "declared fallback locale (`i18n.fallbackLocale`, "
226230
+ 'else `defaultLocale`) the same way, then tries the literal `en-US`; a replacement template '
227231
+ 'loader matches the tag exactly and retries only `en-US`. `en-US` is the floor every loader '
228232
+ 'honours: when no rung lands on a row the call raises TEMPLATE_NOT_FOUND, which is permanent — '

‎packages/spec/src/system/i18n-resolver.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4472,9 +4472,10 @@ export const BUILTIN_SYSTEM_FIELD_LABEL_LOCALES: readonly string[] = Object.free
44724472

44734473
/**
44744474
* Fallback label for a platform-injected system field, honouring the same
4475-
* locale-matching rules as bundle lookup (exact → case-insensitive → base
4476-
* language → variant). Applied only when the field still carries its injected
4477-
* English default — an author's custom label is never overridden.
4475+
* locale-matching rules as bundle lookup (exact → case-insensitive → platform
4476+
* table language → base language → variant). Applied only when the field
4477+
* still carries its injected English default — an author's custom label is
4478+
* never overridden.
44784479
*/
44794480
function builtinSystemFieldLabel(
44804481
fieldName: string,

‎packages/spec/src/system/validation-message.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ export interface RenderValidationMessageOptions {
356356
* 1. `translate('validation.field.<messageKey>', locale)` — a deployment's
357357
* `translation` override. A miss is detected by the II18nService contract
358358
* of echoing the key back.
359-
* 2. the built-in catalog for the locale (BCP-47 matched: exact →
360-
* case-insensitive → base language → variant).
359+
* 2. the built-in catalog for the locale (BCP-47 matched by
360+
* `resolveBundleLocale`: exact → case-insensitive → platform table
361+
* language → base language → variant).
361362
* 3. the built-in catalog for `en`.
362363
* 4. `<label> (<messageKey>)` — only reachable for a messageKey absent from
363364
* even the English catalog, i.e. a coding error; still returns something a

0 commit comments

Comments
 (0)