@deriv-com/translations 1.4.0 → 1.4.2

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 (42) hide show
  1. package/dist/chunk-DeC0fbbY.js +23 -0
  2. package/dist/components/index.js +2 -4
  3. package/dist/components/localize.js +2 -386
  4. package/dist/hooks/index.js +2 -4
  5. package/dist/hooks/use-translations.js +22 -20
  6. package/dist/i18next-DzZwHOzH.js +1202 -0
  7. package/dist/index.js +9 -16
  8. package/dist/initReactI18next-AIGy7ACI.js +52 -0
  9. package/dist/jsx-runtime-BJITdUlL.js +193 -0
  10. package/dist/localize-CZ6EZTCG.js +366 -0
  11. package/dist/provider/index.js +2 -5
  12. package/dist/provider/translation-provider.js +2 -47
  13. package/dist/{components → src/components}/localize.d.ts +2 -1
  14. package/dist/src/index.d.ts +4 -0
  15. package/dist/{provider → src/provider}/translation-provider.d.ts +1 -1
  16. package/dist/{utils → src/utils}/lang-utils.d.ts +1 -1
  17. package/dist/translation-provider-DouO5SpQ.js +34 -0
  18. package/dist/useTranslation-Ws-GUPE_.js +221 -0
  19. package/dist/utils/constants.js +34 -6
  20. package/dist/utils/index.js +5 -14
  21. package/dist/utils/initialize-i18n.js +2 -34
  22. package/dist/utils/lang-utils.js +2 -31
  23. package/dist/utils/localize.js +48 -9
  24. package/dist/utils/otasdk.js +19 -20
  25. package/dist/utils-17GMfKvo.js +50 -0
  26. package/package.json +28 -28
  27. package/dist/constants-HKuDWVkt.js +0 -37
  28. package/dist/crc32-BeCcwohL.js +0 -1556
  29. package/dist/i18nInstance-D3STmr24.js +0 -55
  30. package/dist/index.d.ts +0 -4
  31. package/dist/jsx-runtime-oIKL5WiM.js +0 -634
  32. package/dist/useTranslation-CZfO55Z-.js +0 -129
  33. /package/dist/{components → src/components}/index.d.ts +0 -0
  34. /package/dist/{hooks → src/hooks}/index.d.ts +0 -0
  35. /package/dist/{hooks → src/hooks}/use-translations.d.ts +0 -0
  36. /package/dist/{provider → src/provider}/index.d.ts +0 -0
  37. /package/dist/{utils → src/utils}/__tests__/lang-utils.spec.d.ts +0 -0
  38. /package/dist/{utils → src/utils}/constants.d.ts +0 -0
  39. /package/dist/{utils → src/utils}/index.d.ts +0 -0
  40. /package/dist/{utils → src/utils}/initialize-i18n.d.ts +0 -0
  41. /package/dist/{utils → src/utils}/localize.d.ts +0 -0
  42. /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
- };
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