@deriv-com/translations 1.3.1 → 1.3.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.
- package/dist/components/index.js +4 -5
- package/dist/components/localize.js +44 -45
- package/dist/{constants-C3Rdpvgf.js → constants-BZU6eCHC.js} +12 -8
- package/dist/hooks/index.js +5 -6
- package/dist/hooks/use-translations.js +7 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/jsx-runtime-ClgrxkDP.js +639 -0
- package/dist/provider/index.js +4 -5
- package/dist/provider/translation-provider.js +15 -18
- package/dist/{useTranslation-DWHGHs02.js → useTranslation-De5US25M.js} +1 -1
- package/dist/utils/__tests__/lang-utils.spec.d.ts +1 -0
- package/dist/utils/constants.d.ts +6 -2
- package/dist/utils/constants.js +1 -1
- package/dist/utils/index.js +6 -5
- package/dist/utils/initialize-i18n.d.ts +8 -2
- package/dist/utils/initialize-i18n.js +21 -17
- package/dist/utils/lang-utils.d.ts +11 -1
- package/dist/utils/lang-utils.js +15 -11
- package/package.json +1 -7
- package/dist/context-f4Bcf4Hs.js +0 -19
package/dist/components/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import "
|
|
1
|
+
import { default as a } from "./localize.js";
|
|
2
|
+
import "../jsx-runtime-ClgrxkDP.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import "../useTranslation-
|
|
5
|
-
import "../context-f4Bcf4Hs.js";
|
|
4
|
+
import "../useTranslation-De5US25M.js";
|
|
6
5
|
import "../i18nInstance-D20fwFYr.js";
|
|
7
6
|
export {
|
|
8
|
-
|
|
7
|
+
a as Localize
|
|
9
8
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createElement as T, isValidElement as D, Fragment as
|
|
3
|
-
import { w as
|
|
4
|
-
import { g as
|
|
5
|
-
import { I as G } from "../context-f4Bcf4Hs.js";
|
|
1
|
+
import { I as W, j as z } from "../jsx-runtime-ClgrxkDP.js";
|
|
2
|
+
import { createElement as T, isValidElement as D, Fragment as M, cloneElement as _, Children as J, useContext as U, forwardRef as X } from "react";
|
|
3
|
+
import { w as Y, a as K, g as Z, u as q } from "../useTranslation-De5US25M.js";
|
|
4
|
+
import { g as G, b as S } from "../i18nInstance-D20fwFYr.js";
|
|
6
5
|
function Q(e) {
|
|
7
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
8
7
|
}
|
|
@@ -24,7 +23,7 @@ var ee = {
|
|
|
24
23
|
};
|
|
25
24
|
const te = /* @__PURE__ */ Q(ee);
|
|
26
25
|
var ne = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
27
|
-
function
|
|
26
|
+
function L(e) {
|
|
28
27
|
var t = { type: "tag", name: "", voidElement: !1, attrs: {}, children: [] }, n = e.match(/<\/?([^\s]+?)[/\s>]/);
|
|
29
28
|
if (n && (t.name = n[1], (te[n[1]] || e.charAt(e.length - 2) === "/") && (t.voidElement = !0), t.name.startsWith("!--"))) {
|
|
30
29
|
var o = e.indexOf("-->");
|
|
@@ -68,12 +67,12 @@ var ae = { parse: function(e, t) {
|
|
|
68
67
|
return;
|
|
69
68
|
i = !1;
|
|
70
69
|
}
|
|
71
|
-
var g, j = f.charAt(1) !== "/",
|
|
72
|
-
if (
|
|
73
|
-
var y =
|
|
70
|
+
var g, j = f.charAt(1) !== "/", E = f.startsWith("<!--"), b = c + f.length, x = e.charAt(b);
|
|
71
|
+
if (E) {
|
|
72
|
+
var y = L(f);
|
|
74
73
|
return s < 0 ? (o.push(y), o) : ((g = p[s]).children.push(y), o);
|
|
75
74
|
}
|
|
76
|
-
if (j && (s++, (n =
|
|
75
|
+
if (j && (s++, (n = L(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), (!j || n.voidElement) && (s > -1 && (n.voidElement || n.name === f.slice(2, -1)) && (s--, n = s === -1 ? o : p[s]), !i && x !== "<" && x)) {
|
|
77
76
|
g = s === -1 ? o : p[s].children;
|
|
78
77
|
var m = e.indexOf("<", b), u = e.slice(b, m === -1 ? void 0 : m);
|
|
79
78
|
re.test(u) && (u = " "), (m > -1 && s + g.length >= 0 || u !== " ") && g.push({ type: "text", content: u });
|
|
@@ -84,13 +83,13 @@ var ae = { parse: function(e, t) {
|
|
|
84
83
|
return t + V("", n);
|
|
85
84
|
}, "");
|
|
86
85
|
} };
|
|
87
|
-
function
|
|
86
|
+
function R(e, t) {
|
|
88
87
|
if (!e)
|
|
89
88
|
return !1;
|
|
90
89
|
const n = e.props ? e.props.children : e.children;
|
|
91
90
|
return t ? n.length > 0 : !!n;
|
|
92
91
|
}
|
|
93
|
-
function
|
|
92
|
+
function H(e) {
|
|
94
93
|
if (!e)
|
|
95
94
|
return [];
|
|
96
95
|
const t = e.props ? e.props.children : e.children;
|
|
@@ -155,7 +154,7 @@ function pe(e, t, n, o, p, s) {
|
|
|
155
154
|
const f = {};
|
|
156
155
|
function c(m) {
|
|
157
156
|
F(m).forEach((l) => {
|
|
158
|
-
typeof l != "string" && (
|
|
157
|
+
typeof l != "string" && (R(l) ? c(H(l)) : typeof l == "object" && !D(l) && Object.assign(f, l));
|
|
159
158
|
});
|
|
160
159
|
}
|
|
161
160
|
c(e);
|
|
@@ -163,14 +162,14 @@ function pe(e, t, n, o, p, s) {
|
|
|
163
162
|
...f,
|
|
164
163
|
...p
|
|
165
164
|
};
|
|
166
|
-
function
|
|
167
|
-
const v =
|
|
165
|
+
function E(m, u, l) {
|
|
166
|
+
const v = H(m), O = x(v, u.children, l);
|
|
168
167
|
return ie(v) && O.length === 0 || m.props && m.props.i18nIsDynamicList ? v : O;
|
|
169
168
|
}
|
|
170
169
|
function b(m, u, l, v, O) {
|
|
171
|
-
m.dummy ? (m.children = u, l.push(
|
|
170
|
+
m.dummy ? (m.children = u, l.push(_(m, {
|
|
172
171
|
key: v
|
|
173
|
-
}, O ? void 0 : u))) : l.push(...
|
|
172
|
+
}, O ? void 0 : u))) : l.push(...J.map([m], (h) => {
|
|
174
173
|
const r = {
|
|
175
174
|
...h.props
|
|
176
175
|
};
|
|
@@ -186,23 +185,23 @@ function pe(e, t, n, o, p, s) {
|
|
|
186
185
|
return F(u).reduce((h, r, k) => {
|
|
187
186
|
const A = r.children && r.children[0] && r.children[0].content && n.services.interpolator.interpolate(r.children[0].content, j, n.language);
|
|
188
187
|
if (r.type === "tag") {
|
|
189
|
-
let
|
|
190
|
-
l.length === 1 && !
|
|
188
|
+
let w = v[parseInt(r.name, 10)];
|
|
189
|
+
l.length === 1 && !w && (w = l[0][r.name]), w || (w = {});
|
|
191
190
|
const d = Object.keys(r.attrs).length !== 0 ? le({
|
|
192
191
|
props: r.attrs
|
|
193
|
-
},
|
|
192
|
+
}, w) : w, N = D(d), C = N && R(r, !0) && !r.voidElement, P = a && typeof d == "object" && d.dummy && !N, I = typeof e == "object" && e !== null && Object.hasOwnProperty.call(e, r.name);
|
|
194
193
|
if (typeof d == "string") {
|
|
195
194
|
const $ = n.services.interpolator.interpolate(d, j, n.language);
|
|
196
195
|
h.push($);
|
|
197
|
-
} else if (
|
|
198
|
-
const $ =
|
|
196
|
+
} else if (R(d) || C) {
|
|
197
|
+
const $ = E(d, r, l);
|
|
199
198
|
b(d, $, h, k);
|
|
200
199
|
} else if (P) {
|
|
201
200
|
const $ = x(v, r.children, l);
|
|
202
201
|
b(d, $, h, k);
|
|
203
202
|
} else if (Number.isNaN(parseFloat(r.name)))
|
|
204
203
|
if (I) {
|
|
205
|
-
const $ =
|
|
204
|
+
const $ = E(d, r, l);
|
|
206
205
|
b(d, $, h, k, r.voidElement);
|
|
207
206
|
} else if (o.transSupportBasicHtmlNodes && i.indexOf(r.name) > -1)
|
|
208
207
|
if (r.voidElement)
|
|
@@ -227,8 +226,8 @@ function pe(e, t, n, o, p, s) {
|
|
|
227
226
|
} else
|
|
228
227
|
b(d, A, h, k, r.children.length !== 1 || !A);
|
|
229
228
|
} else if (r.type === "text") {
|
|
230
|
-
const
|
|
231
|
-
|
|
229
|
+
const w = o.transWrapTextNodes, d = s ? o.unescape(n.services.interpolator.interpolate(r.content, j, n.language)) : n.services.interpolator.interpolate(r.content, j, n.language);
|
|
230
|
+
w ? h.push(T(w, {
|
|
232
231
|
key: `${r.name}-${k}`
|
|
233
232
|
}, d)) : h.push(d);
|
|
234
233
|
}
|
|
@@ -239,7 +238,7 @@ function pe(e, t, n, o, p, s) {
|
|
|
239
238
|
dummy: !0,
|
|
240
239
|
children: e || []
|
|
241
240
|
}], g, F(e || []));
|
|
242
|
-
return
|
|
241
|
+
return H(y[0]);
|
|
243
242
|
}
|
|
244
243
|
function ue(e) {
|
|
245
244
|
let {
|
|
@@ -254,17 +253,17 @@ function ue(e) {
|
|
|
254
253
|
components: c,
|
|
255
254
|
ns: g,
|
|
256
255
|
i18n: j,
|
|
257
|
-
t:
|
|
256
|
+
t: E,
|
|
258
257
|
shouldUnescape: b,
|
|
259
258
|
...x
|
|
260
259
|
} = e;
|
|
261
260
|
const y = j || S();
|
|
262
261
|
if (!y)
|
|
263
|
-
return
|
|
264
|
-
const m =
|
|
262
|
+
return Y("You will need to pass in an i18next instance by using i18nextReactModule"), t;
|
|
263
|
+
const m = E || y.t.bind(y) || ((C) => C);
|
|
265
264
|
s && (i.context = s);
|
|
266
265
|
const u = {
|
|
267
|
-
...
|
|
266
|
+
...G(),
|
|
268
267
|
...y.options && y.options.react
|
|
269
268
|
};
|
|
270
269
|
let l = g || m.ns || y.options && y.options.defaultNS;
|
|
@@ -291,17 +290,17 @@ function ue(e) {
|
|
|
291
290
|
...k,
|
|
292
291
|
defaultValue: O,
|
|
293
292
|
ns: l
|
|
294
|
-
},
|
|
293
|
+
}, w = r ? m(r, A) : O;
|
|
295
294
|
c && Object.keys(c).forEach((C) => {
|
|
296
295
|
const P = c[C];
|
|
297
|
-
if (typeof P.type == "function" || !P.props || !P.props.children ||
|
|
296
|
+
if (typeof P.type == "function" || !P.props || !P.props.children || w.indexOf(`${C}/>`) < 0 && w.indexOf(`${C} />`) < 0)
|
|
298
297
|
return;
|
|
299
298
|
function I() {
|
|
300
|
-
return T(
|
|
299
|
+
return T(M, null, P);
|
|
301
300
|
}
|
|
302
301
|
c[C] = T(I);
|
|
303
302
|
});
|
|
304
|
-
const d = pe(c || t,
|
|
303
|
+
const d = pe(c || t, w, y, u, A, b), N = o !== void 0 ? o : u.defaultTransParent;
|
|
305
304
|
return N ? T(N, x, d) : d;
|
|
306
305
|
}
|
|
307
306
|
function ce(e) {
|
|
@@ -317,14 +316,14 @@ function ce(e) {
|
|
|
317
316
|
components: c,
|
|
318
317
|
ns: g,
|
|
319
318
|
i18n: j,
|
|
320
|
-
t:
|
|
319
|
+
t: E,
|
|
321
320
|
shouldUnescape: b,
|
|
322
321
|
...x
|
|
323
322
|
} = e;
|
|
324
323
|
const {
|
|
325
324
|
i18n: y,
|
|
326
325
|
defaultNS: m
|
|
327
|
-
} =
|
|
326
|
+
} = U(W) || {}, u = j || y || S(), l = E || u && u.t.bind(u);
|
|
328
327
|
return ue({
|
|
329
328
|
children: t,
|
|
330
329
|
count: n,
|
|
@@ -337,7 +336,7 @@ function ce(e) {
|
|
|
337
336
|
components: c,
|
|
338
337
|
ns: g || l && l.ns || m || u && u.options && u.options.defaultNS,
|
|
339
338
|
i18n: u,
|
|
340
|
-
t:
|
|
339
|
+
t: E,
|
|
341
340
|
shouldUnescape: b,
|
|
342
341
|
...x
|
|
343
342
|
});
|
|
@@ -350,22 +349,22 @@ function fe(e) {
|
|
|
350
349
|
forwardedRef: a,
|
|
351
350
|
...f
|
|
352
351
|
} = i;
|
|
353
|
-
const [c, g, j] =
|
|
352
|
+
const [c, g, j] = q(e, {
|
|
354
353
|
...f,
|
|
355
354
|
keyPrefix: t.keyPrefix
|
|
356
|
-
}),
|
|
355
|
+
}), E = {
|
|
357
356
|
...f,
|
|
358
357
|
t: c,
|
|
359
358
|
i18n: g,
|
|
360
359
|
tReady: j
|
|
361
360
|
};
|
|
362
|
-
return t.withRef && a ?
|
|
361
|
+
return t.withRef && a ? E.ref = a : !t.withRef && a && (E.forwardedRef = a), T(o, E);
|
|
363
362
|
}
|
|
364
|
-
p.displayName = `withI18nextTranslation(${
|
|
363
|
+
p.displayName = `withI18nextTranslation(${Z(o)})`, p.WrappedComponent = o;
|
|
365
364
|
const s = (i, a) => T(p, Object.assign({}, i, {
|
|
366
365
|
forwardedRef: a
|
|
367
366
|
}));
|
|
368
|
-
return t.withRef ?
|
|
367
|
+
return t.withRef ? X(s) : p;
|
|
369
368
|
};
|
|
370
369
|
}
|
|
371
370
|
function me({
|
|
@@ -376,7 +375,7 @@ function me({
|
|
|
376
375
|
options: p,
|
|
377
376
|
shouldUnescape: s
|
|
378
377
|
}) {
|
|
379
|
-
return /* @__PURE__ */
|
|
378
|
+
return /* @__PURE__ */ z.jsx(
|
|
380
379
|
ce,
|
|
381
380
|
{
|
|
382
381
|
defaults: t,
|
|
@@ -388,7 +387,7 @@ function me({
|
|
|
388
387
|
}
|
|
389
388
|
);
|
|
390
389
|
}
|
|
391
|
-
const
|
|
390
|
+
const ve = fe()(me);
|
|
392
391
|
export {
|
|
393
|
-
|
|
392
|
+
ve as default
|
|
394
393
|
};
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
const n = Object.freeze({
|
|
2
2
|
ACH: "Translations",
|
|
3
3
|
EN: "English",
|
|
4
|
-
|
|
4
|
+
AR: "العربية",
|
|
5
|
+
BN: "বাংলা",
|
|
5
6
|
DE: "Deutsch",
|
|
7
|
+
ES: "Español",
|
|
6
8
|
FR: "Français",
|
|
7
9
|
ID: "Indonesian",
|
|
8
10
|
IT: "Italiano",
|
|
11
|
+
SW: "Kiswahili",
|
|
9
12
|
KO: "한국어",
|
|
10
13
|
PL: "Polish",
|
|
11
14
|
PT: "Português",
|
|
12
15
|
RU: "Русский",
|
|
16
|
+
SI: "සිංහල",
|
|
17
|
+
TH: "ไทย",
|
|
13
18
|
TR: "Türkçe",
|
|
14
19
|
VI: "Tiếng Việt",
|
|
15
20
|
ZH_CN: "简体中文",
|
|
16
|
-
ZH_TW: "繁體中文"
|
|
17
|
-
|
|
18
|
-
}), e = "i18n_language", s = "EN", t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
21
|
+
ZH_TW: "繁體中文"
|
|
22
|
+
}), s = "i18n_language", e = "EN", t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
19
23
|
__proto__: null,
|
|
20
24
|
ALL_LANGUAGES: n,
|
|
21
|
-
DEFAULT_LANGUAGE:
|
|
22
|
-
LANGUAGE_KEY:
|
|
25
|
+
DEFAULT_LANGUAGE: e,
|
|
26
|
+
LANGUAGE_KEY: s
|
|
23
27
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
24
28
|
export {
|
|
25
29
|
n as A,
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
e as D,
|
|
31
|
+
s as L,
|
|
28
32
|
t as c
|
|
29
33
|
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as f } from "./use-translations.js";
|
|
2
2
|
import "react";
|
|
3
3
|
import "../provider/translation-provider.js";
|
|
4
|
-
import "
|
|
4
|
+
import "../jsx-runtime-ClgrxkDP.js";
|
|
5
5
|
import "../crc32-LCGpXEbE.js";
|
|
6
|
-
import "../constants-
|
|
7
|
-
import "../
|
|
8
|
-
import "../useTranslation-DWHGHs02.js";
|
|
6
|
+
import "../constants-BZU6eCHC.js";
|
|
7
|
+
import "../useTranslation-De5US25M.js";
|
|
9
8
|
import "../i18nInstance-D20fwFYr.js";
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
f as useTranslations
|
|
12
11
|
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { useContext as s } from "react";
|
|
2
2
|
import { TranslationContext as u } from "../provider/translation-provider.js";
|
|
3
3
|
import { c } from "../crc32-LCGpXEbE.js";
|
|
4
|
-
import { u as
|
|
5
|
-
import "
|
|
6
|
-
import "../constants-
|
|
7
|
-
import "../context-f4Bcf4Hs.js";
|
|
4
|
+
import { u as l } from "../useTranslation-De5US25M.js";
|
|
5
|
+
import "../jsx-runtime-ClgrxkDP.js";
|
|
6
|
+
import "../constants-BZU6eCHC.js";
|
|
8
7
|
import "../i18nInstance-D20fwFYr.js";
|
|
9
|
-
function
|
|
10
|
-
const t = s(u), { ready:
|
|
8
|
+
function T() {
|
|
9
|
+
const t = s(u), { ready: r, t: o, i18n: a } = l(), e = (n, i = {}) => o(c.str(n).toString(), { defaultValue: n, ...i });
|
|
11
10
|
if (!t)
|
|
12
11
|
throw new Error(
|
|
13
12
|
"useTranslation has to be used within <TranslationContext.Provider>"
|
|
14
13
|
);
|
|
15
14
|
return {
|
|
16
|
-
ready:
|
|
15
|
+
ready: r,
|
|
17
16
|
localize: e,
|
|
18
17
|
instance: a,
|
|
19
18
|
switchLanguage: t.switchLanguage,
|
|
@@ -21,5 +20,5 @@ function x() {
|
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
export {
|
|
24
|
-
|
|
23
|
+
T as default
|
|
25
24
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { localize, getInitialLanguage, loadIncontextTranslation, initializeI18n } from './utils/index';
|
|
1
|
+
export { localize, getInitialLanguage, loadIncontextTranslation, getAllowedLanguages, initializeI18n, } from './utils/index';
|
|
2
2
|
export { Localize } from './components/index';
|
|
3
3
|
export { useTranslations } from './hooks/index';
|
|
4
4
|
export { TranslationProvider } from './provider/index';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { default as
|
|
3
|
-
import { getInitialLanguage as x, loadIncontextTranslation as
|
|
1
|
+
import { default as p } from "./utils/initialize-i18n.js";
|
|
2
|
+
import { default as s } from "./utils/localize.js";
|
|
3
|
+
import { getAllowedLanguages as u, getInitialLanguage as x, loadIncontextTranslation as g } from "./utils/lang-utils.js";
|
|
4
4
|
import { default as z } from "./components/localize.js";
|
|
5
|
-
import { default as
|
|
5
|
+
import { default as L } from "./hooks/use-translations.js";
|
|
6
6
|
import { default as v } from "./provider/translation-provider.js";
|
|
7
7
|
import "./crc32-LCGpXEbE.js";
|
|
8
8
|
import "./utils/otasdk.js";
|
|
9
9
|
import "./i18nInstance-D20fwFYr.js";
|
|
10
|
-
import "./constants-
|
|
11
|
-
import "
|
|
10
|
+
import "./constants-BZU6eCHC.js";
|
|
11
|
+
import "./jsx-runtime-ClgrxkDP.js";
|
|
12
12
|
import "react";
|
|
13
|
-
import "./useTranslation-
|
|
14
|
-
import "./context-f4Bcf4Hs.js";
|
|
13
|
+
import "./useTranslation-De5US25M.js";
|
|
15
14
|
export {
|
|
16
15
|
z as Localize,
|
|
17
16
|
v as TranslationProvider,
|
|
17
|
+
u as getAllowedLanguages,
|
|
18
18
|
x as getInitialLanguage,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
p as initializeI18n,
|
|
20
|
+
g as loadIncontextTranslation,
|
|
21
|
+
s as localize,
|
|
22
|
+
L as useTranslations
|
|
23
23
|
};
|