react-i18next 11.8.11 → 11.8.15
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/CHANGELOG.md +16 -0
- package/dist/amd/react-i18next.js +95 -167
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/Trans.js +3 -1
- package/dist/commonjs/useTranslation.js +7 -9
- package/dist/es/Trans.js +3 -1
- package/dist/es/useTranslation.js +7 -9
- package/dist/umd/react-i18next.js +95 -167
- package/dist/umd/react-i18next.min.js +1 -1
- package/package.json +2 -2
- package/react-i18next.js +95 -167
- package/react-i18next.min.js +1 -1
- package/src/Trans.js +6 -4
- package/src/useTranslation.js +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
### 11.8.15
|
|
2
|
+
|
|
3
|
+
- ignore null children in Trans component [1307](https://github.com/i18next/react-i18next/issues/1307)
|
|
4
|
+
|
|
5
|
+
### 11.8.14
|
|
6
|
+
|
|
7
|
+
- update html-parse-stringify to fix uppercase elements in Trans component [1304](https://github.com/i18next/react-i18next/issues/1304)
|
|
8
|
+
|
|
9
|
+
### 11.8.13
|
|
10
|
+
|
|
11
|
+
- Replace html-parse-stringify2 with html-parse-stringify [1283](https://github.com/i18next/react-i18next/pull/1283) to prevent [CVE-2021-23346](https://github.com/i18next/react-i18next/issues/1275)
|
|
12
|
+
|
|
13
|
+
### 11.8.12
|
|
14
|
+
|
|
15
|
+
- refactor: remove unneeded object [1286](https://github.com/i18next/react-i18next/pull/1286)
|
|
16
|
+
|
|
1
17
|
### 11.8.11
|
|
2
18
|
|
|
3
19
|
- typescript: Bug fixes [1284](https://github.com/i18next/react-i18next/pull/1284)
|
|
@@ -190,9 +190,7 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
190
190
|
"hr": true,
|
|
191
191
|
"img": true,
|
|
192
192
|
"input": true,
|
|
193
|
-
"keygen": true,
|
|
194
193
|
"link": true,
|
|
195
|
-
"menuitem": true,
|
|
196
194
|
"meta": true,
|
|
197
195
|
"param": true,
|
|
198
196
|
"source": true,
|
|
@@ -200,185 +198,115 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
200
198
|
"wbr": true
|
|
201
199
|
};
|
|
202
200
|
|
|
203
|
-
var
|
|
201
|
+
var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
204
202
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
var expectingValueAfterEquals = true;
|
|
211
|
-
var res = {
|
|
212
|
-
type: 'tag',
|
|
213
|
-
name: '',
|
|
214
|
-
voidElement: false,
|
|
203
|
+
function n(n) {
|
|
204
|
+
var r = {
|
|
205
|
+
type: "tag",
|
|
206
|
+
name: "",
|
|
207
|
+
voidElement: !1,
|
|
215
208
|
attrs: {},
|
|
216
209
|
children: []
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (match === '=') {
|
|
220
|
-
expectingValueAfterEquals = true;
|
|
221
|
-
i++;
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (!expectingValueAfterEquals) {
|
|
226
|
-
if (key) {
|
|
227
|
-
res.attrs[key] = key;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
key = match;
|
|
231
|
-
} else {
|
|
232
|
-
if (i === 0) {
|
|
233
|
-
if (voidElements[match] || tag.charAt(tag.length - 2) === '/') {
|
|
234
|
-
res.voidElement = true;
|
|
235
|
-
}
|
|
210
|
+
},
|
|
211
|
+
i = n.match(/<\/?([^\s]+?)[/\s>]/);
|
|
236
212
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
213
|
+
if (i && (r.name = i[1], (voidElements[i[1]] || "/" === n.charAt(n.length - 2)) && (r.voidElement = !0), r.name.startsWith("!--"))) {
|
|
214
|
+
var s = n.indexOf("--\x3e");
|
|
215
|
+
return {
|
|
216
|
+
type: "comment",
|
|
217
|
+
comment: -1 !== s ? n.slice(4, s) : ""
|
|
218
|
+
};
|
|
219
|
+
}
|
|
243
220
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
221
|
+
for (var a = new RegExp(t), c = null; null !== (c = a.exec(n));) {
|
|
222
|
+
if (c[0].trim()) if (c[1]) {
|
|
223
|
+
var o = c[1].trim(),
|
|
224
|
+
l = [o, ""];
|
|
225
|
+
o.indexOf("=") > -1 && (l = o.split("=")), r.attrs[l[0]] = l[1], a.lastIndex--;
|
|
226
|
+
} else c[2] && (r.attrs[c[2]] = c[3].trim().substring(1, c[3].length - 1));
|
|
227
|
+
}
|
|
249
228
|
|
|
250
|
-
|
|
229
|
+
return r;
|
|
230
|
+
}
|
|
251
231
|
|
|
232
|
+
var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,
|
|
233
|
+
i = /^\s*$/,
|
|
234
|
+
s = Object.create(null);
|
|
252
235
|
|
|
236
|
+
function a(e, t) {
|
|
237
|
+
switch (t.type) {
|
|
238
|
+
case "text":
|
|
239
|
+
return e + t.content;
|
|
253
240
|
|
|
254
|
-
|
|
241
|
+
case "tag":
|
|
242
|
+
return e += "<" + t.name + (t.attrs ? function (e) {
|
|
243
|
+
var t = [];
|
|
255
244
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
for (var n in e) {
|
|
246
|
+
t.push(n + '="' + e[n] + '"');
|
|
247
|
+
}
|
|
259
248
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
249
|
+
return t.length ? " " + t.join(" ") : "";
|
|
250
|
+
}(t.attrs) : "") + (t.voidElement ? "/>" : ">"), t.voidElement ? e : e + t.children.reduce(a, "") + "</" + t.name + ">";
|
|
263
251
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
type: 'text',
|
|
267
|
-
content: content
|
|
268
|
-
});
|
|
252
|
+
case "comment":
|
|
253
|
+
return e + "\x3c!--" + t.comment + "--\x3e";
|
|
269
254
|
}
|
|
270
255
|
}
|
|
271
256
|
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
257
|
+
var c = {
|
|
258
|
+
parse: function parse(e, t) {
|
|
259
|
+
t || (t = {}), t.components || (t.components = s);
|
|
260
|
+
var a,
|
|
261
|
+
c = [],
|
|
262
|
+
o = [],
|
|
263
|
+
l = -1,
|
|
264
|
+
m = !1;
|
|
265
|
+
|
|
266
|
+
if (0 !== e.indexOf("<")) {
|
|
267
|
+
var u = e.indexOf("<");
|
|
268
|
+
c.push({
|
|
269
|
+
type: "text",
|
|
270
|
+
content: -1 === u ? e : e.substring(0, u)
|
|
271
|
+
});
|
|
288
272
|
}
|
|
289
273
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
var parent;
|
|
295
|
-
|
|
296
|
-
if (isOpen && !isComment) {
|
|
297
|
-
level++;
|
|
298
|
-
current = parseTag(tag);
|
|
299
|
-
|
|
300
|
-
if (current.type === 'tag' && options.components[current.name]) {
|
|
301
|
-
current.type = 'component';
|
|
302
|
-
inComponent = true;
|
|
274
|
+
return e.replace(r, function (r, s) {
|
|
275
|
+
if (m) {
|
|
276
|
+
if (r !== "</" + a.name + ">") return;
|
|
277
|
+
m = !1;
|
|
303
278
|
}
|
|
304
279
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
280
|
+
var u,
|
|
281
|
+
f = "/" !== r.charAt(1),
|
|
282
|
+
h = r.startsWith("\x3c!--"),
|
|
283
|
+
p = s + r.length,
|
|
284
|
+
d = e.charAt(p);
|
|
308
285
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
result.push(current);
|
|
286
|
+
if (h) {
|
|
287
|
+
var v = n(r);
|
|
288
|
+
return l < 0 ? (c.push(v), c) : ((u = o[l]).children.push(v), c);
|
|
313
289
|
}
|
|
314
290
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
level--;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (!inComponent && nextChar !== '<' && nextChar) {
|
|
330
|
-
parent = level === -1 ? result : arr[level].children;
|
|
331
|
-
pushTextNode(parent, html, level, start, options.ignoreWhitespace);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
if (!result.length && html.length) {
|
|
337
|
-
pushTextNode(result, html, 0, 0, options.ignoreWhitespace);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return result;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
function attrString(attrs) {
|
|
344
|
-
var buff = [];
|
|
345
|
-
|
|
346
|
-
for (var key in attrs) {
|
|
347
|
-
buff.push(key + '="' + attrs[key] + '"');
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (!buff.length) {
|
|
351
|
-
return '';
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return ' ' + buff.join(' ');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function stringify(buff, doc) {
|
|
358
|
-
switch (doc.type) {
|
|
359
|
-
case 'text':
|
|
360
|
-
return buff + doc.content;
|
|
361
|
-
|
|
362
|
-
case 'tag':
|
|
363
|
-
buff += '<' + doc.name + (doc.attrs ? attrString(doc.attrs) : '') + (doc.voidElement ? '/>' : '>');
|
|
364
|
-
|
|
365
|
-
if (doc.voidElement) {
|
|
366
|
-
return buff;
|
|
291
|
+
if (f && (l++, "tag" === (a = n(r)).type && t.components[a.name] && (a.type = "component", m = !0), a.voidElement || m || !d || "<" === d || a.children.push({
|
|
292
|
+
type: "text",
|
|
293
|
+
content: e.slice(p, e.indexOf("<", p))
|
|
294
|
+
}), 0 === l && c.push(a), (u = o[l - 1]) && u.children.push(a), o[l] = a), (!f || a.voidElement) && (l > -1 && (a.voidElement || a.name === r.slice(2, -1)) && (l--, a = -1 === l ? c : o[l]), !m && "<" !== d && d)) {
|
|
295
|
+
u = -1 === l ? c : o[l].children;
|
|
296
|
+
var x = e.indexOf("<", p),
|
|
297
|
+
g = e.slice(p, -1 === x ? void 0 : x);
|
|
298
|
+
i.test(g) && (g = " "), (x > -1 && l + u.length >= 0 || " " !== g) && u.push({
|
|
299
|
+
type: "text",
|
|
300
|
+
content: g
|
|
301
|
+
});
|
|
367
302
|
}
|
|
368
|
-
|
|
369
|
-
|
|
303
|
+
}), c;
|
|
304
|
+
},
|
|
305
|
+
stringify: function stringify(e) {
|
|
306
|
+
return e.reduce(function (e, t) {
|
|
307
|
+
return e + a("", t);
|
|
308
|
+
}, "");
|
|
370
309
|
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
var stringify_1 = function (doc) {
|
|
374
|
-
return doc.reduce(function (token, rootEl) {
|
|
375
|
-
return token + stringify('', rootEl);
|
|
376
|
-
}, '');
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
var htmlParseStringify2 = {
|
|
380
|
-
parse: parse,
|
|
381
|
-
stringify: stringify_1
|
|
382
310
|
};
|
|
383
311
|
|
|
384
312
|
var defaultOptions = {
|
|
@@ -589,6 +517,8 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
589
517
|
var content = nodesToString(childChildren, i18nOptions);
|
|
590
518
|
stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
|
|
591
519
|
}
|
|
520
|
+
} else if (child === null) {
|
|
521
|
+
warn("Trans: the passed in value is invalid - seems you passed in a null child.");
|
|
592
522
|
} else if (_typeof(child) === 'object') {
|
|
593
523
|
var format = child.format,
|
|
594
524
|
clone = _objectWithoutProperties(child, ["format"]);
|
|
@@ -625,7 +555,7 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
625
555
|
|
|
626
556
|
getData(children);
|
|
627
557
|
var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread2(_objectSpread2({}, data), combinedTOpts), i18n.language);
|
|
628
|
-
var ast =
|
|
558
|
+
var ast = c.parse("<0>".concat(interpolatedString, "</0>"));
|
|
629
559
|
|
|
630
560
|
function renderInner(child, node, rootReactNode) {
|
|
631
561
|
var childs = getChildren(child);
|
|
@@ -815,12 +745,10 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
815
745
|
});
|
|
816
746
|
|
|
817
747
|
function getT() {
|
|
818
|
-
return
|
|
819
|
-
t: i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0])
|
|
820
|
-
};
|
|
748
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
|
|
821
749
|
}
|
|
822
750
|
|
|
823
|
-
var _useState = React.useState(getT
|
|
751
|
+
var _useState = React.useState(getT),
|
|
824
752
|
_useState2 = _slicedToArray(_useState, 2),
|
|
825
753
|
t = _useState2[0],
|
|
826
754
|
setT = _useState2[1];
|
|
@@ -833,12 +761,12 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
833
761
|
|
|
834
762
|
if (!ready && !useSuspense) {
|
|
835
763
|
loadNamespaces(i18n, namespaces, function () {
|
|
836
|
-
if (isMounted.current) setT(getT
|
|
764
|
+
if (isMounted.current) setT(getT);
|
|
837
765
|
});
|
|
838
766
|
}
|
|
839
767
|
|
|
840
768
|
function boundReset() {
|
|
841
|
-
if (isMounted.current) setT(getT
|
|
769
|
+
if (isMounted.current) setT(getT);
|
|
842
770
|
}
|
|
843
771
|
|
|
844
772
|
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
@@ -856,13 +784,13 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
856
784
|
var isInitial = React.useRef(true);
|
|
857
785
|
React.useEffect(function () {
|
|
858
786
|
if (isMounted.current && !isInitial.current) {
|
|
859
|
-
setT(getT
|
|
787
|
+
setT(getT);
|
|
860
788
|
}
|
|
861
789
|
|
|
862
790
|
isInitial.current = false;
|
|
863
791
|
}, [i18n]);
|
|
864
|
-
var ret = [t
|
|
865
|
-
ret.t = t
|
|
792
|
+
var ret = [t, i18n, ready];
|
|
793
|
+
ret.t = t;
|
|
866
794
|
ret.i18n = i18n;
|
|
867
795
|
ret.ready = ready;
|
|
868
796
|
if (ready) return ret;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
define(["exports","react"],(function(e,n){"use strict";var t="default"in n?n.default:n;function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function c(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?o(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function s(e,n){if(null==e)return{};var t,r,i=function(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}function u(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,i=!1,a=void 0;try{for(var o,c=e[Symbol.iterator]();!(r=(o=c.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(i)throw a}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return l(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var f={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},p=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,d=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,g=Object.create?Object.create(null):{};function m(e,n,t,r,i){var a=n.indexOf("<",r),o=n.slice(r,-1===a?void 0:a);/^\s*$/.test(o)&&(o=" "),(!i&&a>-1&&t+e.length>=0||" "!==o)&&e.push({type:"text",content:o})}var h,y=function(e,n){n||(n={}),n.components||(n.components=g);var t,r=[],i=-1,a=[],o={},c=!1;return e.replace(d,(function(s,u){if(c){if(s!=="</"+t.name+">")return;c=!1}var l,d="/"!==s.charAt(1),g=0===s.indexOf("\x3c!--"),h=u+s.length,y=e.charAt(h);d&&!g&&(i++,"tag"===(t=function(e){var n,t=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(p,(function(a){if("="===a)return r=!0,void t++;r?0===t?((f[a]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=a):(i.attrs[n]=a.replace(/^['"]|['"]$/g,""),n=void 0):(n&&(i.attrs[n]=n),n=a),t++,r=!1})),i}(s)).type&&n.components[t.name]&&(t.type="component",c=!0),t.voidElement||c||!y||"<"===y||m(t.children,e,i,h,n.ignoreWhitespace),o[t.tagName]=t,0===i&&r.push(t),(l=a[i-1])&&l.children.push(t),a[i]=t),(g||!d||t.voidElement)&&(g||i--,!c&&"<"!==y&&y&&m(l=-1===i?r:a[i].children,e,i,h,n.ignoreWhitespace))})),!r.length&&e.length&&m(r,e,0,0,n.ignoreWhitespace),r},v={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0},b=t.createContext();function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v=c(c({},v),e)}function w(){return v}var j=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function S(e){h=e}function E(){return h}var N={type:"3rdParty",init:function(e){O(e.options.react),S(e)}};function x(e){return function(n){return new Promise((function(t){var r=I();e.getInitialProps?e.getInitialProps(n).then((function(e){t(c(c({},e),r))})):t(r)}))}}function I(){var e=E(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function k(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var P={};function R(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&P[n[0]]||("string"==typeof n[0]&&(P[n[0]]=new Date),k.apply(void 0,n))}function C(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function A(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return R("i18n.languages were undefined or empty",n.languages),!0;var r=n.languages[0],i=!!n.options&&n.options.fallbackLng,a=n.languages[n.languages.length-1];if("cimode"===r.toLowerCase())return!0;var o=function(e,t){var r=n.services.backendConnector.state["".concat(e,"|").concat(t)];return-1===r||2===r};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,e))&&(!!n.hasResourceBundle(r,e)||(!n.services.backendConnector.backend||!(!o(r,e)||i&&!o(a,e))))}function T(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function L(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function z(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function D(e){return Array.isArray(e)?e:[e]}function B(e,n,i,a,o){if(""===n)return[];var s=a.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(s.join("|")).test(n);if(!e&&!u)return[n];var l={};!function e(n){D(n).forEach((function(n){"string"!=typeof n&&(L(n)?e(z(n)):"object"!==r(n)||t.isValidElement(n)||Object.assign(l,n))}))}(e);var f=i.services.interpolator.interpolate(n,c(c({},l),o),i.language),p=y("<0>".concat(f,"</0>"));function d(e,n,r){var i=z(e),a=m(i,n.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return t.isValidElement(e)}))}(i)&&0===a.length?i:a}function g(e,n,r,i,a){e.dummy&&(e.children=n),r.push(t.cloneElement(e,c(c({},e.props),{},{key:i}),a?void 0:n))}function m(n,i,o){var l=D(n);return D(i).reduce((function(n,i,f){var p,h,y,v=i.children&&i.children[0]&&i.children[0].content;if("tag"===i.type){var b=l[parseInt(i.name,10)];!b&&1===o.length&&o[0][i.name]&&(b=o[0][i.name]),b||(b={});var O=0!==Object.keys(i.attrs).length?(p={props:i.attrs},(y=c({},h=b)).props=Object.assign(p.props,h.props),y):b,w=t.isValidElement(O),j=w&&L(i,!0)&&!i.voidElement,S=u&&"object"===r(O)&&O.dummy&&!w,E="object"===r(e)&&null!==e&&Object.hasOwnProperty.call(e,i.name);if("string"==typeof O)n.push(O);else if(L(O)||j){g(O,d(O,i,o),n,f)}else if(S){var N=m(l,i.children,o);n.push(t.cloneElement(O,c(c({},O.props),{},{key:f}),N))}else if(Number.isNaN(parseFloat(i.name))){if(E)g(O,d(O,i,o),n,f,i.voidElement);else if(a.transSupportBasicHtmlNodes&&s.indexOf(i.name)>-1)if(i.voidElement)n.push(t.createElement(i.name,{key:"".concat(i.name,"-").concat(f)}));else{var x=m(l,i.children,o);n.push(t.createElement(i.name,{key:"".concat(i.name,"-").concat(f)},x))}else if(i.voidElement)n.push("<".concat(i.name," />"));else{var I=m(l,i.children,o);n.push("<".concat(i.name,">").concat(I,"</").concat(i.name,">"))}}else if("object"!==r(O)||w)1===i.children.length&&v?n.push(t.cloneElement(O,c(c({},O.props),{},{key:f}),v)):n.push(t.cloneElement(O,c(c({},O.props),{},{key:f})));else{var k=i.children[0]?v:null;k&&n.push(k)}}else"text"===i.type&&n.push(i.content);return n}),[])}return z(m([{dummy:!0,children:e}],p,D(e||[]))[0])}function U(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.i18n,i=n.useContext(b)||{},a=i.i18n,o=i.defaultNS,s=r||a||E();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new j),!s){R("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}s.options.react&&void 0!==s.options.react.wait&&R("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=c(c(c({},w()),s.options.react),t),d=p.useSuspense,g=e||o||s.options&&s.options.defaultNS;g="string"==typeof g?[g]:g||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(g);var m=(s.isInitialized||s.initializedStoreOnce)&&g.every((function(e){return A(e,s,p)}));function h(){return{t:s.getFixedT(null,"fallback"===p.nsMode?g:g[0])}}var y=n.useState(h()),v=u(y,2),O=v[0],S=v[1],N=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){N.current&&S(h())}return N.current=!0,m||d||C(s,g,(function(){N.current&&S(h())})),e&&s&&s.on(e,t),n&&s&&s.store.on(n,t),function(){N.current=!1,e&&s&&e.split(" ").forEach((function(e){return s.off(e,t)})),n&&s&&n.split(" ").forEach((function(e){return s.store.off(e,t)}))}}),[s,g.join()]);var x=n.useRef(!0);n.useEffect((function(){N.current&&!x.current&&S(h()),x.current=!1}),[s]);var I=[O.t,s,m];if(I.t=O.t,I.i18n=s,I.ready=m,m)return I;if(!m&&!d)return I;throw new Promise((function(e){C(s,g,(function(){e()}))}))}function V(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=r.i18n,a=n.useContext(b)||{},o=a.i18n,c=i||o||E();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}e.I18nContext=b,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,i=e.children,a=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(b.Provider,{value:a},i)},e.Trans=function(e){var i=e.children,a=e.count,o=e.parent,u=e.i18nKey,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,y=e.t,v=s(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),O=n.useContext(b)||{},j=O.i18n,S=O.defaultNS,N=h||j||E();if(!N)return R("You will need to pass in an i18next instance by using i18nextReactModule"),i;var x=y||N.t.bind(N)||function(e){return e},I=c(c({},w()),N.options&&N.options.react),P=m||x.ns||S||N.options&&N.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var C=d||function e(n,i){if(!n)return"";var a="",o=D(n),c=i.transKeepBasicHtmlNodesFor||[];return o.forEach((function(n,o){if("string"==typeof n)a+="".concat(n);else if(t.isValidElement(n)){var u=Object.keys(n.props).length,l=c.indexOf(n.type)>-1,f=n.props.children;if(!f&&l&&0===u)a+="<".concat(n.type,"/>");else if(f||l&&0===u)if(n.props.i18nIsDynamicList)a+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)a+="<".concat(n.type,">").concat(f,"</").concat(n.type,">");else{var p=e(f,i);a+="<".concat(o,">").concat(p,"</").concat(o,">")}else a+="<".concat(o,"></").concat(o,">")}else if("object"===r(n)){var d=n.format,g=s(n,["format"]),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];a+="{{".concat(h,"}}")}else k("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",n)}else 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}}.",n)})),a}(i,I)||I.transEmptyNodeValue||u,A=I.hashTransKey,T=u||(A?A(C):C),L=p?f.interpolation:{interpolation:c(c({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},z=c(c(c(c({},f),{},{count:a},p),L),{},{defaultValue:C,ns:P}),U=B(g||i,T?x(T,z):C,N,I,z),V=void 0!==o?o:I.defaultTransParent;return V?t.createElement(V,v,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=u(U(n,s(e,["ns","children"])),3),i=r[0],a=r[1],o=r[2];return t(i,{i18n:a,lng:a.language},o)},e.composeInitialProps=x,e.getDefaults=w,e.getI18n=E,e.getInitialProps=I,e.initReactI18next=N,e.setDefaults=O,e.setI18n=S,e.useSSR=V,e.useTranslation=U,e.withSSR=function(){return function(e){function n(n){var r=n.initialI18nStore,i=n.initialLanguage,a=s(n,["initialI18nStore","initialLanguage"]);return V(r,i),t.createElement(e,c({},a))}return n.getInitialProps=x(e),n.displayName="withI18nextSSR(".concat(T(e),")"),n.WrappedComponent=e,n}},e.withTranslation=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function i(i){var a=i.forwardedRef,o=s(i,["forwardedRef"]),l=u(U(e,o),3),f=l[0],p=l[1],d=l[2],g=c(c({},o),{},{t:f,i18n:p,tReady:d});return n.withRef&&a?g.ref=a:!n.withRef&&a&&(g.forwardedRef=a),t.createElement(r,g)}i.displayName="withI18nextTranslation(".concat(T(r),")"),i.WrappedComponent=r;return n.withRef?t.forwardRef((function(e,n){return t.createElement(i,Object.assign({},e,{forwardedRef:n}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
define(["exports","react"],(function(e,n){"use strict";var t="default"in n?n.default:n;function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?o(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function c(e,n){if(null==e)return{};var t,r,i=function(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}function u(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(t.push(o.value),!n||t.length!==n);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return l(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var f={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},p=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function d(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(f[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var i=new RegExp(p),a=null;null!==(a=i.exec(e));)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,""];o.indexOf("=")>-1&&(s=o.split("=")),n.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(n.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return n}var m=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,h=Object.create(null);var y,v=function(e,n){n||(n={}),n.components||(n.components=h);var t,r=[],i=[],a=-1,o=!1;if(0!==e.indexOf("<")){var s=e.indexOf("<");r.push({type:"text",content:-1===s?e:e.substring(0,s)})}return e.replace(m,(function(s,c){if(o){if(s!=="</"+t.name+">")return;o=!1}var u,l="/"!==s.charAt(1),f=s.startsWith("\x3c!--"),p=c+s.length,m=e.charAt(p);if(f){var h=d(s);return a<0?(r.push(h),r):((u=i[a]).children.push(h),r)}if(l&&(a++,"tag"===(t=d(s)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===a&&r.push(t),(u=i[a-1])&&u.children.push(t),i[a]=t),(!l||t.voidElement)&&(a>-1&&(t.voidElement||t.name===s.slice(2,-1))&&(a--,t=-1===a?r:i[a]),!o&&"<"!==m&&m)){u=-1===a?r:i[a].children;var y=e.indexOf("<",p),v=e.slice(p,-1===y?void 0:y);g.test(v)&&(v=" "),(y>-1&&a+u.length>=0||" "!==v)&&u.push({type:"text",content:v})}})),r},b={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0},O=t.createContext();function w(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b=s(s({},b),e)}function j(){return b}var E=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function S(e){y=e}function x(){return y}var N={type:"3rdParty",init:function(e){w(e.options.react),S(e)}};function I(e){return function(n){return new Promise((function(t){var r=k();e.getInitialProps?e.getInitialProps(n).then((function(e){t(s(s({},e),r))})):t(r)}))}}function k(){var e=x(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function P(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var R={};function C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&R[n[0]]||("string"==typeof n[0]&&(R[n[0]]=new Date),P.apply(void 0,n))}function A(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function T(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return C("i18n.languages were undefined or empty",n.languages),!0;var r=n.languages[0],i=!!n.options&&n.options.fallbackLng,a=n.languages[n.languages.length-1];if("cimode"===r.toLowerCase())return!0;var o=function(e,t){var r=n.services.backendConnector.state["".concat(e,"|").concat(t)];return-1===r||2===r};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,e))&&(!!n.hasResourceBundle(r,e)||(!n.services.backendConnector.backend||!(!o(r,e)||i&&!o(a,e))))}function z(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function L(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function D(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function B(e){return Array.isArray(e)?e:[e]}function U(e,n,i,a,o){if(""===n)return[];var c=a.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(c.join("|")).test(n);if(!e&&!u)return[n];var l={};!function e(n){B(n).forEach((function(n){"string"!=typeof n&&(L(n)?e(D(n)):"object"!==r(n)||t.isValidElement(n)||Object.assign(l,n))}))}(e);var f=i.services.interpolator.interpolate(n,s(s({},l),o),i.language),p=v("<0>".concat(f,"</0>"));function d(e,n,r){var i=D(e),a=g(i,n.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return t.isValidElement(e)}))}(i)&&0===a.length?i:a}function m(e,n,r,i,a){e.dummy&&(e.children=n),r.push(t.cloneElement(e,s(s({},e.props),{},{key:i}),a?void 0:n))}function g(n,i,o){var l=B(n);return B(i).reduce((function(n,i,f){var p,h,y,v=i.children&&i.children[0]&&i.children[0].content;if("tag"===i.type){var b=l[parseInt(i.name,10)];!b&&1===o.length&&o[0][i.name]&&(b=o[0][i.name]),b||(b={});var O=0!==Object.keys(i.attrs).length?(p={props:i.attrs},(y=s({},h=b)).props=Object.assign(p.props,h.props),y):b,w=t.isValidElement(O),j=w&&L(i,!0)&&!i.voidElement,E=u&&"object"===r(O)&&O.dummy&&!w,S="object"===r(e)&&null!==e&&Object.hasOwnProperty.call(e,i.name);if("string"==typeof O)n.push(O);else if(L(O)||j){m(O,d(O,i,o),n,f)}else if(E){var x=g(l,i.children,o);n.push(t.cloneElement(O,s(s({},O.props),{},{key:f}),x))}else if(Number.isNaN(parseFloat(i.name))){if(S)m(O,d(O,i,o),n,f,i.voidElement);else if(a.transSupportBasicHtmlNodes&&c.indexOf(i.name)>-1)if(i.voidElement)n.push(t.createElement(i.name,{key:"".concat(i.name,"-").concat(f)}));else{var N=g(l,i.children,o);n.push(t.createElement(i.name,{key:"".concat(i.name,"-").concat(f)},N))}else if(i.voidElement)n.push("<".concat(i.name," />"));else{var I=g(l,i.children,o);n.push("<".concat(i.name,">").concat(I,"</").concat(i.name,">"))}}else if("object"!==r(O)||w)1===i.children.length&&v?n.push(t.cloneElement(O,s(s({},O.props),{},{key:f}),v)):n.push(t.cloneElement(O,s(s({},O.props),{},{key:f})));else{var k=i.children[0]?v:null;k&&n.push(k)}}else"text"===i.type&&n.push(i.content);return n}),[])}return D(g([{dummy:!0,children:e}],p,B(e||[]))[0])}function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.i18n,i=n.useContext(O)||{},a=i.i18n,o=i.defaultNS,c=r||a||x();if(c&&!c.reportNamespaces&&(c.reportNamespaces=new E),!c){C("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}c.options.react&&void 0!==c.options.react.wait&&C("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=s(s(s({},j()),c.options.react),t),d=p.useSuspense,m=e||o||c.options&&c.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],c.reportNamespaces.addUsedNamespaces&&c.reportNamespaces.addUsedNamespaces(m);var g=(c.isInitialized||c.initializedStoreOnce)&&m.every((function(e){return T(e,c,p)}));function h(){return c.getFixedT(null,"fallback"===p.nsMode?m:m[0])}var y=n.useState(h),v=u(y,2),b=v[0],w=v[1],S=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){S.current&&w(h)}return S.current=!0,g||d||A(c,m,(function(){S.current&&w(h)})),e&&c&&c.on(e,t),n&&c&&c.store.on(n,t),function(){S.current=!1,e&&c&&e.split(" ").forEach((function(e){return c.off(e,t)})),n&&c&&n.split(" ").forEach((function(e){return c.store.off(e,t)}))}}),[c,m.join()]);var N=n.useRef(!0);n.useEffect((function(){S.current&&!N.current&&w(h),N.current=!1}),[c]);var I=[b,c,g];if(I.t=b,I.i18n=c,I.ready=g,g)return I;if(!g&&!d)return I;throw new Promise((function(e){A(c,m,(function(){e()}))}))}function K(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=r.i18n,a=n.useContext(O)||{},o=a.i18n,s=i||o||x();s.options&&s.options.isClone||(e&&!s.initializedStoreOnce&&(s.services.resourceStore.data=e,s.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),s.options.ns),s.initializedStoreOnce=!0,s.isInitialized=!0),t&&!s.initializedLanguageOnce&&(s.changeLanguage(t),s.initializedLanguageOnce=!0))}e.I18nContext=O,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,i=e.children,a=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(O.Provider,{value:a},i)},e.Trans=function(e){var i=e.children,a=e.count,o=e.parent,u=e.i18nKey,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,m=e.components,g=e.ns,h=e.i18n,y=e.t,v=c(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),b=n.useContext(O)||{},w=b.i18n,E=b.defaultNS,S=h||w||x();if(!S)return C("You will need to pass in an i18next instance by using i18nextReactModule"),i;var N=y||S.t.bind(S)||function(e){return e},I=s(s({},j()),S.options&&S.options.react),k=g||N.ns||E||S.options&&S.options.defaultNS;k="string"==typeof k?[k]:k||["translation"];var R=d||function e(n,i){if(!n)return"";var a="",o=B(n),s=i.transKeepBasicHtmlNodesFor||[];return o.forEach((function(n,o){if("string"==typeof n)a+="".concat(n);else if(t.isValidElement(n)){var u=Object.keys(n.props).length,l=s.indexOf(n.type)>-1,f=n.props.children;if(!f&&l&&0===u)a+="<".concat(n.type,"/>");else if(f||l&&0===u)if(n.props.i18nIsDynamicList)a+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)a+="<".concat(n.type,">").concat(f,"</").concat(n.type,">");else{var p=e(f,i);a+="<".concat(o,">").concat(p,"</").concat(o,">")}else a+="<".concat(o,"></").concat(o,">")}else if(null===n)P("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===r(n)){var d=n.format,m=c(n,["format"]),g=Object.keys(m);if(1===g.length){var h=d?"".concat(g[0],", ").concat(d):g[0];a+="{{".concat(h,"}}")}else P("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",n)}else P("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}}.",n)})),a}(i,I)||I.transEmptyNodeValue||u,A=I.hashTransKey,T=u||(A?A(R):R),z=p?f.interpolation:{interpolation:s(s({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},L=s(s(s(s({},f),{},{count:a},p),z),{},{defaultValue:R,ns:k}),D=U(m||i,T?N(T,L):R,S,I,L),V=void 0!==o?o:I.defaultTransParent;return V?t.createElement(V,v,D):D},e.Translation=function(e){var n=e.ns,t=e.children,r=u(V(n,c(e,["ns","children"])),3),i=r[0],a=r[1],o=r[2];return t(i,{i18n:a,lng:a.language},o)},e.composeInitialProps=I,e.getDefaults=j,e.getI18n=x,e.getInitialProps=k,e.initReactI18next=N,e.setDefaults=w,e.setI18n=S,e.useSSR=K,e.useTranslation=V,e.withSSR=function(){return function(e){function n(n){var r=n.initialI18nStore,i=n.initialLanguage,a=c(n,["initialI18nStore","initialLanguage"]);return K(r,i),t.createElement(e,s({},a))}return n.getInitialProps=I(e),n.displayName="withI18nextSSR(".concat(z(e),")"),n.WrappedComponent=e,n}},e.withTranslation=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function i(i){var a=i.forwardedRef,o=c(i,["forwardedRef"]),l=u(V(e,o),3),f=l[0],p=l[1],d=l[2],m=s(s({},o),{},{t:f,i18n:p,tReady:d});return n.withRef&&a?m.ref=a:!n.withRef&&a&&(m.forwardedRef=a),t.createElement(r,m)}i.displayName="withI18nextTranslation(".concat(z(r),")"),i.WrappedComponent=r;return n.withRef?t.forwardRef((function(e,n){return t.createElement(i,Object.assign({},e,{forwardedRef:n}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/dist/commonjs/Trans.js
CHANGED
|
@@ -18,7 +18,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
18
18
|
|
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
20
|
|
|
21
|
-
var _htmlParseStringify = _interopRequireDefault(require("html-parse-
|
|
21
|
+
var _htmlParseStringify = _interopRequireDefault(require("html-parse-stringify"));
|
|
22
22
|
|
|
23
23
|
var _context = require("./context");
|
|
24
24
|
|
|
@@ -83,6 +83,8 @@ function nodesToString(children, i18nOptions) {
|
|
|
83
83
|
var content = nodesToString(childChildren, i18nOptions);
|
|
84
84
|
stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
|
|
85
85
|
}
|
|
86
|
+
} else if (child === null) {
|
|
87
|
+
(0, _utils.warn)("Trans: the passed in value is invalid - seems you passed in a null child.");
|
|
86
88
|
} else if ((0, _typeof2["default"])(child) === 'object') {
|
|
87
89
|
var format = child.format,
|
|
88
90
|
clone = (0, _objectWithoutProperties2["default"])(child, ["format"]);
|
|
@@ -59,12 +59,10 @@ function useTranslation(ns) {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
function getT() {
|
|
62
|
-
return
|
|
63
|
-
t: i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0])
|
|
64
|
-
};
|
|
62
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
var _useState = (0, _react.useState)(getT
|
|
65
|
+
var _useState = (0, _react.useState)(getT),
|
|
68
66
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
69
67
|
t = _useState2[0],
|
|
70
68
|
setT = _useState2[1];
|
|
@@ -77,12 +75,12 @@ function useTranslation(ns) {
|
|
|
77
75
|
|
|
78
76
|
if (!ready && !useSuspense) {
|
|
79
77
|
(0, _utils.loadNamespaces)(i18n, namespaces, function () {
|
|
80
|
-
if (isMounted.current) setT(getT
|
|
78
|
+
if (isMounted.current) setT(getT);
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
function boundReset() {
|
|
85
|
-
if (isMounted.current) setT(getT
|
|
83
|
+
if (isMounted.current) setT(getT);
|
|
86
84
|
}
|
|
87
85
|
|
|
88
86
|
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
@@ -100,13 +98,13 @@ function useTranslation(ns) {
|
|
|
100
98
|
var isInitial = (0, _react.useRef)(true);
|
|
101
99
|
(0, _react.useEffect)(function () {
|
|
102
100
|
if (isMounted.current && !isInitial.current) {
|
|
103
|
-
setT(getT
|
|
101
|
+
setT(getT);
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
isInitial.current = false;
|
|
107
105
|
}, [i18n]);
|
|
108
|
-
var ret = [t
|
|
109
|
-
ret.t = t
|
|
106
|
+
var ret = [t, i18n, ready];
|
|
107
|
+
ret.t = t;
|
|
110
108
|
ret.i18n = i18n;
|
|
111
109
|
ret.ready = ready;
|
|
112
110
|
if (ready) return ret;
|
package/dist/es/Trans.js
CHANGED
|
@@ -7,7 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
8
|
|
|
9
9
|
import React, { useContext } from 'react';
|
|
10
|
-
import HTML from 'html-parse-
|
|
10
|
+
import HTML from 'html-parse-stringify';
|
|
11
11
|
import { getI18n, I18nContext, getDefaults } from './context';
|
|
12
12
|
import { warn, warnOnce } from './utils';
|
|
13
13
|
|
|
@@ -66,6 +66,8 @@ export function nodesToString(children, i18nOptions) {
|
|
|
66
66
|
var content = nodesToString(childChildren, i18nOptions);
|
|
67
67
|
stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
|
|
68
68
|
}
|
|
69
|
+
} else if (child === null) {
|
|
70
|
+
warn("Trans: the passed in value is invalid - seems you passed in a null child.");
|
|
69
71
|
} else if (_typeof(child) === 'object') {
|
|
70
72
|
var format = child.format,
|
|
71
73
|
clone = _objectWithoutProperties(child, ["format"]);
|
|
@@ -46,12 +46,10 @@ export function useTranslation(ns) {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
function getT() {
|
|
49
|
-
return
|
|
50
|
-
t: i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0])
|
|
51
|
-
};
|
|
49
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
var _useState = useState(getT
|
|
52
|
+
var _useState = useState(getT),
|
|
55
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
56
54
|
t = _useState2[0],
|
|
57
55
|
setT = _useState2[1];
|
|
@@ -64,12 +62,12 @@ export function useTranslation(ns) {
|
|
|
64
62
|
|
|
65
63
|
if (!ready && !useSuspense) {
|
|
66
64
|
loadNamespaces(i18n, namespaces, function () {
|
|
67
|
-
if (isMounted.current) setT(getT
|
|
65
|
+
if (isMounted.current) setT(getT);
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
function boundReset() {
|
|
72
|
-
if (isMounted.current) setT(getT
|
|
70
|
+
if (isMounted.current) setT(getT);
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
@@ -87,13 +85,13 @@ export function useTranslation(ns) {
|
|
|
87
85
|
var isInitial = useRef(true);
|
|
88
86
|
useEffect(function () {
|
|
89
87
|
if (isMounted.current && !isInitial.current) {
|
|
90
|
-
setT(getT
|
|
88
|
+
setT(getT);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
isInitial.current = false;
|
|
94
92
|
}, [i18n]);
|
|
95
|
-
var ret = [t
|
|
96
|
-
ret.t = t
|
|
93
|
+
var ret = [t, i18n, ready];
|
|
94
|
+
ret.t = t;
|
|
97
95
|
ret.i18n = i18n;
|
|
98
96
|
ret.ready = ready;
|
|
99
97
|
if (ready) return ret;
|