@nice2dev/i18n 1.1.10 → 1.2.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.
- package/README.md +74 -35
- package/dist/all.cjs +1 -0
- package/dist/all.d.ts +136 -0
- package/dist/all.mjs +25 -0
- package/dist/dictionaries/de.cjs +1 -1
- package/dist/dictionaries/de.mjs +1008 -1
- package/dist/dictionaries/en.cjs +1 -1
- package/dist/dictionaries/en.mjs +1008 -1
- package/dist/dictionaries/es.cjs +1 -1
- package/dist/dictionaries/es.mjs +1008 -1
- package/dist/dictionaries/fr.cjs +1 -1
- package/dist/dictionaries/fr.mjs +1008 -1
- package/dist/dictionaries/pl.cjs +1 -1
- package/dist/dictionaries/pl.mjs +1008 -1
- package/dist/dictionaries/uk.cjs +1 -1
- package/dist/dictionaries/uk.mjs +1008 -1
- package/dist/i18n.cjs +1 -1
- package/dist/i18n.mjs +10 -51
- package/dist/i18nContext.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +46 -158
- package/dist/index.mjs +108 -127
- package/dist/languages.cjs +1 -1
- package/dist/languages.mjs +14 -2
- package/dist/lazyDictionaries.cjs +1 -1
- package/dist/lazyDictionaries.mjs +20 -19
- package/package.json +6 -1
package/dist/index.mjs
CHANGED
|
@@ -1,130 +1,111 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { CALENDAR_INFO as ye, CELESTIAL_STEMS as _e, CHINESE_ZODIAC as Pe, DEFAULT_CALENDAR as xe, HEBREW_MONTHS as ze, HEBREW_MONTHS_LEAP as Fe, HIJRI_MONTHS as He, JAPANESE_ERAS as Oe, PERSIAN_MONTHS as ve, createCalendarFormatter as Me, getAvailableCalendars as Ge, getCalendarInfo as Ue, getCelestialStem as Ve, getChineseZodiac as Be, getCurrentCalendarDate as Ye, getHijriMonthDays as be, getJapaneseEra as he, getJapaneseYear as Je, getRecommendedCalendars as ke, isHebrewLeapYear as We, isHijriLeapYear as Ze, isPersianLeapYear as je, toCalendar as we, useCalendar as Ke } from "./calendar-systems.mjs";
|
|
13
|
-
import { PSEUDO_PRESETS as Qe, PseudoLocalizationProvider as Xe, addAccents as $e, addBidiMarkers as er, addBrackets as rr, analyzeDictionary as ar, containsNonAscii as tr, detectHardcodedText as or, expandText as ir, getPseudoLocalizationPreset as nr, pseudoLocalize as sr, pseudoLocalizeDictionary as cr, usePseudoLocalization as lr } from "./pseudo-localization.mjs";
|
|
14
|
-
import { DynamicI18nProvider as mr, createDynamicLoader as Tr, createFetchLoader as gr, createImportLoader as Sr, detectAndLoad as Lr, preloadWithStrategy as pr, useDynamicI18n as ur, useDynamicTranslation as Nr } from "./dynamic-loading.mjs";
|
|
15
|
-
import { NICE_I18N_DICTIONARIES as Er } from "./dictionaries/index.mjs";
|
|
1
|
+
import { NiceI18nLazyProvider as a, NiceI18nProvider as t, getLoadedNiceDictionary as o, loadNiceDictionary as i } from "./lazyDictionaries.mjs";
|
|
2
|
+
import { formatMessage as c } from "./i18n.mjs";
|
|
3
|
+
import { NICE_SUPPORTED_LANGS as d, detectBrowserLanguage as m, isSupported as l } from "./languages.mjs";
|
|
4
|
+
import { useNiceTranslation as L } from "./i18nContext.mjs";
|
|
5
|
+
import { createICUTranslator as u, formatICU as S, getOrdinalCategory as p, getPluralCategory as N, ordinal as C, plural as E, select as D } from "./icu.mjs";
|
|
6
|
+
import { RTLProvider as P, RTL_CSS_VARS as R, RTL_LANGUAGES as y, analyzeStylesForRTL as I, flipAlignment as f, flipHorizontal as z, getDocumentDirection as _, getLogicalProperty as x, getRTLCSSVars as F, getTextDirection as H, isRTLLanguage as O, rtlValue as M, setDocumentDirection as U, useIsRTL as v, useRTL as B } from "./rtl.mjs";
|
|
7
|
+
import { createCurrencyFormatter as b, createDateFormatter as h, createNumberFormatter as J, createTimeFormatter as V, getLocaleTag as Y, useNiceCurrencyFormat as W, useNiceDateFormat as Z, useNiceNumberFormat as j, useNiceTimeFormat as k } from "./locale.mjs";
|
|
8
|
+
import { TIMEZONE_GROUPS as q, convertTimezone as K, createTimezoneFormatter as Q, detectTimezone as X, fromUTC as $, getAllTimezones as ee, getNextDSTTransition as re, getTimezoneInfo as ae, getTimezonesGrouped as te, isDSTActive as oe, isValidTimezone as ie, toUTC as ne, useTimezone as ce } from "./timezone.mjs";
|
|
9
|
+
import { CALENDAR_INFO as de, CELESTIAL_STEMS as me, CHINESE_ZODIAC as le, DEFAULT_CALENDAR as Te, HEBREW_MONTHS as Le, HEBREW_MONTHS_LEAP as ge, HIJRI_MONTHS as ue, JAPANESE_ERAS as Se, PERSIAN_MONTHS as pe, createCalendarFormatter as Ne, getAvailableCalendars as Ce, getCalendarInfo as Ee, getCelestialStem as De, getChineseZodiac as Ae, getCurrentCalendarDate as Pe, getHijriMonthDays as Re, getJapaneseEra as ye, getJapaneseYear as Ie, getRecommendedCalendars as fe, isHebrewLeapYear as ze, isHijriLeapYear as _e, isPersianLeapYear as xe, toCalendar as Fe, useCalendar as He } from "./calendar-systems.mjs";
|
|
10
|
+
import { PSEUDO_PRESETS as Me, PseudoLocalizationProvider as Ue, addAccents as ve, addBidiMarkers as Be, addBrackets as Ge, analyzeDictionary as be, containsNonAscii as he, detectHardcodedText as Je, expandText as Ve, getPseudoLocalizationPreset as Ye, pseudoLocalize as We, pseudoLocalizeDictionary as Ze, usePseudoLocalization as je } from "./pseudo-localization.mjs";
|
|
11
|
+
import { DynamicI18nProvider as we, createDynamicLoader as qe, createFetchLoader as Ke, createImportLoader as Qe, detectAndLoad as Xe, preloadWithStrategy as $e, useDynamicI18n as er, useDynamicTranslation as rr } from "./dynamic-loading.mjs";
|
|
16
12
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
O as getDocumentDirection,
|
|
78
|
-
ce as getGlossaryForLanguage,
|
|
79
|
-
be as getHijriMonthDays,
|
|
80
|
-
he as getJapaneseEra,
|
|
81
|
-
Je as getJapaneseYear,
|
|
82
|
-
m as getLoadedNiceDictionary,
|
|
83
|
-
ee as getLocaleTag,
|
|
84
|
-
v as getLogicalProperty,
|
|
85
|
-
Z as getMissingTranslations,
|
|
86
|
-
Ne as getNextDSTTransition,
|
|
13
|
+
de as CALENDAR_INFO,
|
|
14
|
+
me as CELESTIAL_STEMS,
|
|
15
|
+
le as CHINESE_ZODIAC,
|
|
16
|
+
Te as DEFAULT_CALENDAR,
|
|
17
|
+
we as DynamicI18nProvider,
|
|
18
|
+
Le as HEBREW_MONTHS,
|
|
19
|
+
ge as HEBREW_MONTHS_LEAP,
|
|
20
|
+
ue as HIJRI_MONTHS,
|
|
21
|
+
Se as JAPANESE_ERAS,
|
|
22
|
+
d as NICE_SUPPORTED_LANGS,
|
|
23
|
+
a as NiceI18nLazyProvider,
|
|
24
|
+
t as NiceI18nProvider,
|
|
25
|
+
pe as PERSIAN_MONTHS,
|
|
26
|
+
Me as PSEUDO_PRESETS,
|
|
27
|
+
Ue as PseudoLocalizationProvider,
|
|
28
|
+
P as RTLProvider,
|
|
29
|
+
R as RTL_CSS_VARS,
|
|
30
|
+
y as RTL_LANGUAGES,
|
|
31
|
+
q as TIMEZONE_GROUPS,
|
|
32
|
+
ve as addAccents,
|
|
33
|
+
Be as addBidiMarkers,
|
|
34
|
+
Ge as addBrackets,
|
|
35
|
+
be as analyzeDictionary,
|
|
36
|
+
I as analyzeStylesForRTL,
|
|
37
|
+
he as containsNonAscii,
|
|
38
|
+
K as convertTimezone,
|
|
39
|
+
Ne as createCalendarFormatter,
|
|
40
|
+
b as createCurrencyFormatter,
|
|
41
|
+
h as createDateFormatter,
|
|
42
|
+
qe as createDynamicLoader,
|
|
43
|
+
Ke as createFetchLoader,
|
|
44
|
+
u as createICUTranslator,
|
|
45
|
+
Qe as createImportLoader,
|
|
46
|
+
J as createNumberFormatter,
|
|
47
|
+
V as createTimeFormatter,
|
|
48
|
+
Q as createTimezoneFormatter,
|
|
49
|
+
Xe as detectAndLoad,
|
|
50
|
+
m as detectBrowserLanguage,
|
|
51
|
+
Je as detectHardcodedText,
|
|
52
|
+
X as detectTimezone,
|
|
53
|
+
Ve as expandText,
|
|
54
|
+
f as flipAlignment,
|
|
55
|
+
z as flipHorizontal,
|
|
56
|
+
S as formatICU,
|
|
57
|
+
c as formatMessage,
|
|
58
|
+
$ as fromUTC,
|
|
59
|
+
ee as getAllTimezones,
|
|
60
|
+
Ce as getAvailableCalendars,
|
|
61
|
+
Ee as getCalendarInfo,
|
|
62
|
+
De as getCelestialStem,
|
|
63
|
+
Ae as getChineseZodiac,
|
|
64
|
+
Pe as getCurrentCalendarDate,
|
|
65
|
+
_ as getDocumentDirection,
|
|
66
|
+
Re as getHijriMonthDays,
|
|
67
|
+
ye as getJapaneseEra,
|
|
68
|
+
Ie as getJapaneseYear,
|
|
69
|
+
o as getLoadedNiceDictionary,
|
|
70
|
+
Y as getLocaleTag,
|
|
71
|
+
x as getLogicalProperty,
|
|
72
|
+
re as getNextDSTTransition,
|
|
87
73
|
p as getOrdinalCategory,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
c as useNiceTranslation,
|
|
126
|
-
lr as usePseudoLocalization,
|
|
127
|
-
b as useRTL,
|
|
128
|
-
Re as useTimezone,
|
|
129
|
-
de as validateAgainstGlossary
|
|
74
|
+
N as getPluralCategory,
|
|
75
|
+
Ye as getPseudoLocalizationPreset,
|
|
76
|
+
F as getRTLCSSVars,
|
|
77
|
+
fe as getRecommendedCalendars,
|
|
78
|
+
H as getTextDirection,
|
|
79
|
+
ae as getTimezoneInfo,
|
|
80
|
+
te as getTimezonesGrouped,
|
|
81
|
+
oe as isDSTActive,
|
|
82
|
+
ze as isHebrewLeapYear,
|
|
83
|
+
_e as isHijriLeapYear,
|
|
84
|
+
xe as isPersianLeapYear,
|
|
85
|
+
O as isRTLLanguage,
|
|
86
|
+
l as isSupported,
|
|
87
|
+
ie as isValidTimezone,
|
|
88
|
+
i as loadNiceDictionary,
|
|
89
|
+
C as ordinal,
|
|
90
|
+
E as plural,
|
|
91
|
+
$e as preloadWithStrategy,
|
|
92
|
+
We as pseudoLocalize,
|
|
93
|
+
Ze as pseudoLocalizeDictionary,
|
|
94
|
+
M as rtlValue,
|
|
95
|
+
D as select,
|
|
96
|
+
U as setDocumentDirection,
|
|
97
|
+
Fe as toCalendar,
|
|
98
|
+
ne as toUTC,
|
|
99
|
+
He as useCalendar,
|
|
100
|
+
er as useDynamicI18n,
|
|
101
|
+
rr as useDynamicTranslation,
|
|
102
|
+
v as useIsRTL,
|
|
103
|
+
W as useNiceCurrencyFormat,
|
|
104
|
+
Z as useNiceDateFormat,
|
|
105
|
+
j as useNiceNumberFormat,
|
|
106
|
+
k as useNiceTimeFormat,
|
|
107
|
+
L as useNiceTranslation,
|
|
108
|
+
je as usePseudoLocalization,
|
|
109
|
+
B as useRTL,
|
|
110
|
+
ce as useTimezone
|
|
130
111
|
};
|
package/dist/languages.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=["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"];function r(e){return t.includes(e)}function i(){var n;if(typeof navigator>"u")return"en";const e=(n=navigator.language)==null?void 0:n.split("-")[0];return r(e)?e:"en"}exports.NICE_SUPPORTED_LANGS=t;exports.detectBrowserLanguage=i;exports.isSupported=r;
|
package/dist/languages.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t = [
|
|
2
2
|
"en",
|
|
3
3
|
"pl",
|
|
4
4
|
"de",
|
|
@@ -39,6 +39,18 @@ const s = [
|
|
|
39
39
|
"ms"
|
|
40
40
|
// Malay
|
|
41
41
|
];
|
|
42
|
+
function r(n) {
|
|
43
|
+
return t.includes(n);
|
|
44
|
+
}
|
|
45
|
+
function i() {
|
|
46
|
+
var e;
|
|
47
|
+
if (typeof navigator > "u")
|
|
48
|
+
return "en";
|
|
49
|
+
const n = (e = navigator.language) == null ? void 0 : e.split("-")[0];
|
|
50
|
+
return r(n) ? n : "en";
|
|
51
|
+
}
|
|
42
52
|
export {
|
|
43
|
-
|
|
53
|
+
t as NICE_SUPPORTED_LANGS,
|
|
54
|
+
i as detectBrowserLanguage,
|
|
55
|
+
r as isSupported
|
|
44
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),v=require("react"),j=require("./i18nContext.cjs"),e=r=>Object.freeze(Object.defineProperty({__proto__:null,default:r},Symbol.toStringTag,{value:"Module"})),x={en:()=>Promise.resolve().then(()=>e(require("./dictionaries/en.cjs"))),pl:()=>Promise.resolve().then(()=>e(require("./dictionaries/pl.cjs"))),de:()=>Promise.resolve().then(()=>e(require("./dictionaries/de.cjs"))),fr:()=>Promise.resolve().then(()=>e(require("./dictionaries/fr.cjs"))),es:()=>Promise.resolve().then(()=>e(require("./dictionaries/es.cjs"))),it:()=>Promise.resolve().then(()=>e(require("./dictionaries/it.cjs"))),pt:()=>Promise.resolve().then(()=>e(require("./dictionaries/pt.cjs"))),nl:()=>Promise.resolve().then(()=>e(require("./dictionaries/nl.cjs"))),sv:()=>Promise.resolve().then(()=>e(require("./dictionaries/sv.cjs"))),no:()=>Promise.resolve().then(()=>e(require("./dictionaries/no.cjs"))),da:()=>Promise.resolve().then(()=>e(require("./dictionaries/da.cjs"))),fi:()=>Promise.resolve().then(()=>e(require("./dictionaries/fi.cjs"))),cs:()=>Promise.resolve().then(()=>e(require("./dictionaries/cs.cjs"))),sk:()=>Promise.resolve().then(()=>e(require("./dictionaries/sk.cjs"))),hu:()=>Promise.resolve().then(()=>e(require("./dictionaries/hu.cjs"))),ro:()=>Promise.resolve().then(()=>e(require("./dictionaries/ro.cjs"))),bg:()=>Promise.resolve().then(()=>e(require("./dictionaries/bg.cjs"))),uk:()=>Promise.resolve().then(()=>e(require("./dictionaries/uk.cjs"))),ja:()=>Promise.resolve().then(()=>e(require("./dictionaries/ja.cjs"))),ko:()=>Promise.resolve().then(()=>e(require("./dictionaries/ko.cjs"))),zh:()=>Promise.resolve().then(()=>e(require("./dictionaries/zh.cjs"))),ar:()=>Promise.resolve().then(()=>e(require("./dictionaries/ar.cjs"))),hi:()=>Promise.resolve().then(()=>e(require("./dictionaries/hi.cjs"))),bn:()=>Promise.resolve().then(()=>e(require("./dictionaries/bn.cjs"))),th:()=>Promise.resolve().then(()=>e(require("./dictionaries/th.cjs"))),vi:()=>Promise.resolve().then(()=>e(require("./dictionaries/vi.cjs"))),id:()=>Promise.resolve().then(()=>e(require("./dictionaries/id.cjs"))),sw:()=>Promise.resolve().then(()=>e(require("./dictionaries/sw.cjs"))),fil:()=>Promise.resolve().then(()=>e(require("./dictionaries/fil.cjs"))),ms:()=>Promise.resolve().then(()=>e(require("./dictionaries/ms.cjs")))},h=new Map,d=new Map;function L(r){return h.get(r)}function D(r){const t=h.get(r);if(t)return Promise.resolve(t);let o=d.get(r);return o||(o=(x[r]??x.en)().then(s=>(h.set(r,s.default),d.delete(r),s.default),s=>{throw d.delete(r),s}),d.set(r,o)),o}const b=({t:r,lang:t="en",overrides:o,fallback:q,onError:s,children:a})=>{const[n,f]=v.useState(null),P=v.useRef(s);P.current=s;const y=h.get(t),w=y?t:n==null?void 0:n.lang,l=y??(n==null?void 0:n.dict);v.useEffect(()=>{if(r)return;const c=h.get(t);if(c){f(i=>(i==null?void 0:i.lang)===t?i:{lang:t,dict:c});return}let u=!0;return D(t).then(i=>{u&&f({lang:t,dict:i})},i=>{var N;u&&((N=P.current)==null||N.call(P,i))}),()=>{u=!1}},[t,r]);const I=v.useMemo(()=>{const c=l&&o?{...l,...o}:l??o;return c?(u,i)=>c[u]??i:(u,i)=>i},[l,o]);return r?m.jsx(j.NiceI18nContextProvider,{t:r,lang:t,children:a}):!l&&q!==void 0?m.jsx(m.Fragment,{children:q}):m.jsx(j.NiceI18nContextProvider,{t:I,lang:w??"en",children:a})},S=b;exports.NiceI18nLazyProvider=S;exports.NiceI18nProvider=b;exports.getLoadedNiceDictionary=L;exports.loadNiceDictionary=D;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as h, Fragment as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { NiceI18nContextProvider as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as h, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { useState as x, useRef as I, useEffect as M, useMemo as j } from "react";
|
|
3
|
+
import { NiceI18nContextProvider as N } from "./i18nContext.mjs";
|
|
4
|
+
const D = {
|
|
5
5
|
en: () => import("./dictionaries/en.mjs"),
|
|
6
6
|
pl: () => import("./dictionaries/pl.mjs"),
|
|
7
7
|
de: () => import("./dictionaries/de.mjs"),
|
|
@@ -33,22 +33,22 @@ const L = {
|
|
|
33
33
|
fil: () => import("./dictionaries/fil.mjs"),
|
|
34
34
|
ms: () => import("./dictionaries/ms.mjs")
|
|
35
35
|
}, c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
36
|
-
function
|
|
36
|
+
function C(t) {
|
|
37
37
|
return c.get(t);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function z(t) {
|
|
40
40
|
const o = c.get(t);
|
|
41
41
|
if (o)
|
|
42
42
|
return Promise.resolve(o);
|
|
43
43
|
let i = u.get(t);
|
|
44
|
-
return i || (i = (
|
|
44
|
+
return i || (i = (D[t] ?? D.en)().then(
|
|
45
45
|
(e) => (c.set(t, e.default), u.delete(t), e.default),
|
|
46
46
|
(e) => {
|
|
47
47
|
throw u.delete(t), e;
|
|
48
48
|
}
|
|
49
49
|
), u.set(t, i)), i;
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const A = ({
|
|
52
52
|
t,
|
|
53
53
|
lang: o = "en",
|
|
54
54
|
overrides: i,
|
|
@@ -56,12 +56,12 @@ const C = ({
|
|
|
56
56
|
onError: e,
|
|
57
57
|
children: a
|
|
58
58
|
}) => {
|
|
59
|
-
const [n, w] =
|
|
59
|
+
const [n, w] = x(
|
|
60
60
|
null
|
|
61
|
-
), d =
|
|
61
|
+
), d = I(e);
|
|
62
62
|
d.current = e;
|
|
63
|
-
const l = c.get(o),
|
|
64
|
-
|
|
63
|
+
const l = c.get(o), L = l ? o : n == null ? void 0 : n.lang, p = l ?? (n == null ? void 0 : n.dict);
|
|
64
|
+
M(() => {
|
|
65
65
|
if (t)
|
|
66
66
|
return;
|
|
67
67
|
const s = c.get(o);
|
|
@@ -70,7 +70,7 @@ const C = ({
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
let m = !0;
|
|
73
|
-
return
|
|
73
|
+
return z(o).then(
|
|
74
74
|
(r) => {
|
|
75
75
|
m && w({ lang: o, dict: r });
|
|
76
76
|
},
|
|
@@ -82,14 +82,15 @@ const C = ({
|
|
|
82
82
|
m = !1;
|
|
83
83
|
};
|
|
84
84
|
}, [o, t]);
|
|
85
|
-
const
|
|
85
|
+
const P = j(() => {
|
|
86
86
|
const s = p && i ? { ...p, ...i } : p ?? i;
|
|
87
87
|
return s ? (m, r) => s[m] ?? r : (m, r) => r;
|
|
88
88
|
}, [p, i]);
|
|
89
|
-
return t ? /* @__PURE__ */ h(
|
|
90
|
-
};
|
|
89
|
+
return t ? /* @__PURE__ */ h(N, { t, lang: o, children: a }) : !p && f !== void 0 ? /* @__PURE__ */ h(k, { children: f }) : /* @__PURE__ */ h(N, { t: P, lang: L ?? "en", children: a });
|
|
90
|
+
}, F = A;
|
|
91
91
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
F as NiceI18nLazyProvider,
|
|
93
|
+
A as NiceI18nProvider,
|
|
94
|
+
C as getLoadedNiceDictionary,
|
|
95
|
+
z as loadNiceDictionary
|
|
95
96
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice2dev/i18n",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shared internationalization infrastructure for Nice2Dev UI libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.mjs",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./all": {
|
|
16
|
+
"types": "./dist/all.d.ts",
|
|
17
|
+
"import": "./dist/all.mjs",
|
|
18
|
+
"require": "./dist/all.cjs"
|
|
14
19
|
}
|
|
15
20
|
},
|
|
16
21
|
"sideEffects": false,
|