@deriv-com/translations 1.3.12 → 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}/constants.d.ts +1 -0
  17. package/dist/{utils → src/utils}/lang-utils.d.ts +1 -1
  18. package/dist/translation-provider-DouO5SpQ.js +34 -0
  19. package/dist/useTranslation-Ws-GUPE_.js +221 -0
  20. package/dist/utils/constants.js +34 -6
  21. package/dist/utils/index.js +5 -14
  22. package/dist/utils/initialize-i18n.js +2 -34
  23. package/dist/utils/lang-utils.js +2 -31
  24. package/dist/utils/localize.js +48 -9
  25. package/dist/utils/otasdk.js +19 -20
  26. package/dist/utils-17GMfKvo.js +50 -0
  27. package/package.json +28 -28
  28. package/dist/constants-BypKaLtI.js +0 -36
  29. package/dist/crc32-BeCcwohL.js +0 -1556
  30. package/dist/i18nInstance-D3STmr24.js +0 -55
  31. package/dist/index.d.ts +0 -4
  32. package/dist/jsx-runtime-oIKL5WiM.js +0 -634
  33. package/dist/useTranslation-CZfO55Z-.js +0 -129
  34. /package/dist/{components → src/components}/index.d.ts +0 -0
  35. /package/dist/{hooks → src/hooks}/index.d.ts +0 -0
  36. /package/dist/{hooks → src/hooks}/use-translations.d.ts +0 -0
  37. /package/dist/{provider → src/provider}/index.d.ts +0 -0
  38. /package/dist/{utils → src/utils}/__tests__/lang-utils.spec.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
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, n) => {
3
+ let r = {};
4
+ for (var i in e) t(r, i, {
5
+ get: e[i],
6
+ enumerable: !0
7
+ });
8
+ return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ }, c = (e, i, o, s) => {
10
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
11
+ get: ((e) => i[e]).bind(null, d),
12
+ enumerable: !(s = n(i, d)) || s.enumerable
13
+ });
14
+ return e;
15
+ }, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
16
+ value: n,
17
+ enumerable: !0
18
+ }) : a, n)), u = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
19
+ if (typeof require < "u") return require.apply(this, arguments);
20
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
21
+ });
22
+ //#endregion
23
+ export { l as i, s as n, u as r, o as t };
@@ -1,4 +1,2 @@
1
- import { default as o } from "./localize.js";
2
- export {
3
- o as Localize
4
- };
1
+ import { t as e } from "../localize-CZ6EZTCG.js";
2
+ export { e as Localize };
@@ -1,386 +1,2 @@
1
- import { I as M, j as q } from "../jsx-runtime-oIKL5WiM.js";
2
- import { createElement as T, isValidElement as D, Fragment as _, cloneElement as J, Children as U, useContext as X, forwardRef as Y } from "react";
3
- import { w as Z, a as V, g as G, u as Q } from "../useTranslation-CZfO55Z-.js";
4
- import { g as B, b as ee } from "../i18nInstance-D3STmr24.js";
5
- function te(e) {
6
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
- }
8
- var I, L;
9
- function ne() {
10
- return L || (L = 1, I = {
11
- area: !0,
12
- base: !0,
13
- br: !0,
14
- col: !0,
15
- embed: !0,
16
- hr: !0,
17
- img: !0,
18
- input: !0,
19
- link: !0,
20
- meta: !0,
21
- param: !0,
22
- source: !0,
23
- track: !0,
24
- wbr: !0
25
- }), I;
26
- }
27
- var se = ne();
28
- const re = /* @__PURE__ */ te(se);
29
- var oe = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
30
- function S(e) {
31
- var t = { type: "tag", name: "", voidElement: !1, attrs: {}, children: [] }, n = e.match(/<\/?([^\s]+?)[/\s>]/);
32
- if (n && (t.name = n[1], (re[n[1]] || e.charAt(e.length - 2) === "/") && (t.voidElement = !0), t.name.startsWith("!--"))) {
33
- var o = e.indexOf("-->");
34
- return { type: "comment", comment: o !== -1 ? e.slice(4, o) : "" };
35
- }
36
- for (var p = new RegExp(oe), s = null; (s = p.exec(e)) !== null; ) if (s[0].trim()) if (s[1]) {
37
- var i = s[1].trim(), a = [i, ""];
38
- i.indexOf("=") > -1 && (a = i.split("=")), t.attrs[a[0]] = a[1], p.lastIndex--;
39
- } else s[2] && (t.attrs[s[2]] = s[3].trim().substring(1, s[3].length - 1));
40
- return t;
41
- }
42
- var ae = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g, ie = /^\s*$/, le = /* @__PURE__ */ Object.create(null);
43
- function W(e, t) {
44
- switch (t.type) {
45
- case "text":
46
- return e + t.content;
47
- case "tag":
48
- return e += "<" + t.name + (t.attrs ? function(n) {
49
- var o = [];
50
- for (var p in n) o.push(p + '="' + n[p] + '"');
51
- return o.length ? " " + o.join(" ") : "";
52
- }(t.attrs) : "") + (t.voidElement ? "/>" : ">"), t.voidElement ? e : e + t.children.reduce(W, "") + "</" + t.name + ">";
53
- case "comment":
54
- return e + "<!--" + t.comment + "-->";
55
- }
56
- }
57
- var pe = { parse: function(e, t) {
58
- t || (t = {}), t.components || (t.components = le);
59
- var n, o = [], p = [], s = -1, i = !1;
60
- if (e.indexOf("<") !== 0) {
61
- var a = e.indexOf("<");
62
- o.push({ type: "text", content: a === -1 ? e : e.substring(0, a) });
63
- }
64
- return e.replace(ae, function(f, c) {
65
- if (i) {
66
- if (f !== "</" + n.name + ">") return;
67
- i = !1;
68
- }
69
- var g, E = f.charAt(1) !== "/", j = f.startsWith("<!--"), b = c + f.length, x = e.charAt(b);
70
- if (j) {
71
- var h = S(f);
72
- return s < 0 ? (o.push(h), o) : ((g = p[s]).children.push(h), o);
73
- }
74
- if (E && (s++, (n = S(f)).type === "tag" && t.components[n.name] && (n.type = "component", i = !0), n.voidElement || i || !x || x === "<" || n.children.push({ type: "text", content: e.slice(b, e.indexOf("<", b)) }), s === 0 && o.push(n), (g = p[s - 1]) && g.children.push(n), p[s] = n), (!E || n.voidElement) && (s > -1 && (n.voidElement || n.name === f.slice(2, -1)) && (s--, n = s === -1 ? o : p[s]), !i && x !== "<" && x)) {
75
- g = s === -1 ? o : p[s].children;
76
- var m = e.indexOf("<", b), u = e.slice(b, m === -1 ? void 0 : m);
77
- ie.test(u) && (u = " "), (m > -1 && s + g.length >= 0 || u !== " ") && g.push({ type: "text", content: u });
78
- }
79
- }), o;
80
- }, stringify: function(e) {
81
- return e.reduce(function(t, n) {
82
- return t + W("", n);
83
- }, "");
84
- } };
85
- function K(e, t) {
86
- if (!e) return !1;
87
- const n = e.props ? e.props.children : e.children;
88
- return t ? n.length > 0 : !!n;
89
- }
90
- function H(e) {
91
- if (!e) return [];
92
- const t = e.props ? e.props.children : e.children;
93
- return e.props && e.props.i18nIsDynamicList ? F(t) : t;
94
- }
95
- function ue(e) {
96
- return Object.prototype.toString.call(e) !== "[object Array]" ? !1 : e.every((t) => D(t));
97
- }
98
- function F(e) {
99
- return Array.isArray(e) ? e : [e];
100
- }
101
- function ce(e, t) {
102
- const n = {
103
- ...t
104
- };
105
- return n.props = Object.assign(e.props, t.props), n;
106
- }
107
- function z(e, t) {
108
- if (!e) return "";
109
- let n = "";
110
- const o = F(e), p = t.transSupportBasicHtmlNodes && t.transKeepBasicHtmlNodesFor ? t.transKeepBasicHtmlNodesFor : [];
111
- return o.forEach((s, i) => {
112
- if (typeof s == "string")
113
- n += `${s}`;
114
- else if (D(s)) {
115
- const a = Object.keys(s.props).length, f = p.indexOf(s.type) > -1, c = s.props.children;
116
- if (!c && f && a === 0)
117
- n += `<${s.type}/>`;
118
- else if (!c && (!f || a !== 0))
119
- n += `<${i}></${i}>`;
120
- else if (s.props.i18nIsDynamicList)
121
- n += `<${i}></${i}>`;
122
- else if (f && a === 1 && typeof c == "string")
123
- n += `<${s.type}>${c}</${s.type}>`;
124
- else {
125
- const g = z(c, t);
126
- n += `<${i}>${g}</${i}>`;
127
- }
128
- } else if (s === null)
129
- V("Trans: the passed in value is invalid - seems you passed in a null child.");
130
- else if (typeof s == "object") {
131
- const {
132
- format: a,
133
- ...f
134
- } = s, c = Object.keys(f);
135
- if (c.length === 1) {
136
- const g = a ? `${c[0]}, ${a}` : c[0];
137
- n += `{{${g}}}`;
138
- } else
139
- V("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", s);
140
- } else
141
- V("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", s);
142
- }), n;
143
- }
144
- function fe(e, t, n, o, p, s) {
145
- if (t === "") return [];
146
- const i = o.transKeepBasicHtmlNodesFor || [], a = t && new RegExp(i.map((m) => `<${m}`).join("|")).test(t);
147
- if (!e && !a && !s) return [t];
148
- const f = {};
149
- function c(m) {
150
- F(m).forEach((l) => {
151
- typeof l != "string" && (K(l) ? c(H(l)) : typeof l == "object" && !D(l) && Object.assign(f, l));
152
- });
153
- }
154
- c(e);
155
- const g = pe.parse(`<0>${t}</0>`), E = {
156
- ...f,
157
- ...p
158
- };
159
- function j(m, u, l) {
160
- const v = H(m), O = x(v, u.children, l);
161
- return ue(v) && O.length === 0 || m.props && m.props.i18nIsDynamicList ? v : O;
162
- }
163
- function b(m, u, l, v, O) {
164
- m.dummy ? (m.children = u, l.push(J(m, {
165
- key: v
166
- }, O ? void 0 : u))) : l.push(...U.map([m], (y) => {
167
- const r = {
168
- ...y.props
169
- };
170
- return delete r.i18nIsDynamicList, T(y.type, {
171
- ...r,
172
- key: v,
173
- ref: y.ref
174
- }, O ? null : u);
175
- }));
176
- }
177
- function x(m, u, l) {
178
- const v = F(m);
179
- return F(u).reduce((y, r, k) => {
180
- const A = r.children && r.children[0] && r.children[0].content && n.services.interpolator.interpolate(r.children[0].content, E, n.language);
181
- if (r.type === "tag") {
182
- let w = v[parseInt(r.name, 10)];
183
- l.length === 1 && !w && (w = l[0][r.name]), w || (w = {});
184
- const d = Object.keys(r.attrs).length !== 0 ? ce({
185
- props: r.attrs
186
- }, w) : w, N = D(d), C = N && K(r, !0) && !r.voidElement, P = a && typeof d == "object" && d.dummy && !N, R = typeof e == "object" && e !== null && Object.hasOwnProperty.call(e, r.name);
187
- if (typeof d == "string") {
188
- const $ = n.services.interpolator.interpolate(d, E, n.language);
189
- y.push($);
190
- } else if (K(d) || C) {
191
- const $ = j(d, r, l);
192
- b(d, $, y, k);
193
- } else if (P) {
194
- const $ = x(v, r.children, l);
195
- b(d, $, y, k);
196
- } else if (Number.isNaN(parseFloat(r.name)))
197
- if (R) {
198
- const $ = j(d, r, l);
199
- b(d, $, y, k, r.voidElement);
200
- } else if (o.transSupportBasicHtmlNodes && i.indexOf(r.name) > -1)
201
- if (r.voidElement)
202
- y.push(T(r.name, {
203
- key: `${r.name}-${k}`
204
- }));
205
- else {
206
- const $ = x(v, r.children, l);
207
- y.push(T(r.name, {
208
- key: `${r.name}-${k}`
209
- }, $));
210
- }
211
- else if (r.voidElement)
212
- y.push(`<${r.name} />`);
213
- else {
214
- const $ = x(v, r.children, l);
215
- y.push(`<${r.name}>${$}</${r.name}>`);
216
- }
217
- else if (typeof d == "object" && !N) {
218
- const $ = r.children[0] ? A : null;
219
- $ && y.push($);
220
- } else
221
- b(d, A, y, k, r.children.length !== 1 || !A);
222
- } else if (r.type === "text") {
223
- const w = o.transWrapTextNodes, d = s ? o.unescape(n.services.interpolator.interpolate(r.content, E, n.language)) : n.services.interpolator.interpolate(r.content, E, n.language);
224
- w ? y.push(T(w, {
225
- key: `${r.name}-${k}`
226
- }, d)) : y.push(d);
227
- }
228
- return y;
229
- }, []);
230
- }
231
- const h = x([{
232
- dummy: !0,
233
- children: e || []
234
- }], g, F(e || []));
235
- return H(h[0]);
236
- }
237
- function me(e) {
238
- let {
239
- children: t,
240
- count: n,
241
- parent: o,
242
- i18nKey: p,
243
- context: s,
244
- tOptions: i = {},
245
- values: a,
246
- defaults: f,
247
- components: c,
248
- ns: g,
249
- i18n: E,
250
- t: j,
251
- shouldUnescape: b,
252
- ...x
253
- } = e;
254
- const h = E || B();
255
- if (!h)
256
- return Z("You will need to pass in an i18next instance by using i18nextReactModule"), t;
257
- const m = j || h.t.bind(h) || ((C) => C);
258
- s && (i.context = s);
259
- const u = {
260
- ...ee(),
261
- ...h.options && h.options.react
262
- };
263
- let l = g || m.ns || h.options && h.options.defaultNS;
264
- l = typeof l == "string" ? [l] : l || ["translation"];
265
- const v = z(t, u), O = f || v || u.transEmptyNodeValue || p, {
266
- hashTransKey: y
267
- } = u, r = p || (y ? y(v || O) : v || O);
268
- h.options && h.options.interpolation && h.options.interpolation.defaultVariables && (a = a && Object.keys(a).length > 0 ? {
269
- ...a,
270
- ...h.options.interpolation.defaultVariables
271
- } : {
272
- ...h.options.interpolation.defaultVariables
273
- });
274
- const k = a ? i.interpolation : {
275
- interpolation: {
276
- ...i.interpolation,
277
- prefix: "#$?",
278
- suffix: "?$#"
279
- }
280
- }, A = {
281
- ...i,
282
- count: n,
283
- ...a,
284
- ...k,
285
- defaultValue: O,
286
- ns: l
287
- }, w = r ? m(r, A) : O;
288
- c && Object.keys(c).forEach((C) => {
289
- const P = c[C];
290
- if (typeof P.type == "function" || !P.props || !P.props.children || w.indexOf(`${C}/>`) < 0 && w.indexOf(`${C} />`) < 0) return;
291
- function R() {
292
- return T(_, null, P);
293
- }
294
- c[C] = T(R);
295
- });
296
- const d = fe(c || t, w, h, u, A, b), N = o !== void 0 ? o : u.defaultTransParent;
297
- return N ? T(N, x, d) : d;
298
- }
299
- function he(e) {
300
- let {
301
- children: t,
302
- count: n,
303
- parent: o,
304
- i18nKey: p,
305
- context: s,
306
- tOptions: i = {},
307
- values: a,
308
- defaults: f,
309
- components: c,
310
- ns: g,
311
- i18n: E,
312
- t: j,
313
- shouldUnescape: b,
314
- ...x
315
- } = e;
316
- const {
317
- i18n: h,
318
- defaultNS: m
319
- } = X(M) || {}, u = E || h || B(), l = j || u && u.t.bind(u);
320
- return me({
321
- children: t,
322
- count: n,
323
- parent: o,
324
- i18nKey: p,
325
- context: s,
326
- tOptions: i,
327
- values: a,
328
- defaults: f,
329
- components: c,
330
- ns: g || l && l.ns || m || u && u.options && u.options.defaultNS,
331
- i18n: u,
332
- t: j,
333
- shouldUnescape: b,
334
- ...x
335
- });
336
- }
337
- function ye(e) {
338
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
339
- return function(o) {
340
- function p(i) {
341
- let {
342
- forwardedRef: a,
343
- ...f
344
- } = i;
345
- const [c, g, E] = Q(e, {
346
- ...f,
347
- keyPrefix: t.keyPrefix
348
- }), j = {
349
- ...f,
350
- t: c,
351
- i18n: g,
352
- tReady: E
353
- };
354
- return t.withRef && a ? j.ref = a : !t.withRef && a && (j.forwardedRef = a), T(o, j);
355
- }
356
- p.displayName = `withI18nextTranslation(${G(o)})`, p.WrappedComponent = o;
357
- const s = (i, a) => T(p, Object.assign({}, i, {
358
- forwardedRef: a
359
- }));
360
- return t.withRef ? Y(s) : p;
361
- };
362
- }
363
- function de({
364
- i18n: e,
365
- i18n_default_text: t,
366
- values: n,
367
- components: o,
368
- options: p,
369
- shouldUnescape: s
370
- }) {
371
- return /* @__PURE__ */ q.jsx(
372
- he,
373
- {
374
- defaults: t,
375
- i18n: e,
376
- values: n,
377
- components: o,
378
- tOptions: p,
379
- shouldUnescape: s
380
- }
381
- );
382
- }
383
- const $e = ye()(de);
384
- export {
385
- $e as default
386
- };
1
+ import { t as e } from "../localize-CZ6EZTCG.js";
2
+ export { e as default };
@@ -1,4 +1,2 @@
1
- import { default as e } from "./use-translations.js";
2
- export {
3
- e as useTranslations
4
- };
1
+ import e from "./use-translations.js";
2
+ export { e as useTranslations };
@@ -1,21 +1,23 @@
1
- import { useContext as i } from "react";
2
- import { TranslationContext as u } from "../provider/translation-provider.js";
3
- import { c } from "../crc32-BeCcwohL.js";
4
- import { u as l } from "../useTranslation-CZfO55Z-.js";
5
- function d() {
6
- const t = i(u), { ready: r, t: a, i18n: o } = l(), e = (n, s = {}) => a(c.str(n).toString(), { defaultValue: n, ...s });
7
- if (!t)
8
- throw new Error(
9
- "useTranslation has to be used within <TranslationContext.Provider>"
10
- );
11
- return {
12
- ready: r,
13
- localize: e,
14
- instance: o,
15
- switchLanguage: t.switchLanguage,
16
- currentLang: t.currentLang
17
- };
1
+ import { t as e } from "../useTranslation-Ws-GUPE_.js";
2
+ import { t } from "../translation-provider-DouO5SpQ.js";
3
+ import { t as n } from "../utils/localize.js";
4
+ import "../provider/index.js";
5
+ import { useContext as r } from "react";
6
+ //#region src/hooks/use-translations.ts
7
+ var i = n();
8
+ function a() {
9
+ let n = r(t), { ready: a, t: o, i18n: s } = e(), c = (e, t = {}) => o((0, i.str)(e).toString(), {
10
+ defaultValue: e,
11
+ ...t
12
+ });
13
+ if (!n) throw Error("useTranslation has to be used within <TranslationContext.Provider>");
14
+ return {
15
+ ready: a,
16
+ localize: c,
17
+ instance: s,
18
+ switchLanguage: n.switchLanguage,
19
+ currentLang: n.currentLang
20
+ };
18
21
  }
19
- export {
20
- d as default
21
- };
22
+ //#endregion
23
+ export { a as default };