11/**
22 * The `marketplace` namespace (objectstack#30588): its shape, and how it sits
3- * beside the ten packs it was cut out of.
3+ * beside the packs it was cut out of: one catalogue per platform locale table
4+ * tag (objectstack#30511), keyed by the tag as the packs are.
45 *
5- * 1. LAZY BY CONSTRUCTION. `namespaces/marketplace/index.ts` reaches its ten
6- * catalogues through ten literal `import()`s and nothing else — no static
6+ * 1. LAZY BY CONSTRUCTION. `namespaces/marketplace/index.ts` reaches its
7+ * catalogues through one literal `import()` each and nothing else — no static
78 * import, no template-literal specifier — so each is a chunk of its own
89 * and none is in the console's first load.
910 * 2. CUT, NOT COPIED. Every catalogue holds only the `marketplace` group and
1011 * the probe key the page frame waits on; no pack holds the probe key, and
1112 * no leaf is in both a pack and its catalogue.
12- * 3. THE ALL-TEN DOOR IS COMPLETE. `locales/index.ts` hands out each language
13+ * 3. THE ALL-PACKS DOOR IS COMPLETE. `locales/index.ts` hands out each language
1314 * as its pack merged with its catalogue, so the parity suites that walk
1415 * `builtInLocales` still walk these keys; the package entry's `en` is the
1516 * resident pack alone.
@@ -30,23 +31,25 @@ import { en as entryEn } from '../index.js';
3031import { BUILT_IN_LANGUAGE_CODES } from '../locales/registry.js' ;
3132import { builtInLocales } from '../locales/index.js' ;
3233import enPack from '../locales/en.js' ;
33- import zhPack from '../locales/zh.js' ;
34+ import zhHansPack from '../locales/zh-Hans.js' ;
35+ import zhHantPack from '../locales/zh-Hant.js' ;
3436import jaPack from '../locales/ja.js' ;
3537import koPack from '../locales/ko.js' ;
3638import dePack from '../locales/de.js' ;
3739import frPack from '../locales/fr.js' ;
3840import esPack from '../locales/es.js' ;
39- import ptPack from '../locales/pt.js' ;
41+ import ptBrPack from '../locales/pt-BR .js' ;
4042import ruPack from '../locales/ru.js' ;
4143import arPack from '../locales/ar.js' ;
4244import enNs from '../namespaces/marketplace/en.js' ;
43- import zhNs from '../namespaces/marketplace/zh.js' ;
45+ import zhHansNs from '../namespaces/marketplace/zh-Hans.js' ;
46+ import zhHantNs from '../namespaces/marketplace/zh-Hant.js' ;
4447import jaNs from '../namespaces/marketplace/ja.js' ;
4548import koNs from '../namespaces/marketplace/ko.js' ;
4649import deNs from '../namespaces/marketplace/de.js' ;
4750import frNs from '../namespaces/marketplace/fr.js' ;
4851import esNs from '../namespaces/marketplace/es.js' ;
49- import ptNs from '../namespaces/marketplace/pt.js' ;
52+ import ptBrNs from '../namespaces/marketplace/pt-BR .js' ;
5053import ruNs from '../namespaces/marketplace/ru.js' ;
5154import arNs from '../namespaces/marketplace/ar.js' ;
5255import {
@@ -63,12 +66,12 @@ const INDEX_PATH = join(HERE, '..', 'namespaces', 'marketplace', 'index.ts');
6366
6467type Tree = Record < string , unknown > ;
6568const PACKS : Record < string , Tree > = {
66- en : enPack , zh : zhPack , ja : jaPack , ko : koPack , de : dePack ,
67- fr : frPack , es : esPack , pt : ptPack , ru : ruPack , ar : arPack ,
69+ en : enPack , 'zh-Hans' : zhHansPack , 'zh-Hant' : zhHantPack , ja : jaPack , ko : koPack , de : dePack ,
70+ fr : frPack , es : esPack , 'pt-BR' : ptBrPack , ru : ruPack , ar : arPack ,
6871} ;
6972const CATALOGUES : Record < string , Tree > = {
70- en : enNs , zh : zhNs , ja : jaNs , ko : koNs , de : deNs ,
71- fr : frNs , es : esNs , pt : ptNs , ru : ruNs , ar : arNs ,
73+ en : enNs , 'zh-Hans' : zhHansNs , 'zh-Hant' : zhHantNs , ja : jaNs , ko : koNs , de : deNs ,
74+ fr : frNs , es : esNs , 'pt-BR' : ptBrNs , ru : ruNs , ar : arNs ,
7275} ;
7376
7477function leaves ( node : unknown , prefix = '' ) : string [ ] {
@@ -109,12 +112,14 @@ describe('marketplace namespace — lazy by construction', () => {
109112 } ) ;
110113
111114 it ( 'statically imports no catalogue (nothing of it rides in with the page frame)' , ( ) => {
112- expect ( staticSpecifiers . filter ( ( s ) => / ^ \. \/ [ a - z ] { 2 } \. j s $ / . test ( s ) ) ) . toEqual ( [ ] ) ;
115+ // A catalogue specifier is `./<tag>.js`: a language, or a language and a
116+ // script or region subtag (`./zh-Hant.js`, `./pt-BR.js`).
117+ expect ( staticSpecifiers . filter ( ( s ) => / ^ \. \/ [ a - z ] { 2 } (?: - [ A - Z a - z ] + ) ? \. j s $ / . test ( s ) ) ) . toEqual ( [ ] ) ;
113118 // Lit control: the static imports were read.
114119 expect ( staticSpecifiers ) . toContain ( '../../locales/registry.js' ) ;
115120 } ) ;
116121
117- it ( 'ships the ten built-in languages ' , ( ) => {
122+ it ( 'ships one catalogue per built-in language (the platform locale table) ' , ( ) => {
118123 expect ( [ ...MARKETPLACE_LANGUAGE_CODES ] . sort ( ) ) . toEqual ( [ ...BUILT_IN_LANGUAGE_CODES ] . sort ( ) ) ;
119124 } ) ;
120125} ) ;
@@ -139,7 +144,7 @@ describe('marketplace namespace — cut out of the packs, not copied', () => {
139144 } ) ;
140145} ) ;
141146
142- describe ( 'marketplace namespace — the all-ten door hands out complete languages' , ( ) => {
147+ describe ( 'marketplace namespace — the all-packs door hands out complete languages' , ( ) => {
143148 it . each ( BUILT_IN_LANGUAGE_CODES . map ( ( code ) => [ code ] ) ) ( '%s: pack keys and namespace keys are both there' , ( code ) => {
144149 const complete = ( builtInLocales as unknown as Record < string , Tree > ) [ code ] ;
145150 const expected = [ ...leaves ( PACKS [ code ] ) , ...leaves ( CATALOGUES [ code ] ) ] . sort ( ) ;
@@ -157,10 +162,14 @@ describe('marketplace namespace — the all-ten door hands out complete language
157162
158163describe ( 'marketplace namespace — language resolution and the loader' , ( ) => {
159164 it . each ( [
160- [ 'zh-CN' , 'zh' ] ,
161- [ 'zh' , 'zh' ] ,
162- [ 'zh-TW' , 'zh' ] ,
163- [ 'pt-BR' , 'pt' ] ,
165+ [ 'zh-CN' , 'zh-Hans' ] ,
166+ [ 'zh' , 'zh-Hans' ] ,
167+ [ 'zh-Hans' , 'zh-Hans' ] ,
168+ [ 'zh-TW' , 'zh-Hant' ] ,
169+ [ 'zh-HK' , 'zh-Hant' ] ,
170+ [ 'zh-Hant' , 'zh-Hant' ] ,
171+ [ 'pt' , 'pt-BR' ] ,
172+ [ 'pt-BR' , 'pt-BR' ] ,
164173 [ 'ar-EG' , 'ar' ] ,
165174 [ 'en-US' , 'en' ] ,
166175 [ 'de' , 'de' ] ,
0 commit comments