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