@object-ui/i18n 17.5.0 → 17.7.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 (58) hide show
  1. package/CHANGELOG.md +4954 -0
  2. package/README.md +234 -13
  3. package/dist/builtinAggregateLabels.d.ts +40 -0
  4. package/dist/builtinAggregateLabels.js +23 -0
  5. package/dist/currency.d.ts +27 -3
  6. package/dist/currency.js +28 -4
  7. package/dist/fallbackInterpolation.d.ts +79 -0
  8. package/dist/fallbackInterpolation.js +124 -0
  9. package/dist/i18n.d.ts +28 -2
  10. package/dist/i18n.js +99 -17
  11. package/dist/index.d.ts +17 -23
  12. package/dist/index.js +51 -27
  13. package/dist/locales/ar.d.ts +1113 -370
  14. package/dist/locales/ar.js +1276 -428
  15. package/dist/locales/de.d.ts +785 -370
  16. package/dist/locales/de.js +896 -401
  17. package/dist/locales/en.d.ts +800 -385
  18. package/dist/locales/en.js +1261 -419
  19. package/dist/locales/es.d.ts +867 -370
  20. package/dist/locales/es.js +976 -398
  21. package/dist/locales/fr.d.ts +867 -370
  22. package/dist/locales/fr.js +976 -399
  23. package/dist/locales/index.d.ts +8682 -3761
  24. package/dist/locales/index.js +68 -29
  25. package/dist/locales/ja.d.ts +785 -370
  26. package/dist/locales/ja.js +891 -395
  27. package/dist/locales/ko.d.ts +785 -370
  28. package/dist/locales/ko.js +893 -399
  29. package/dist/locales/pt.d.ts +867 -370
  30. package/dist/locales/pt.js +975 -397
  31. package/dist/locales/registry.d.ts +102 -0
  32. package/dist/locales/registry.js +220 -0
  33. package/dist/locales/rtl.d.ts +24 -0
  34. package/dist/locales/rtl.js +26 -0
  35. package/dist/locales/ru.d.ts +949 -370
  36. package/dist/locales/ru.js +1093 -419
  37. package/dist/locales/zh.d.ts +803 -388
  38. package/dist/locales/zh.js +899 -388
  39. package/dist/pickLocalized.d.ts +67 -0
  40. package/dist/pickLocalized.js +114 -0
  41. package/dist/provider.d.ts +102 -13
  42. package/dist/provider.js +335 -50
  43. package/dist/translateFn.d.ts +29 -0
  44. package/dist/translateFn.js +8 -0
  45. package/dist/useDisplayLocale.d.ts +11 -0
  46. package/dist/useDisplayLocale.js +13 -2
  47. package/dist/useObjectLabel.d.ts +118 -22
  48. package/dist/useObjectLabel.js +148 -23
  49. package/dist/useSafeTranslation.js +41 -43
  50. package/dist/utils/formatting.d.ts +16 -0
  51. package/dist/utils/formatting.js +23 -3
  52. package/dist/utils/index.d.ts +4 -4
  53. package/dist/utils/index.js +4 -4
  54. package/dist/utils/spec-formatters.d.ts +13 -23
  55. package/dist/utils/spec-formatters.js +41 -2
  56. package/dist/utils/spec-translations.d.ts +16 -3
  57. package/dist/utils/spec-translations.js +52 -13
  58. package/package.json +12 -6
@@ -1,38 +1,77 @@
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
- export { default as en } from './en';
6
- export { default as zh } from './zh';
7
- export { default as ja } from './ja';
8
- export { default as ko } from './ko';
9
- export { default as de } from './de';
10
- export { default as fr } from './fr';
11
- export { default as es } from './es';
12
- export { default as pt } from './pt';
13
- export { default as ru } from './ru';
14
- export { default as ar } from './ar';
20
+ export { default as en } from './en.js';
21
+ export { default as zh } from './zh.js';
22
+ export { default as ja } from './ja.js';
23
+ export { default as ko } from './ko.js';
24
+ export { default as de } from './de.js';
25
+ export { default as fr } from './fr.js';
26
+ export { default as es } from './es.js';
27
+ export { default as pt } from './pt.js';
28
+ export { default as ru } from './ru.js';
29
+ export { default as ar } from './ar.js';
15
30
  /**
16
31
  * Map of all built-in locales keyed by language code
17
32
  */
18
- import en from './en';
19
- import zh from './zh';
20
- import ja from './ja';
21
- import ko from './ko';
22
- import de from './de';
23
- import fr from './fr';
24
- import es from './es';
25
- import pt from './pt';
26
- import ru from './ru';
27
- import ar from './ar';
33
+ import en from './en.js';
34
+ import zh from './zh.js';
35
+ import ja from './ja.js';
36
+ import ko from './ko.js';
37
+ import de from './de.js';
38
+ import fr from './fr.js';
39
+ import es from './es.js';
40
+ import pt from './pt.js';
41
+ import ru from './ru.js';
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
  }