|
2 | 2 | // |
3 | 3 | // [#28880] The template locale ladder for a call that NAMES a locale is the |
4 | 4 | // 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 |
7 | 8 | // `en-US`, then `TEMPLATE_NOT_FOUND`. Measured on `origin/main` (`b15b634c`) |
8 | 9 | // before this file: the service tried the named tag exactly, then `en-US`, so |
9 | 10 | // an `en-GB` or `zh-TW` recipient of an `en` + `zh-CN` bundle dead-lettered. |
10 | 11 | // |
11 | 12 | // 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. |
13 | 16 | // |
14 | 17 | // The folding is the built-in registry loader's bundle read; a replacement |
15 | 18 | // 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', () => |
78 | 81 | }); |
79 | 82 |
|
80 | 83 | 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'); |
83 | 93 | }); |
84 | 94 |
|
85 | 95 | it('an exact hit wins over every fold', async () => { |
|
0 commit comments