@nice2dev/i18n 1.1.9 → 1.1.10

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 (94) hide show
  1. package/dist/calendar-systems.cjs +1 -0
  2. package/dist/calendar-systems.mjs +412 -0
  3. package/dist/dictionaries/ar.cjs +1 -0
  4. package/dist/dictionaries/ar.mjs +375 -0
  5. package/dist/dictionaries/bg.cjs +1 -0
  6. package/dist/dictionaries/bg.mjs +67 -0
  7. package/dist/dictionaries/bn.cjs +1 -0
  8. package/dist/dictionaries/bn.mjs +23 -0
  9. package/dist/dictionaries/cs.cjs +1 -0
  10. package/dist/dictionaries/cs.mjs +375 -0
  11. package/dist/dictionaries/da.cjs +1 -0
  12. package/dist/dictionaries/da.mjs +75 -0
  13. package/dist/dictionaries/de.cjs +1 -0
  14. package/dist/dictionaries/de.mjs +3398 -0
  15. package/dist/dictionaries/en.cjs +1 -0
  16. package/dist/dictionaries/en.mjs +3443 -0
  17. package/dist/dictionaries/es.cjs +1 -0
  18. package/dist/dictionaries/es.mjs +3396 -0
  19. package/dist/dictionaries/fi.cjs +1 -0
  20. package/dist/dictionaries/fi.mjs +75 -0
  21. package/dist/dictionaries/fil.cjs +1 -0
  22. package/dist/dictionaries/fil.mjs +19 -0
  23. package/dist/dictionaries/fr.cjs +1 -0
  24. package/dist/dictionaries/fr.mjs +3398 -0
  25. package/dist/dictionaries/hi.cjs +1 -0
  26. package/dist/dictionaries/hi.mjs +23 -0
  27. package/dist/dictionaries/hu.cjs +1 -0
  28. package/dist/dictionaries/hu.mjs +75 -0
  29. package/dist/dictionaries/id.cjs +1 -0
  30. package/dist/dictionaries/id.mjs +23 -0
  31. package/dist/dictionaries/index.cjs +1 -0
  32. package/dist/dictionaries/index.mjs +95 -0
  33. package/dist/dictionaries/it.cjs +1 -0
  34. package/dist/dictionaries/it.mjs +297 -0
  35. package/dist/dictionaries/ja.cjs +1 -0
  36. package/dist/dictionaries/ja.mjs +375 -0
  37. package/dist/dictionaries/ko.cjs +1 -0
  38. package/dist/dictionaries/ko.mjs +375 -0
  39. package/dist/dictionaries/ms.cjs +1 -0
  40. package/dist/dictionaries/ms.mjs +23 -0
  41. package/dist/dictionaries/nl.cjs +1 -0
  42. package/dist/dictionaries/nl.mjs +97 -0
  43. package/dist/dictionaries/no.cjs +1 -0
  44. package/dist/dictionaries/no.mjs +75 -0
  45. package/dist/dictionaries/pl.cjs +1 -0
  46. package/dist/dictionaries/pl.mjs +3404 -0
  47. package/dist/dictionaries/pt.cjs +1 -0
  48. package/dist/dictionaries/pt.mjs +375 -0
  49. package/dist/dictionaries/ro.cjs +1 -0
  50. package/dist/dictionaries/ro.mjs +67 -0
  51. package/dist/dictionaries/sk.cjs +1 -0
  52. package/dist/dictionaries/sk.mjs +75 -0
  53. package/dist/dictionaries/sv.cjs +1 -0
  54. package/dist/dictionaries/sv.mjs +82 -0
  55. package/dist/dictionaries/sw.cjs +1 -0
  56. package/dist/dictionaries/sw.mjs +23 -0
  57. package/dist/dictionaries/th.cjs +1 -0
  58. package/dist/dictionaries/th.mjs +23 -0
  59. package/dist/dictionaries/uk.cjs +1 -0
  60. package/dist/dictionaries/uk.mjs +3396 -0
  61. package/dist/dictionaries/vi.cjs +1 -0
  62. package/dist/dictionaries/vi.mjs +23 -0
  63. package/dist/dictionaries/zh.cjs +1 -0
  64. package/dist/dictionaries/zh.mjs +375 -0
  65. package/dist/dynamic-loading.cjs +1 -0
  66. package/dist/dynamic-loading.mjs +274 -0
  67. package/dist/i18n.cjs +1 -0
  68. package/dist/i18n.mjs +57 -0
  69. package/dist/i18nContext.cjs +1 -0
  70. package/dist/i18nContext.mjs +11 -0
  71. package/dist/i18nDictionaries.cjs +1 -0
  72. package/dist/i18nDictionaries.mjs +61 -0
  73. package/dist/icu.cjs +1 -0
  74. package/dist/icu.mjs +242 -0
  75. package/dist/index.cjs +1 -24
  76. package/dist/index.d.ts +59 -1
  77. package/dist/index.mjs +128 -25811
  78. package/dist/languages.cjs +1 -0
  79. package/dist/languages.mjs +44 -0
  80. package/dist/lazyDictionaries.cjs +1 -0
  81. package/dist/lazyDictionaries.mjs +95 -0
  82. package/dist/locale.cjs +1 -0
  83. package/dist/locale.mjs +94 -0
  84. package/dist/pseudo-localization.cjs +1 -0
  85. package/dist/pseudo-localization.mjs +272 -0
  86. package/dist/rtl.cjs +1 -0
  87. package/dist/rtl.mjs +155 -0
  88. package/dist/timezone.cjs +1 -0
  89. package/dist/timezone.mjs +195 -0
  90. package/dist/translate-pipeline.cjs +24 -0
  91. package/dist/translate-pipeline.mjs +79 -0
  92. package/dist/translationMemory.cjs +1 -0
  93. package/dist/translationMemory.mjs +207 -0
  94. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -400,6 +400,9 @@ export declare function getJapaneseEra(date: Date): JapaneseEra | null;
