Skip to content

Commit 9f692b7

Browse files
committed
test(plugin-email): a Traditional recipient reaches a Traditional template row
The fold pin asserted a zh-MO recipient of a zh-TW + zh-HK + zh-CN bundle got the Simplified row; the table-language step now answers zh-HK. The variant expansion pin moves to a code the table does not know (es-CO). Claude-Session: https://claude.ai/code/session_01L6bhgXFwZkpwurAYNxGpAb Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4c4ae9b commit 9f692b7

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎packages/plugins/plugin-email/src/email-service.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,9 @@ export class EmailService implements IEmailService {
14941494
const wanted = preferred || DEFAULT_TEMPLATE_LOCALE;
14951495
// [#28880] A named locale, over the built-in loader, is folded against the
14961496
// bundle's own tags by the platform's one BCP-47 ladder (exact →
1497-
// case-insensitive → base language → variant expansion, the first match
1498-
// in ascending tag order), then the stack's declared fallback is folded
1497+
// case-insensitive → platform locale table language → base language →
1498+
// variant expansion, the first match in ascending tag order), then the
1499+
// stack's declared fallback is folded
14991500
// the same way, before the `en-US` rung below. Each rung loads the tag it
15001501
// resolved to, exactly. A no-locale call keeps its ladder: en-US, then the
15011502
// loader's own answer.

‎packages/plugins/plugin-email/src/template-locale-fold.test.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
//
33
// [#28880] The template locale ladder for a call that NAMES a locale is the
44
// platform's: the recipient's tag folded against the bundle's locales by
5-
// `resolveBundleLocale` (exact → case-insensitive → base language → variant
6-
// expansion), then the stack's declared fallback folded the same way, then
5+
// `resolveBundleLocale` (exact → case-insensitive → platform locale table
6+
// language → base language → variant expansion), then the stack's declared
7+
// fallback folded the same way, then
78
// `en-US`, then `TEMPLATE_NOT_FOUND`. Measured on `origin/main` (`b15b634c`)
89
// before this file: the service tried the named tag exactly, then `en-US`, so
910
// an `en-GB` or `zh-TW` recipient of an `en` + `zh-CN` bundle dead-lettered.
1011
//
1112
// Variant expansion picks the first base-language match in ascending tag
12-
// order, so the answer does not depend on the order the list carries.
13+
// order, so the answer does not depend on the order the list carries. The
14+
// table-language step runs first: a `zh-MO` recipient reaches a Traditional
15+
// row (`zh-HK`, `zh-TW`) before any Simplified one.
1316
//
1417
// The folding is the built-in registry loader's bundle read; a replacement
1518
// loader that offers no locale list keeps the exact ladder (pinned last).
@@ -78,8 +81,15 @@ describe('[#28880] a named recipient locale is folded against the bundle', () =>
7881
});
7982

8083
it('variant expansion takes the first base-language match in ascending tag order, whatever the list order', async () => {
81-
expect(await sentLocale(['zh-TW', 'zh-HK', 'zh-CN'], 'zh-MO')).toBe('zh-CN');
82-
expect(await sentLocale(['zh-CN', 'zh-HK', 'zh-TW'], 'zh-MO')).toBe('zh-CN');
84+
expect(await sentLocale(['es-MX', 'es-AR', 'en-US'], 'es-CO')).toBe('es-AR');
85+
expect(await sentLocale(['en-US', 'es-AR', 'es-MX'], 'es-CO')).toBe('es-AR');
86+
});
87+
88+
it('a Traditional recipient reaches a Traditional row before a Simplified one, whatever the list order', async () => {
89+
expect(await sentLocale(['zh-TW', 'zh-HK', 'zh-CN'], 'zh-MO')).toBe('zh-HK');
90+
expect(await sentLocale(['zh-CN', 'zh-HK', 'zh-TW'], 'zh-MO')).toBe('zh-HK');
91+
expect(await sentLocale(['en-US', 'zh-CN', 'zh-Hant'], 'zh-TW')).toBe('zh-Hant');
92+
expect(await sentLocale(['en-US', 'zh-CN', 'zh-Hant'], 'zh')).toBe('zh-CN');
8393
});
8494

8595
it('an exact hit wins over every fold', async () => {

0 commit comments

Comments
 (0)