react-i18next 11.8.12 → 11.9.0
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/README.md +10 -3
- package/dist/amd/react-i18next.js +113 -158
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/Trans.js +3 -1
- package/dist/commonjs/index.js +38 -1
- package/dist/es/Trans.js +3 -1
- package/dist/es/index.js +19 -1
- package/dist/umd/react-i18next.js +113 -158
- package/dist/umd/react-i18next.min.js +1 -1
- package/icu.macro.js +370 -52
- package/package.json +2 -3
- package/react-i18next.js +113 -158
- package/react-i18next.min.js +1 -1
- package/src/Trans.js +6 -4
- package/src/index.js +9 -0
- package/ts4.1/icu.macro.d.ts +104 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
### 11.9.0
|
|
2
|
+
|
|
3
|
+
- typescript/icu macro: add new syntax for interpolation of complex types [1316](https://github.com/i18next/react-i18next/pull/1316) -> [docs for template usage](https://react.i18next.com/misc/using-with-icu-format#tagged-template-for-icu)
|
|
4
|
+
|
|
5
|
+
### 11.8.15
|
|
6
|
+
|
|
7
|
+
- ignore null children in Trans component [1307](https://github.com/i18next/react-i18next/issues/1307)
|
|
8
|
+
|
|
9
|
+
### 11.8.14
|
|
10
|
+
|
|
11
|
+
- update html-parse-stringify to fix uppercase elements in Trans component [1304](https://github.com/i18next/react-i18next/issues/1304)
|
|
12
|
+
|
|
13
|
+
### 11.8.13
|
|
14
|
+
|
|
15
|
+
- 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)
|
|
16
|
+
|
|
1
17
|
### 11.8.12
|
|
2
18
|
|
|
3
19
|
- refactor: remove unneeded object [1286](https://github.com/i18next/react-i18next/pull/1286)
|
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
|
|
19
19
|
### IMPORTANT:
|
|
20
20
|
|
|
21
|
-
Master Branch is the
|
|
21
|
+
Master Branch is the newest version using hooks (>= v10).
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
$ v10.0.0
|
|
24
|
+
$ >=v10.0.0
|
|
25
25
|
npm i react-i18next
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -37,6 +37,7 @@ npm i react-i18next@legacy
|
|
|
37
37
|
### Documentation
|
|
38
38
|
|
|
39
39
|
The documentation is published on [react.i18next.com](https://react.i18next.com)
|
|
40
|
+
The general i18next documentation is published on [www.i18next.com](https://www.i18next.com)
|
|
40
41
|
|
|
41
42
|
### What will my code look like?
|
|
42
43
|
|
|
@@ -102,10 +103,16 @@ $ npm install react-i18next
|
|
|
102
103
|
|
|
103
104
|
- If you don't use a module loader it will be added to `window.reactI18next`
|
|
104
105
|
|
|
106
|
+
### Do you like to read a more complete step by step tutorial?
|
|
107
|
+
|
|
108
|
+
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.
|
|
109
|
+
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.
|
|
110
|
+
|
|
105
111
|
### Examples
|
|
106
112
|
|
|
107
113
|
- [Example react](https://github.com/i18next/react-i18next/tree/master/example/react)
|
|
108
114
|
- [Example react with typescript 4.1+](https://github.com/i18next/react-i18next/tree/master/example/react-typescript4.1)
|
|
115
|
+
- [Example locize.com](https://github.com/i18next/react-i18next/tree/master/example/locize)
|
|
109
116
|
|
|
110
117
|
#### v9 samples
|
|
111
118
|
|
|
@@ -117,7 +124,7 @@ $ npm install react-i18next
|
|
|
117
124
|
- [Example razzle](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/razzle-ssr)
|
|
118
125
|
- [Example hashbase / beaker browser](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/dat)
|
|
119
126
|
- [Example storybook](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/storybook)
|
|
120
|
-
- [Example locize.com](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/locize
|
|
127
|
+
- [Example locize.com](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/locize)
|
|
121
128
|
- [Example test with jest](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/test-jest)
|
|
122
129
|
|
|
123
130
|
### Requirements
|
|
@@ -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;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (!current.voidElement && !inComponent && nextChar && nextChar !== '<') {
|
|
306
|
-
pushTextNode(current.children, html, level, start, options.ignoreWhitespace);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
byTag[current.tagName] = current;
|
|
310
|
-
|
|
311
|
-
if (level === 0) {
|
|
312
|
-
result.push(current);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
parent = arr[level - 1];
|
|
316
|
-
|
|
317
|
-
if (parent) {
|
|
318
|
-
parent.children.push(current);
|
|
274
|
+
return e.replace(r, function (r, s) {
|
|
275
|
+
if (m) {
|
|
276
|
+
if (r !== "</" + a.name + ">") return;
|
|
277
|
+
m = !1;
|
|
319
278
|
}
|
|
320
279
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
level--;
|
|
327
|
-
}
|
|
280
|
+
var u,
|
|
281
|
+
f = "/" !== r.charAt(1),
|
|
282
|
+
h = r.startsWith("\x3c!--"),
|
|
283
|
+
p = s + r.length,
|
|
284
|
+
d = e.charAt(p);
|
|
328
285
|
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
286
|
+
if (h) {
|
|
287
|
+
var v = n(r);
|
|
288
|
+
return l < 0 ? (c.push(v), c) : ((u = o[l]).children.push(v), c);
|
|
332
289
|
}
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
if (!result.length && html.length) {
|
|
337
|
-
pushTextNode(result, html, 0, 0, options.ignoreWhitespace);
|
|
338
|
-
}
|
|
339
290
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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);
|
|
@@ -991,17 +921,42 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
|
|
|
991
921
|
};
|
|
992
922
|
}
|
|
993
923
|
|
|
924
|
+
var date = function date() {
|
|
925
|
+
return '';
|
|
926
|
+
};
|
|
927
|
+
var time = function time() {
|
|
928
|
+
return '';
|
|
929
|
+
};
|
|
930
|
+
var number = function number() {
|
|
931
|
+
return '';
|
|
932
|
+
};
|
|
933
|
+
var select = function select() {
|
|
934
|
+
return '';
|
|
935
|
+
};
|
|
936
|
+
var plural = function plural() {
|
|
937
|
+
return '';
|
|
938
|
+
};
|
|
939
|
+
var selectOrdinal = function selectOrdinal() {
|
|
940
|
+
return '';
|
|
941
|
+
};
|
|
942
|
+
|
|
994
943
|
exports.I18nContext = I18nContext;
|
|
995
944
|
exports.I18nextProvider = I18nextProvider;
|
|
996
945
|
exports.Trans = Trans;
|
|
997
946
|
exports.Translation = Translation;
|
|
998
947
|
exports.composeInitialProps = composeInitialProps;
|
|
948
|
+
exports.date = date;
|
|
999
949
|
exports.getDefaults = getDefaults;
|
|
1000
950
|
exports.getI18n = getI18n;
|
|
1001
951
|
exports.getInitialProps = getInitialProps;
|
|
1002
952
|
exports.initReactI18next = initReactI18next;
|
|
953
|
+
exports.number = number;
|
|
954
|
+
exports.plural = plural;
|
|
955
|
+
exports.select = select;
|
|
956
|
+
exports.selectOrdinal = selectOrdinal;
|
|
1003
957
|
exports.setDefaults = setDefaults;
|
|
1004
958
|
exports.setI18n = setI18n;
|
|
959
|
+
exports.time = time;
|
|
1005
960
|
exports.useSSR = useSSR;
|
|
1006
961
|
exports.useTranslation = useTranslation;
|
|
1007
962
|
exports.withSSR = withSSR;
|
|
@@ -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 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,s,m];if(I.t=O,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 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,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(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[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 c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(m,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),p=s+c.length,m=e.charAt(p);if(f){var h=d(c);return a<0?(r.push(h),r):((u=i[a]).children.push(h),r)}if(l&&(a++,"tag"===(t=d(c)).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===c.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=c(c({},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(c(c({},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 s=a.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(s.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,c(c({},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,c(c({},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=c({},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,c(c({},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&&s.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,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 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,s=r||a||x();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new E),!s){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}s.options.react&&void 0!==s.options.react.wait&&C("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=c(c(c({},j()),s.options.react),t),d=p.useSuspense,m=e||o||s.options&&s.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(m);var g=(s.isInitialized||s.initializedStoreOnce)&&m.every((function(e){return T(e,s,p)}));function h(){return s.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(s,m,(function(){S.current&&w(h)})),e&&s&&s.on(e,t),n&&s&&s.store.on(n,t),function(){S.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,m.join()]);var N=n.useRef(!0);n.useEffect((function(){S.current&&!N.current&&w(h),N.current=!1}),[s]);var I=[b,s,g];if(I.t=b,I.i18n=s,I.ready=g,g)return I;if(!g&&!d)return I;throw new Promise((function(e){A(s,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,c=i||o||x();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=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=s(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=c(c({},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),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(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=s(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:c(c({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},L=c(c(c(c({},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,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=I,e.date=function(){return""},e.getDefaults=j,e.getI18n=x,e.getInitialProps=k,e.initReactI18next=N,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=w,e.setI18n=S,e.time=function(){return""},e.useSSR=K,e.useTranslation=V,e.withSSR=function(){return function(e){function n(n){var r=n.initialI18nStore,i=n.initialLanguage,a=s(n,["initialI18nStore","initialLanguage"]);return K(r,i),t.createElement(e,c({},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=s(i,["forwardedRef"]),l=u(V(e,o),3),f=l[0],p=l[1],d=l[2],m=c(c({},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"]);
|
package/dist/commonjs/index.js
CHANGED
|
@@ -93,6 +93,7 @@ Object.defineProperty(exports, "getInitialProps", {
|
|
|
93
93
|
return _context.getInitialProps;
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
+
exports.selectOrdinal = exports.plural = exports.select = exports.number = exports.time = exports.date = void 0;
|
|
96
97
|
|
|
97
98
|
var _Trans = require("./Trans");
|
|
98
99
|
|
|
@@ -108,4 +109,40 @@ var _withSSR = require("./withSSR");
|
|
|
108
109
|
|
|
109
110
|
var _useSSR = require("./useSSR");
|
|
110
111
|
|
|
111
|
-
var _context = require("./context");
|
|
112
|
+
var _context = require("./context");
|
|
113
|
+
|
|
114
|
+
var date = function date() {
|
|
115
|
+
return '';
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
exports.date = date;
|
|
119
|
+
|
|
120
|
+
var time = function time() {
|
|
121
|
+
return '';
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
exports.time = time;
|
|
125
|
+
|
|
126
|
+
var number = function number() {
|
|
127
|
+
return '';
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
exports.number = number;
|
|
131
|
+
|
|
132
|
+
var select = function select() {
|
|
133
|
+
return '';
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
exports.select = select;
|
|
137
|
+
|
|
138
|
+
var plural = function plural() {
|
|
139
|
+
return '';
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
exports.plural = plural;
|
|
143
|
+
|
|
144
|
+
var selectOrdinal = function selectOrdinal() {
|
|
145
|
+
return '';
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
exports.selectOrdinal = selectOrdinal;
|
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"]);
|
package/dist/es/index.js
CHANGED
|
@@ -5,4 +5,22 @@ export { Translation } from './Translation';
|
|
|
5
5
|
export { I18nextProvider } from './I18nextProvider';
|
|
6
6
|
export { withSSR } from './withSSR';
|
|
7
7
|
export { useSSR } from './useSSR';
|
|
8
|
-
export { I18nContext, initReactI18next, setDefaults, getDefaults, setI18n, getI18n, composeInitialProps, getInitialProps } from './context';
|
|
8
|
+
export { I18nContext, initReactI18next, setDefaults, getDefaults, setI18n, getI18n, composeInitialProps, getInitialProps } from './context';
|
|
9
|
+
export var date = function date() {
|
|
10
|
+
return '';
|
|
11
|
+
};
|
|
12
|
+
export var time = function time() {
|
|
13
|
+
return '';
|
|
14
|
+
};
|
|
15
|
+
export var number = function number() {
|
|
16
|
+
return '';
|
|
17
|
+
};
|
|
18
|
+
export var select = function select() {
|
|
19
|
+
return '';
|
|
20
|
+
};
|
|
21
|
+
export var plural = function plural() {
|
|
22
|
+
return '';
|
|
23
|
+
};
|
|
24
|
+
export var selectOrdinal = function selectOrdinal() {
|
|
25
|
+
return '';
|
|
26
|
+
};
|