@object-ui/i18n 17.6.0 → 18.0.0

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +5408 -0
  2. package/README.md +255 -13
  3. package/dist/LocalizationContext.d.ts +32 -9
  4. package/dist/LocalizationContext.js +32 -10
  5. package/dist/builtinAggregateLabels.d.ts +40 -0
  6. package/dist/builtinAggregateLabels.js +23 -0
  7. package/dist/currency.d.ts +27 -3
  8. package/dist/currency.js +28 -4
  9. package/dist/fallbackInterpolation.d.ts +79 -0
  10. package/dist/fallbackInterpolation.js +124 -0
  11. package/dist/i18n.d.ts +27 -1
  12. package/dist/i18n.js +99 -16
  13. package/dist/index.d.ts +8 -13
  14. package/dist/index.js +45 -17
  15. package/dist/locales/ar.d.ts +1504 -188
  16. package/dist/locales/ar.js +1711 -281
  17. package/dist/locales/de.d.ts +1080 -188
  18. package/dist/locales/de.js +1248 -261
  19. package/dist/locales/en.d.ts +1141 -249
  20. package/dist/locales/en.js +1714 -295
  21. package/dist/locales/es.d.ts +1186 -188
  22. package/dist/locales/es.js +1350 -255
  23. package/dist/locales/fr.d.ts +1186 -188
  24. package/dist/locales/fr.js +1351 -258
  25. package/dist/locales/index.d.ts +11940 -2033
  26. package/dist/locales/index.js +48 -9
  27. package/dist/locales/ja.d.ts +1080 -188
  28. package/dist/locales/ja.js +1240 -254
  29. package/dist/locales/ko.d.ts +1080 -188
  30. package/dist/locales/ko.js +1244 -258
  31. package/dist/locales/pt.d.ts +1186 -188
  32. package/dist/locales/pt.js +1350 -255
  33. package/dist/locales/registry.d.ts +102 -0
  34. package/dist/locales/registry.js +220 -0
  35. package/dist/locales/rtl.d.ts +24 -0
  36. package/dist/locales/rtl.js +26 -0
  37. package/dist/locales/ru.d.ts +1292 -188
  38. package/dist/locales/ru.js +1479 -272
  39. package/dist/locales/zh.d.ts +1144 -252
  40. package/dist/locales/zh.js +1245 -259
  41. package/dist/pickLocalized.d.ts +30 -0
  42. package/dist/pickLocalized.js +39 -0
  43. package/dist/provider.d.ts +101 -12
  44. package/dist/provider.js +335 -50
  45. package/dist/translateFn.d.ts +29 -0
  46. package/dist/translateFn.js +8 -0
  47. package/dist/useDisplayLocale.d.ts +11 -0
  48. package/dist/useDisplayLocale.js +11 -0
  49. package/dist/useObjectLabel.d.ts +143 -100
  50. package/dist/useObjectLabel.js +129 -82
  51. package/dist/useSafeTranslation.js +40 -42
  52. package/dist/utils/first-day-of-week.d.ts +71 -0
  53. package/dist/utils/first-day-of-week.js +61 -0
  54. package/dist/utils/formatting.d.ts +23 -1
  55. package/dist/utils/formatting.js +34 -5
  56. package/dist/utils/index.d.ts +1 -0
  57. package/dist/utils/index.js +1 -0
  58. package/dist/utils/spec-formatters.d.ts +13 -23
  59. package/dist/utils/spec-formatters.js +41 -2
  60. package/dist/utils/spec-translations.d.ts +16 -3
  61. package/dist/utils/spec-translations.js +52 -13
  62. package/package.json +12 -6
@@ -1,6 +1,21 @@
1
1
  /**
2
- * @object-ui/i18n - Locale index
3
- * Exports all 10 built-in language packs
2
+ * @object-ui/i18n - Locale index — the explicit ALL TEN door.
3
+ *
4
+ * ⛔ This module is NOT reachable from the package entry any more
5
+ * (objectui#7479). Importing it pulls every catalogue this package ships —
6
+ * ~1.8 MB raw / ~450 KB gzipped — which is exactly the eager payload that card
7
+ * removed from the console. The entry exposes `en` plus
8
+ * `loadBuiltInLocale()` instead; see `./registry.js`.
9
+ *
10
+ * What it is still for, and the only two things it is for:
11
+ *
12
+ * - the parity / drift suites, which must compare all ten packs at once and
13
+ * run in Node, where a megabyte of translations costs nobody anything;
14
+ * - an app that deliberately wants every catalogue resident, which reaches it
15
+ * through the published `@object-ui/i18n/locales` subpath — a specifier
16
+ * that says what it costs.
17
+ *
18
+ * ⚠️ Anything on a page-load path belongs on `./registry.js`, not here.
4
19
  */
5
20
  export { default as en } from './en.js';
6
21
  export { default as zh } from './zh.js';
@@ -26,13 +41,37 @@ import pt from './pt.js';
26
41
  import ru from './ru.js';
27
42
  import ar from './ar.js';
28
43
  export const builtInLocales = { en, zh, ja, ko, de, fr, es, pt, ru, ar };
44
+ // Direction and the lazy registry live in payload-free modules so the runtime
45
+ // can reach them without reaching the ten packs above. Re-exported here so the
46
+ // historical import path keeps answering.
47
+ export { RTL_LANGUAGES, isRTL } from './rtl.js';
48
+ export { BUILT_IN_LANGUAGE_CODES, DEFAULT_BUILT_IN_LANGUAGE, getLoadedBuiltInLocales, isBuiltInLanguage, isBuiltInLocaleLoaded, loadBuiltInLocale, } from './registry.js';
49
+ import { registerBuiltInLocale } from './registry.js';
29
50
  /**
30
- * List of RTL language codes
51
+ * Make every catalogue this module holds RESIDENT — synchronously, and without
52
+ * a single `import()`.
53
+ *
54
+ * ⛔ Deliberately a CALL and not an import-time side effect: this package
55
+ * declares `"sideEffects": false`, and a module that registered on import would
56
+ * make that declaration false for every consumer's bundler. A caller that wants
57
+ * all ten resident says so.
58
+ *
59
+ * Who calls it:
60
+ *
61
+ * - a test that renders in a non-`en` locale and asserts SYNCHRONOUSLY. One
62
+ * line at module scope, next to the import that already paid for these ten
63
+ * modules, is the shape AGENTS.md prescribes for a cost that belongs in the
64
+ * import phase — ⛔ never a `beforeAll`, which is bounded by `hookTimeout`
65
+ * and only moves the race;
66
+ * - an app that deliberately ships every language resident and wants no
67
+ * fetch at switch time.
68
+ *
69
+ * ⚠️ It is NOT how a normal app boots. Calling it costs the whole ~1.8 MB of
70
+ * catalogues on the page-load path, which is the payload objectui#7479 removed.
71
+ * `preloadBootstrapLocale()` — one catalogue, the active one — is that path.
31
72
  */
32
- export const RTL_LANGUAGES = ['ar', 'he', 'fa', 'ur'];
33
- /**
34
- * Check if a language code is RTL
35
- */
36
- export function isRTL(lang) {
37
- return RTL_LANGUAGES.includes(lang);
73
+ export function registerBuiltInLocales() {
74
+ for (const [code, catalogue] of Object.entries(builtInLocales)) {
75
+ registerBuiltInLocale(code, catalogue);
76
+ }
38
77
  }