400
400
  */
401
401
  export declare function getJapaneseYear(date: Date): number | null;
402
402
 
403
+ /** The dictionary of `lang` if it has been loaded already, otherwise `undefined`. */
404
+ export declare function getLoadedNiceDictionary(lang: NiceSupportedLang): NiceDictionary | undefined;
405
+
403
406
  /**
404
407
  * Get the BCP 47 locale tag for a NiceSupportedLang code.
405
408
  */
@@ -601,6 +604,19 @@ export declare interface LoaderState {
601
604
  currentLanguage: NiceSupportedLang;
602
605
  }
603
606
 
607
+ /**
608
+ * Load one language's built-in dictionary. Cached, and concurrent calls share one request.
609
+ * Await it before the first render to start in that language instead of in English:
610
+ *
611
+ * ```ts
612
+ * await loadNiceDictionary('pl');
613
+ * root.render(<NiceI18nLazyProvider lang="pl"><App /></NiceI18nLazyProvider>);
614
+ * ```
615
+ *
616
+ * An unknown code loads English, as `NiceI18nProvider` falls back to it.
617
+ */
618
+ export declare function loadNiceDictionary(lang: NiceSupportedLang): Promise<NiceDictionary>;
619
+
604
620
  /**
605
621
  * Look up a term in the glossary for a given language.
606
622
  * Returns the approved translation or undefined.
@@ -622,6 +638,13 @@ export declare const NICE_I18N_DICTIONARIES: Record<NiceSupportedLang, Record<st
622
638
  */
623
639
  export declare const NICE_I18N_VARIANTS: Partial<Record<string, Partial<Record<NiceI18nVariant, Record<string, string>>>>>;
624
640
 
