@deriv-com/translations 1.4.0 → 1.4.3
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/dist/chunk-CzZxQCTN.js +14 -0
- package/dist/components/index.js +2 -4
- package/dist/components/localize.js +18 -386
- package/dist/hooks/index.js +2 -4
- package/dist/hooks/use-translations.js +23 -20
- package/dist/index.js +9 -16
- package/dist/jsx-runtime-22qKqdB2.js +180 -0
- package/dist/provider/index.js +2 -5
- package/dist/provider/translation-provider.js +26 -46
- package/dist/{components → src/components}/localize.d.ts +2 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/{provider → src/provider}/translation-provider.d.ts +1 -1
- package/dist/{utils → src/utils}/lang-utils.d.ts +1 -1
- package/dist/utils/constants.js +34 -6
- package/dist/utils/index.js +5 -14
- package/dist/utils/initialize-i18n.js +2 -34
- package/dist/utils/lang-utils.js +2 -31
- package/dist/utils/localize.js +48 -9
- package/dist/utils/otasdk.js +19 -20
- package/dist/utils-CvIwp1ax.js +50 -0
- package/package.json +29 -28
- package/dist/constants-HKuDWVkt.js +0 -37
- package/dist/crc32-BeCcwohL.js +0 -1556
- package/dist/i18nInstance-D3STmr24.js +0 -55
- package/dist/index.d.ts +0 -4
- package/dist/jsx-runtime-oIKL5WiM.js +0 -634
- package/dist/useTranslation-CZfO55Z-.js +0 -129
- package/dist/utils/__tests__/lang-utils.spec.d.ts +0 -1
- /package/dist/{components → src/components}/index.d.ts +0 -0
- /package/dist/{hooks → src/hooks}/index.d.ts +0 -0
- /package/dist/{hooks → src/hooks}/use-translations.d.ts +0 -0
- /package/dist/{provider → src/provider}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/constants.d.ts +0 -0
- /package/dist/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/initialize-i18n.d.ts +0 -0
- /package/dist/{utils → src/utils}/localize.d.ts +0 -0
- /package/dist/{utils → src/utils}/otasdk.d.ts +0 -0
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { useContext as P, useState as $, useRef as w, useEffect as x } from "react";
|
|
2
|
-
import { I as k, R as A } from "./jsx-runtime-oIKL5WiM.js";
|
|
3
|
-
import { g as E, b as F } from "./i18nInstance-D3STmr24.js";
|
|
4
|
-
function j() {
|
|
5
|
-
if (console && console.warn) {
|
|
6
|
-
for (var n = arguments.length, e = new Array(n), a = 0; a < n; a++)
|
|
7
|
-
e[a] = arguments[a];
|
|
8
|
-
typeof e[0] == "string" && (e[0] = `react-i18next:: ${e[0]}`), console.warn(...e);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const T = {};
|
|
12
|
-
function I() {
|
|
13
|
-
for (var n = arguments.length, e = new Array(n), a = 0; a < n; a++)
|
|
14
|
-
e[a] = arguments[a];
|
|
15
|
-
typeof e[0] == "string" && T[e[0]] || (typeof e[0] == "string" && (T[e[0]] = /* @__PURE__ */ new Date()), j(...e));
|
|
16
|
-
}
|
|
17
|
-
const z = (n, e) => () => {
|
|
18
|
-
if (n.isInitialized)
|
|
19
|
-
e();
|
|
20
|
-
else {
|
|
21
|
-
const a = () => {
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
n.off("initialized", a);
|
|
24
|
-
}, 0), e();
|
|
25
|
-
};
|
|
26
|
-
n.on("initialized", a);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
function v(n, e, a) {
|
|
30
|
-
n.loadNamespaces(e, z(n, a));
|
|
31
|
-
}
|
|
32
|
-
function R(n, e, a, f) {
|
|
33
|
-
typeof a == "string" && (a = [a]), a.forEach((o) => {
|
|
34
|
-
n.options.ns.indexOf(o) < 0 && n.options.ns.push(o);
|
|
35
|
-
}), n.loadLanguages(e, z(n, f));
|
|
36
|
-
}
|
|
37
|
-
function U(n, e) {
|
|
38
|
-
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
39
|
-
const f = e.languages[0], o = e.options ? e.options.fallbackLng : !1, t = e.languages[e.languages.length - 1];
|
|
40
|
-
if (f.toLowerCase() === "cimode") return !0;
|
|
41
|
-
const g = (y, b) => {
|
|
42
|
-
const r = e.services.backendConnector.state[`${y}|${b}`];
|
|
43
|
-
return r === -1 || r === 2;
|
|
44
|
-
};
|
|
45
|
-
return a.bindI18n && a.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !g(e.isLanguageChangingTo, n) ? !1 : !!(e.hasResourceBundle(f, n) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || g(f, n) && (!o || g(t, n)));
|
|
46
|
-
}
|
|
47
|
-
function B(n, e) {
|
|
48
|
-
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
49
|
-
return !e.languages || !e.languages.length ? (I("i18n.languages were undefined or empty", e.languages), !0) : e.options.ignoreJSONStructure !== void 0 ? e.hasLoadedNamespace(n, {
|
|
50
|
-
lng: a.lng,
|
|
51
|
-
precheck: (o, t) => {
|
|
52
|
-
if (a.bindI18n && a.bindI18n.indexOf("languageChanging") > -1 && o.services.backendConnector.backend && o.isLanguageChangingTo && !t(o.isLanguageChangingTo, n)) return !1;
|
|
53
|
-
}
|
|
54
|
-
}) : U(n, e, a);
|
|
55
|
-
}
|
|
56
|
-
function W(n) {
|
|
57
|
-
return n.displayName || n.name || (typeof n == "string" && n.length > 0 ? n : "Unknown");
|
|
58
|
-
}
|
|
59
|
-
const J = (n, e) => {
|
|
60
|
-
const a = w();
|
|
61
|
-
return x(() => {
|
|
62
|
-
a.current = n;
|
|
63
|
-
}, [n, e]), a.current;
|
|
64
|
-
};
|
|
65
|
-
function Y(n) {
|
|
66
|
-
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
67
|
-
const {
|
|
68
|
-
i18n: a
|
|
69
|
-
} = e, {
|
|
70
|
-
i18n: f,
|
|
71
|
-
defaultNS: o
|
|
72
|
-
} = P(k) || {}, t = a || f || E();
|
|
73
|
-
if (t && !t.reportNamespaces && (t.reportNamespaces = new A()), !t) {
|
|
74
|
-
I("You will need to pass in an i18next instance by using initReactI18next");
|
|
75
|
-
const s = (c, i) => typeof i == "string" ? i : i && typeof i == "object" && typeof i.defaultValue == "string" ? i.defaultValue : Array.isArray(c) ? c[c.length - 1] : c, u = [s, {}, !1];
|
|
76
|
-
return u.t = s, u.i18n = {}, u.ready = !1, u;
|
|
77
|
-
}
|
|
78
|
-
t.options.react && t.options.react.wait !== void 0 && I("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
79
|
-
const g = {
|
|
80
|
-
...F(),
|
|
81
|
-
...t.options.react,
|
|
82
|
-
...e
|
|
83
|
-
}, {
|
|
84
|
-
useSuspense: y,
|
|
85
|
-
keyPrefix: b
|
|
86
|
-
} = g;
|
|
87
|
-
let r = o || t.options && t.options.defaultNS;
|
|
88
|
-
r = typeof r == "string" ? [r] : r || ["translation"], t.reportNamespaces.addUsedNamespaces && t.reportNamespaces.addUsedNamespaces(r);
|
|
89
|
-
const l = (t.isInitialized || t.initializedStoreOnce) && r.every((s) => B(s, t, g));
|
|
90
|
-
function p() {
|
|
91
|
-
return t.getFixedT(e.lng || null, g.nsMode === "fallback" ? r : r[0], b);
|
|
92
|
-
}
|
|
93
|
-
const [L, m] = $(p);
|
|
94
|
-
let h = r.join();
|
|
95
|
-
e.lng && (h = `${e.lng}${h}`);
|
|
96
|
-
const S = J(h), d = w(!0);
|
|
97
|
-
x(() => {
|
|
98
|
-
const {
|
|
99
|
-
bindI18n: s,
|
|
100
|
-
bindI18nStore: u
|
|
101
|
-
} = g;
|
|
102
|
-
d.current = !0, !l && !y && (e.lng ? R(t, e.lng, r, () => {
|
|
103
|
-
d.current && m(p);
|
|
104
|
-
}) : v(t, r, () => {
|
|
105
|
-
d.current && m(p);
|
|
106
|
-
})), l && S && S !== h && d.current && m(p);
|
|
107
|
-
function c() {
|
|
108
|
-
d.current && m(p);
|
|
109
|
-
}
|
|
110
|
-
return s && t && t.on(s, c), u && t && t.store.on(u, c), () => {
|
|
111
|
-
d.current = !1, s && t && s.split(" ").forEach((i) => t.off(i, c)), u && t && u.split(" ").forEach((i) => t.store.off(i, c));
|
|
112
|
-
};
|
|
113
|
-
}, [t, h]);
|
|
114
|
-
const C = w(!0);
|
|
115
|
-
x(() => {
|
|
116
|
-
d.current && !C.current && m(p), C.current = !1;
|
|
117
|
-
}, [t, b]);
|
|
118
|
-
const N = [L, t, l];
|
|
119
|
-
if (N.t = L, N.i18n = t, N.ready = l, l || !l && !y) return N;
|
|
120
|
-
throw new Promise((s) => {
|
|
121
|
-
e.lng ? R(t, e.lng, r, () => s()) : v(t, r, () => s());
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
export {
|
|
125
|
-
j as a,
|
|
126
|
-
W as g,
|
|
127
|
-
Y as u,
|
|
128
|
-
I as w
|
|
129
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|