@pie-element/shared-i18n 0.1.2 → 0.1.3-next.20261024044430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,8 +24,13 @@ An element translates in the language its item declares in `model.language` (`en
24
24
  so a migrated element renders as it did; the PRD moves interface strings to a locale the host
25
25
  publishes, with `en-US` as the default. The browser locale is never consulted.
26
26
 
27
- A tag resolves by RFC 4647 lookup, then by its primary subtag: `es_MX` reads `es-MX`, then `es`. A
28
- tag nothing ships renders English key by key, unless a host registered messages for it.
27
+ A tag resolves by RFC 4647 lookup, then by its primary subtag: `es_MX` reads `es-MX`, then `es`.
28
+ Both steps stay within the tag's script, explicit or the CLDR likely script from
29
+ `Intl.Locale.maximize()`. Lookup tries the language and script before the bare language, so `zh-TW`
30
+ reads `zh-TW`, `zh-Hant`, then `zh`. A catalog under a bare tag declares its likely script, so `zh`
31
+ is Simplified and `sr` Cyrillic: `zh-TW` passes `zh` by, and `sr-ME`, which is Latin, passes `sr`
32
+ by. A tag nothing ships in its script renders English key by key, unless a host registered messages
33
+ for it.
29
34
 
30
35
  Each key is looked up in order: host messages for the locale, the shipped catalog for the locale,
31
36
  host messages for `en-US`, the shipped `en-US` catalog. A miss on all four returns the key.
@@ -168,6 +173,6 @@ every loader eager. A newly migrated element joins its `migratedElements` list.
168
173
  |---|---|
169
174
  | `provider.ts` | `SimpleI18n`: lookup, interpolation, plurals, direction, formatting |
170
175
  | `catalogs.ts` | `defineCatalogs`, the page registry, `isLocaleReady`, `loadLocale`, `registerMessages` |
171
- | `language-tags.ts` | Tag normalization and RFC 4647 matching |
176
+ | `language-tags.ts` | Tag normalization and script-aware RFC 4647 matching |
172
177
  | `element-language.ts` | `lang` and `dir` for an element's host |
173
178
  | `types.ts` | Catalog, key and translator types |
package/dist/index.js CHANGED
@@ -19,19 +19,45 @@ function r(t) {
19
19
  }
20
20
  return i;
21
21
  }
22
- function i(t, n) {
23
- for (let i of r(t)) {
24
- let t = n.find((t) => e(t) === i);
25
- if (t != null) return t;
22
+ var i = /* @__PURE__ */ new Map();
23
+ function a(t) {
24
+ let n = e(t);
25
+ if (!n || typeof Intl > "u" || typeof Intl.Locale != "function") return;
26
+ if (i.has(n)) return i.get(n);
27
+ let r;
28
+ try {
29
+ r = new Intl.Locale(n).maximize().script?.toLowerCase();
30
+ } catch {}
31
+ return i.set(n, r), r;
32
+ }
33
+ function o(e, t) {
34
+ let n = a(e), r = a(t);
35
+ return !n || !r || n === r;
36
+ }
37
+ function s(e) {
38
+ let t = r(e), n = a(e);
39
+ if (!n || t.length < 2) return t;
40
+ let i = t[t.length - 1], o = `${i}-${n}`;
41
+ return t.includes(o) ? t : [
42
+ ...t.slice(0, -1),
43
+ o,
44
+ i
45
+ ];
46
+ }
47
+ function c(t, n) {
48
+ let r = e(t);
49
+ for (let i of s(t)) {
50
+ let a = n.find((n) => e(n) === i && (i === r || o(t, n)));
51
+ if (a != null) return a;
26
52
  }
27
53
  }
28
54
  //#endregion
29
55
  //#region src/provider.ts
30
- var a = "en-US";
31
- function o(e) {
56
+ var l = "en-US";
57
+ function u(e) {
32
58
  return e;
33
59
  }
34
- var s = /* @__PURE__ */ new Set([
60
+ var d = /* @__PURE__ */ new Set([
35
61
  "ar",
36
62
  "ckb",
37
63
  "dv",
@@ -47,7 +73,7 @@ var s = /* @__PURE__ */ new Set([
47
73
  "ug",
48
74
  "ur",
49
75
  "yi"
50
- ]), c = /* @__PURE__ */ new Set([
76
+ ]), f = /* @__PURE__ */ new Set([
51
77
  "zero",
52
78
  "one",
53
79
  "two",
@@ -55,25 +81,25 @@ var s = /* @__PURE__ */ new Set([
55
81
  "many",
56
82
  "other"
57
83
  ]);
58
- function l(e) {
84
+ function p(e) {
59
85
  if (typeof e != "object" || !e) return !1;
60
86
  let t = Object.keys(e);
61
- return t.length > 0 && t.every((e) => c.has(e));
87
+ return t.length > 0 && t.every((e) => f.has(e));
62
88
  }
63
- function u(t) {
89
+ function m(t) {
64
90
  try {
65
91
  let e = new Intl.Locale(t).textInfo;
66
92
  if (e?.direction === "rtl" || e?.direction === "ltr") return e.direction;
67
93
  } catch {}
68
94
  let n = e(t).split("-")[0] ?? "";
69
- return s.has(n) ? "rtl" : "ltr";
95
+ return d.has(n) ? "rtl" : "ltr";
70
96
  }
71
- var d = class n {
97
+ var h = class n {
72
98
  static {
73
99
  this.pluralRules = /* @__PURE__ */ new Map();
74
100
  }
75
101
  constructor(e) {
76
- this.listeners = /* @__PURE__ */ new Set(), this.config = { ...e }, this.fallbackLocale = t(e.fallbackLocale) || "en-US", this.catalogs = /* @__PURE__ */ new Map([[a, e.source]]), this.customMessages = { ...e.customMessages ?? {} }, this.loading = /* @__PURE__ */ new Map(), this.locale = this.resolveLocaleTag(e.locale) ?? "en-US";
102
+ this.listeners = /* @__PURE__ */ new Set(), this.config = { ...e }, this.fallbackLocale = t(e.fallbackLocale) || "en-US", this.catalogs = /* @__PURE__ */ new Map([[l, e.source]]), this.customMessages = { ...e.customMessages ?? {} }, this.loading = /* @__PURE__ */ new Map(), this.locale = this.resolveLocaleTag(e.locale) ?? "en-US";
77
103
  }
78
104
  getLocale() {
79
105
  return this.locale;
@@ -84,14 +110,14 @@ var d = class n {
84
110
  }
85
111
  t(e, t) {
86
112
  let n = this.lookup(e);
87
- return n === void 0 ? (this.config.onMissingKey?.(e, this.locale), e) : h(n, t, this.locale);
113
+ return n === void 0 ? (this.config.onMissingKey?.(e, this.locale), e) : y(n, t, this.locale);
88
114
  }
89
115
  plural(e, t) {
90
116
  let n = this.lookupNode(e);
91
- return n === void 0 || !l(n) ? this.t(e, t) : h(n[this.selectPluralCategory(t.count)] ?? n.other, t, this.locale);
117
+ return n === void 0 || !p(n) ? this.t(e, t) : y(n[this.selectPluralCategory(t.count)] ?? n.other, t, this.locale);
92
118
  }
93
119
  getDirection() {
94
- return u(this.locale);
120
+ return m(this.locale);
95
121
  }
96
122
  getAvailableLocales() {
97
123
  return [.../* @__PURE__ */ new Set([
@@ -118,7 +144,7 @@ var d = class n {
118
144
  }
119
145
  addCustomMessages(e, n) {
120
146
  let r = t(e);
121
- this.customMessages[r] = g(this.customMessages[r] ?? {}, n), this.notify();
147
+ this.customMessages[r] = b(this.customMessages[r] ?? {}, n), this.notify();
122
148
  }
123
149
  withLocale(e) {
124
150
  let r = this.resolveLocaleTag(e) ?? t(e);
@@ -133,14 +159,14 @@ var d = class n {
133
159
  try {
134
160
  return new Intl.NumberFormat(this.locale, t).format(e);
135
161
  } catch {
136
- return new Intl.NumberFormat(a, t).format(e);
162
+ return new Intl.NumberFormat(l, t).format(e);
137
163
  }
138
164
  }
139
165
  formatDate(e, t) {
140
166
  try {
141
167
  return new Intl.DateTimeFormat(this.locale, t).format(e);
142
168
  } catch {
143
- return new Intl.DateTimeFormat(a, t).format(e);
169
+ return new Intl.DateTimeFormat(l, t).format(e);
144
170
  }
145
171
  }
146
172
  async ensureLoaded(e) {
@@ -160,10 +186,10 @@ var d = class n {
160
186
  }
161
187
  resolveLocaleTag(t) {
162
188
  if (!t) return;
163
- let n = this.getAvailableLocales(), r = i(t, n);
189
+ let n = this.getAvailableLocales(), r = c(t, n);
164
190
  if (r) return r;
165
- let a = e(t).split("-")[0];
166
- if (a) return n.find((t) => e(t).split("-")[0] === a);
191
+ let i = e(t).split("-")[0];
192
+ if (i) return n.find((n) => e(n).split("-")[0] === i && o(t, n));
167
193
  }
168
194
  async loadCatalog(e) {
169
195
  let t = this.config.loadCatalog;
@@ -181,14 +207,14 @@ var d = class n {
181
207
  this.catalogs.get(this.fallbackLocale)
182
208
  ];
183
209
  for (let n of t) {
184
- let t = f(n, e);
210
+ let t = g(n, e);
185
211
  if (t !== void 0) return t;
186
212
  }
187
213
  }
188
214
  lookup(e) {
189
215
  let t = this.lookupNode(e);
190
216
  if (typeof t == "string") return t;
191
- if (t !== void 0 && l(t)) return t.other;
217
+ if (t !== void 0 && p(t)) return t.other;
192
218
  }
193
219
  selectPluralCategory(e) {
194
220
  let t = n.pluralRules.get(this.locale);
@@ -206,87 +232,87 @@ var d = class n {
206
232
  for (let e of this.listeners) e();
207
233
  }
208
234
  };
209
- function f(e, t) {
235
+ function g(e, t) {
210
236
  if (!e) return;
211
237
  let n = e;
212
238
  for (let e of t.split(".")) if (typeof n != "object" || !n || (n = n[e], n === void 0)) return;
213
239
  return n;
214
240
  }
215
- var p = /* @__PURE__ */ new Map();
216
- function m(e, t) {
217
- let n = p.get(t);
241
+ var _ = /* @__PURE__ */ new Map();
242
+ function v(e, t) {
243
+ let n = _.get(t);
218
244
  if (!n) {
219
245
  try {
220
246
  n = new Intl.NumberFormat(t);
221
247
  } catch {
222
- n = new Intl.NumberFormat(a);
248
+ n = new Intl.NumberFormat(l);
223
249
  }
224
- p.set(t, n);
250
+ _.set(t, n);
225
251
  }
226
252
  return n.format(e);
227
253
  }
228
- function h(e, t, n) {
254
+ function y(e, t, n) {
229
255
  return t ? e.replace(/\{(\w+)\}/g, (e, r) => {
230
256
  let i = t[r];
231
- return i == null ? e : n !== void 0 && typeof i == "number" && Number.isFinite(i) ? m(i, n) : String(i);
257
+ return i == null ? e : n !== void 0 && typeof i == "number" && Number.isFinite(i) ? v(i, n) : String(i);
232
258
  }) : e;
233
259
  }
234
- function g(e, t) {
260
+ function b(e, t) {
235
261
  let n = { ...e };
236
262
  for (let [e, r] of Object.entries(t)) {
237
263
  let t = n[e];
238
- n[e] = r && typeof r == "object" && t && typeof t == "object" ? g(t, r) : r;
264
+ n[e] = r && typeof r == "object" && t && typeof t == "object" ? b(t, r) : r;
239
265
  }
240
266
  return n;
241
267
  }
242
268
  //#endregion
243
269
  //#region src/catalogs.ts
244
- var _ = Symbol.for("pie-element.i18n.registry");
245
- function v() {
270
+ var x = Symbol.for("pie-element.i18n.registry");
271
+ function S() {
246
272
  let e = globalThis;
247
- return e[_] || (e[_] = {
273
+ return e[x] || (e[x] = {
248
274
  sets: /* @__PURE__ */ new Set(),
249
275
  messages: /* @__PURE__ */ new Map()
250
- }), e[_];
276
+ }), e[x];
251
277
  }
252
- function y(e) {
253
- let t = e.loaders ?? {}, n = v(), r = new d({
278
+ function C(e) {
279
+ let t = e.loaders ?? {}, n = S(), r = new h({
254
280
  source: e.source,
255
- availableLocales: [a, ...Object.keys(t)],
281
+ availableLocales: [l, ...Object.keys(t)],
256
282
  loadCatalog: async (e) => (await t[e]()).default
257
283
  });
258
284
  for (let { locale: t, messages: i } of n.messages.get(e.packageName) ?? []) r.addCustomMessages(t, i);
259
- let i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), c = (e) => {
285
+ let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = (e) => {
260
286
  let t = e || "en-US", n = i.get(t);
261
287
  return n || (n = r.withLocale(t), i.set(t, n)), n;
262
- }, l = {
288
+ }, c = {
263
289
  packageName: e.packageName,
264
- locales: [a, ...Object.keys(t)],
265
- forLocale: (e, t) => (t && e && l.needsLoad(e) && l.load(e).then(t), c(e)),
266
- needsLoad: (e) => !s.has(e) && r.needsLoad(e),
290
+ locales: [l, ...Object.keys(t)],
291
+ forLocale: (e, t) => (t && e && c.needsLoad(e) && c.load(e).then(t), s(e)),
292
+ needsLoad: (e) => !o.has(e) && r.needsLoad(e),
267
293
  load: (t) => {
268
- if (!l.needsLoad(t)) return Promise.resolve();
269
- let n = o.get(t);
270
- return n || (n = c(t).setLocale(t).catch((n) => {
271
- s.add(t), console.warn(`[${e.packageName}]`, n);
272
- }).finally(() => o.delete(t)), o.set(t, n)), n;
294
+ if (!c.needsLoad(t)) return Promise.resolve();
295
+ let n = a.get(t);
296
+ return n || (n = s(t).setLocale(t).catch((n) => {
297
+ o.add(t), console.warn(`[${e.packageName}]`, n);
298
+ }).finally(() => a.delete(t)), a.set(t, n)), n;
273
299
  },
274
300
  addCustomMessages: (e, t) => {
275
301
  r.addCustomMessages(e, t), i.clear();
276
302
  }
277
303
  };
278
- return n.sets.add(l), l;
304
+ return n.sets.add(c), c;
279
305
  }
280
- function b(e) {
306
+ function w(e) {
281
307
  if (!e) return !0;
282
- for (let t of v().sets) if (t.needsLoad(e)) return !1;
308
+ for (let t of S().sets) if (t.needsLoad(e)) return !1;
283
309
  return !0;
284
310
  }
285
- async function x(e) {
286
- e && await Promise.all([...v().sets].map((t) => t.load(e)));
311
+ async function T(e) {
312
+ e && await Promise.all([...S().sets].map((t) => t.load(e)));
287
313
  }
288
- function S(e, t, n) {
289
- let r = v(), i = r.messages.get(e) ?? [];
314
+ function E(e, t, n) {
315
+ let r = S(), i = r.messages.get(e) ?? [];
290
316
  i.push({
291
317
  locale: t,
292
318
  messages: n
@@ -295,7 +321,7 @@ function S(e, t, n) {
295
321
  }
296
322
  //#endregion
297
323
  //#region src/element-language.ts
298
- function C(e) {
324
+ function D(e) {
299
325
  let n = t(e).split(/[.@]/)[0];
300
326
  if (/^[a-z]{2,3}(-|$)/i.test(n)) try {
301
327
  return Intl.getCanonicalLocales(n)[0];
@@ -303,44 +329,44 @@ function C(e) {
303
329
  return;
304
330
  }
305
331
  }
306
- function w(e) {
307
- let t = C(e);
332
+ function O(e) {
333
+ let t = D(e);
308
334
  return t ? {
309
335
  lang: t,
310
- dir: u(t)
336
+ dir: m(t)
311
337
  } : void 0;
312
338
  }
313
- function T(e, t) {
314
- let n = w(t);
339
+ function k(e, t) {
340
+ let n = O(t);
315
341
  n ? (e.setAttribute("lang", n.lang), e.setAttribute("dir", n.dir)) : (e.removeAttribute("lang"), e.removeAttribute("dir"));
316
342
  }
317
343
  //#endregion
318
344
  //#region ../../../node_modules/.bun/@pie-players+pie-context@1.0.0-beta.3/node_modules/@pie-players/pie-context/dist/events.js
319
- function E(e, t, n) {
345
+ function A(e, t, n) {
320
346
  let r = t.ownerDocument?.defaultView?.Event ?? Event;
321
347
  return Object.assign(new r(e, {
322
348
  bubbles: !0,
323
349
  composed: !0
324
350
  }), n);
325
351
  }
326
- var D = /* @__PURE__ */ new WeakSet(), O = (e, t) => typeof t == "object" && !!t && e.has(t), k = class {
352
+ var j = /* @__PURE__ */ new WeakSet(), M = (e, t) => typeof t == "object" && !!t && e.has(t), N = class {
327
353
  constructor(e, t, n, r) {
328
- let i = E("context-request", t, {
354
+ let i = A("context-request", t, {
329
355
  context: e,
330
356
  contextTarget: t,
331
357
  callback: n,
332
358
  subscribe: r ?? !1
333
359
  });
334
- return D.add(i), i;
360
+ return j.add(i), i;
335
361
  }
336
362
  static [Symbol.hasInstance](e) {
337
- return O(D, e);
363
+ return M(j, e);
338
364
  }
339
- }, A = (e) => {
365
+ }, P = (e) => {
340
366
  let t = [];
341
367
  for (let n of e) n.requestorRef.deref() && n.callbackRef.deref() && t.push(n);
342
368
  return t;
343
- }, j = class {
369
+ }, F = class {
344
370
  host;
345
371
  pendingByContext = /* @__PURE__ */ new Map();
346
372
  attached = !1;
@@ -368,7 +394,7 @@ var D = /* @__PURE__ */ new WeakSet(), O = (e, t) => typeof t == "object" && !!t
368
394
  a || (a = /* @__PURE__ */ new WeakSet(), r.callbacks.set(n, a)), !a.has(i) && (a.add(i), r.requests.push({
369
395
  requestorRef: new WeakRef(n),
370
396
  callbackRef: new WeakRef(i)
371
- }), r.requests = A(r.requests));
397
+ }), r.requests = P(r.requests));
372
398
  };
373
399
  onContextProvider = (e) => {
374
400
  let t = e.context;
@@ -378,23 +404,23 @@ var D = /* @__PURE__ */ new WeakSet(), O = (e, t) => typeof t == "object" && !!t
378
404
  this.pendingByContext.delete(t);
379
405
  for (let e of n.requests) {
380
406
  let n = e.requestorRef.deref(), r = e.callbackRef.deref();
381
- n && r && n.dispatchEvent(new k(t, n, r, !0));
407
+ n && r && n.dispatchEvent(new N(t, n, r, !0));
382
408
  }
383
409
  }
384
410
  };
385
- }, M = Symbol.for("pie.context.documentRoot");
386
- function N(e) {
411
+ }, I = Symbol.for("pie.context.documentRoot");
412
+ function L(e) {
387
413
  if (!e) return;
388
414
  let t = e;
389
- if (t[M]) return;
415
+ if (t[I]) return;
390
416
  let n = e.documentElement;
391
417
  if (!n) return;
392
- let r = new j(n);
393
- r.attach(), t[M] = r;
418
+ let r = new F(n);
419
+ r.attach(), t[I] = r;
394
420
  }
395
421
  //#endregion
396
422
  //#region ../../../node_modules/.bun/@pie-players+pie-context@1.0.0-beta.3/node_modules/@pie-players/pie-context/dist/consumer.js
397
- var P = class {
423
+ var R = class {
398
424
  host;
399
425
  context;
400
426
  subscribe;
@@ -407,7 +433,7 @@ var P = class {
407
433
  this.host = e, this.context = t.context, this.subscribe = t.subscribe ?? !0, this.onValue = t.onValue;
408
434
  }
409
435
  connect() {
410
- this.isConnected || (this.isConnected = !0, this.isDisconnected = !1, this.subscribe && N(this.host.ownerDocument), this.requestValue());
436
+ this.isConnected || (this.isConnected = !0, this.isDisconnected = !1, this.subscribe && L(this.host.ownerDocument), this.requestValue());
411
437
  }
412
438
  disconnect() {
413
439
  this.isConnected && (this.isConnected = !1, this.isDisconnected = !0, this.unsubscribe?.(), this.unsubscribe = void 0);
@@ -419,10 +445,10 @@ var P = class {
419
445
  this.isDisconnected ? t?.() : (t !== this.unsubscribe && (this.unsubscribe?.(), this.unsubscribe = t), !this.subscribe && this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0), this.currentValue = e, this.onValue?.(e));
420
446
  };
421
447
  requestValue() {
422
- this.host.dispatchEvent(new k(this.context, this.host, this.handleValue, this.subscribe));
448
+ this.host.dispatchEvent(new N(this.context, this.host, this.handleValue, this.subscribe));
423
449
  }
424
- }, F = (e, t, n) => {
425
- let r = new P(e, {
450
+ }, z = (e, t, n) => {
451
+ let r = new R(e, {
426
452
  context: t,
427
453
  subscribe: !0,
428
454
  onValue: n
@@ -434,9 +460,9 @@ var P = class {
434
460
  return e.addEventListener("context-provider", i), () => {
435
461
  e.removeEventListener("context-provider", i), r.disconnect();
436
462
  };
437
- }, I = ((e) => e)(Symbol.for("pie.interfaceLocale"));
438
- function L(e, t) {
439
- return F(e, I, t);
463
+ }, B = ((e) => e)(Symbol.for("pie.interfaceLocale"));
464
+ function V(e, t) {
465
+ return z(e, B, t);
440
466
  }
441
467
  //#endregion
442
- export { a as DEFAULT_LOCALE, d as SimpleI18n, C as canonicalLanguageTag, y as defineCatalogs, o as dynamicMessageKey, w as elementLanguageAttributes, i as findBestLanguageMatch, I as interfaceLocaleContext, b as isLocaleReady, r as languageTagLookupSequence, n as languageTagsEqual, x as loadLocale, u as localeDirection, e as normalizeLanguageTag, S as registerMessages, T as stampElementLanguage, L as subscribeInterfaceLocale, t as toLanguageTag };
468
+ export { l as DEFAULT_LOCALE, h as SimpleI18n, D as canonicalLanguageTag, C as defineCatalogs, u as dynamicMessageKey, O as elementLanguageAttributes, c as findBestLanguageMatch, B as interfaceLocaleContext, w as isLocaleReady, r as languageTagLookupSequence, n as languageTagsEqual, T as loadLocale, m as localeDirection, e as normalizeLanguageTag, E as registerMessages, k as stampElementLanguage, V as subscribeInterfaceLocale, t as toLanguageTag };
@@ -25,7 +25,20 @@ export declare function languageTagsEqual(a: string | null | undefined, b: strin
25
25
  */
26
26
  export declare function languageTagLookupSequence(tag: string | null | undefined): string[];
27
27
  /**
28
- * Best available tag for a request by RFC 4647 lookup, or `undefined`. Ranked by the
29
- * request's specificity, so `es-MX` prefers an `es-MX` candidate over an `es` one.
28
+ * The script a tag is written in, lowercased: explicit (`sr-Latn`), or the CLDR likely script
29
+ * (`zh-TW` maximizes to Hant, `sr` to Cyrl). `undefined` when the tag has no script data or the
30
+ * runtime has no `Intl.Locale`.
31
+ */
32
+ export declare function languageTagScript(tag: string | null | undefined): string | undefined;
33
+ /**
34
+ * Whether a catalog reached by widening serves a request in the same script. A tag without
35
+ * script data passes, so a runtime without `Intl.Locale` resolves as plain RFC 4647 lookup.
36
+ */
37
+ export declare function languageTagScriptsMatch(requested: string | null | undefined, candidate: string | null | undefined): boolean;
38
+ /**
39
+ * Best available tag for a request, or `undefined`. Ranked by the request's specificity, so
40
+ * `es-MX` prefers an `es-MX` candidate over an `es` one, and `zh-TW` reaches `zh-Hant`. A
41
+ * catalog shorter than the request serves it only in the same script: a bare `zh` catalog is
42
+ * Simplified, so `zh-TW` passes it by.
30
43
  */
31
44
  export declare function findBestLanguageMatch(requested: string | null | undefined, available: readonly (string | null | undefined)[]): string | undefined;
@@ -70,8 +70,9 @@ export declare class SimpleI18n<C extends MessageCatalog = MessageCatalog> imple
70
70
  /** Load a declared locale's catalog once, however many views ask concurrently. */
71
71
  private ensureLoaded;
72
72
  /**
73
- * RFC 4647 lookup first, so `es-MX` reaches an `es` catalog; then primary-subtag widening,
74
- * so a bare `es` or a POSIX `es_ES` reaches a regional catalog.
73
+ * Script-aware RFC 4647 lookup first, so `es-MX` reaches an `es` catalog; then primary-subtag
74
+ * widening, so a bare `es` or a POSIX `es_ES` reaches a regional catalog. Widening stays within
75
+ * the request's script: `zh` never reaches `zh-TW`, and `sr-Latn` may reach `sr-ME`.
75
76
  */
76
77
  private resolveLocaleTag;
77
78
  private loadCatalog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/shared-i18n",
3
- "version": "0.1.2",
3
+ "version": "0.1.3-next.20261024044430",
4
4
  "description": "Interface-string i18n engine for PIE elements: typed per-package catalogs, lazy locales, RFC 4647 resolution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",