641
+ /**
642
+ * The languages with a built-in dictionary.
643
+ *
644
+ * Its own module, free of dictionary imports: the context, `useNiceTranslation` and the
645
+ * lazy provider need the list but must not pull thirty dictionaries in with it.
646
+ * `i18nDictionaries.ts` re-exports both names, so existing imports keep working.
647
+ */
625
648
  export declare const NICE_SUPPORTED_LANGS: readonly ["en", "pl", "de", "fr", "es", "it", "pt", "nl", "sv", "no", "da", "fi", "cs", "sk", "hu", "ro", "bg", "uk", "ja", "ko", "zh", "ar", "hi", "bn", "th", "vi", "id", "sw", "fil", "ms"];
626
649
 
627
650
  export declare interface NiceCurrencyFormatter {
@@ -634,6 +657,41 @@ export declare interface NiceDateFormatter {
634
657
  formatRelative: (date: Date | number) => string;
635
658
  }
636
659
 
660
+ declare type NiceDictionary = Record<string, string>;
661
+
662
+ /**
663
+ * A drop-in for `NiceI18nProvider` — same `t` / `lang` / `overrides` — that loads only the
664
+ * language in use, on demand, instead of carrying all thirty dictionaries in the bundle.
665
+ *
666
+ * @example
667
+ * <NiceI18nLazyProvider lang="pl">
668
+ * <App />
669
+ * </NiceI18nLazyProvider>
670
+ */
671
+ export declare const NiceI18nLazyProvider: default_2.FC<NiceI18nLazyProviderProps>;
672
+
673
+ export declare interface NiceI18nLazyProviderProps {
674
+ /**
675
+ * Custom translation function — takes priority over `lang` and nothing is loaded, as with
676
+ * `NiceI18nProvider`. Lets this provider replace that one everywhere, so nothing in an app
677
+ * has to reach for the module that holds all thirty dictionaries.
678
+ */
679
+ t?: NiceTranslateFn;
680
+ /** Built-in language code; its dictionary is loaded on first use. Default `'en'`. */
681
+ lang?: NiceSupportedLang;
682
+ /** Extra translations merged on top of the loaded dictionary. */
683
+ overrides?: Record<string, string>;
684
+ /**
685
+ * Rendered instead of `children` until the first dictionary has loaded. Leave it out to
686
+ * render the children straight away, in the controls' built-in English. On a language
687
+ * switch the previous language stays on screen until the new one arrives.
688
+ */
689
+ fallback?: default_2.ReactNode;
690
+ /** Called when a dictionary fails to load; the controls keep their current language. */
691
+ onError?: (error: unknown) => void;
692
+ children: default_2.ReactNode;
693
+ }
694
+
637
695
  /**
638
696
  * Provider for plugging in your own translation function (e.g. from react-i18next)
639
697
  * OR using built-in dictionaries via the `lang` prop.
@@ -1014,7 +1072,7 @@ export declare function useDynamicI18n(): DynamicI18nContextValue;
1014
1072
  export declare function useDynamicTranslation(namespace?: string): {
1015
1073
  t: (key: string, params?: Record<string, string | number>) => string;
1016
1074
  isLoading: boolean;
1017
- currentLanguage: "no" | "de" | "en" | "pl" | "fr" | "es" | "it" | "pt" | "nl" | "sv" | "da" | "fi" | "cs" | "sk" | "hu" | "ro" | "bg" | "uk" | "ja" | "ko" | "zh" | "ar" | "hi" | "bn" | "th" | "vi" | "id" | "sw" | "fil" | "ms";
1075
+ currentLanguage: "en" | "pl" | "de" | "fr" | "es" | "it" | "pt" | "nl" | "sv" | "no" | "da" | "fi" | "cs" | "sk" | "hu" | "ro" | "bg" | "uk" | "ja" | "ko" | "zh" | "ar" | "hi" | "bn" | "th" | "vi" | "id" | "sw" | "fil" | "ms";
1018
1076
  };
1019
1077
 
1020
1078
  /**