react-i18next 14.1.2 → 14.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +0 -2
- package/dist/amd/react-i18next.js +104 -126
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/TransWithoutContext.js +43 -45
- package/dist/commonjs/context.js +15 -23
- package/dist/commonjs/defaults.js +6 -7
- package/dist/commonjs/i18nInstance.js +6 -7
- package/dist/commonjs/useSSR.js +4 -3
- package/dist/commonjs/useTranslation.js +11 -14
- package/dist/commonjs/utils.js +22 -19
- package/dist/commonjs/withSSR.js +19 -20
- package/dist/commonjs/withTranslation.js +4 -3
- package/dist/es/TransWithoutContext.js +42 -45
- package/dist/es/context.js +11 -20
- package/dist/es/defaults.js +3 -5
- package/dist/es/i18nInstance.js +3 -5
- package/dist/es/package.json +1 -1
- package/dist/es/useSSR.js +2 -2
- package/dist/es/useTranslation.js +10 -14
- package/dist/es/utils.js +15 -15
- package/dist/es/withSSR.js +17 -19
- package/dist/es/withTranslation.js +2 -2
- package/dist/umd/react-i18next.js +104 -126
- package/dist/umd/react-i18next.min.js +1 -1
- package/package.json +1 -1
- package/react-i18next.js +104 -126
- package/react-i18next.min.js +1 -1
- package/src/TransWithoutContext.js +44 -47
- package/src/context.js +13 -34
- package/src/defaults.js +3 -5
- package/src/i18nInstance.js +3 -5
- package/src/useSSR.js +2 -2
- package/src/useTranslation.js +19 -18
- package/src/utils.js +23 -20
- package/src/withSSR.js +2 -3
- package/src/withTranslation.js +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
### 14.1.3
|
|
2
|
+
|
|
3
|
+
- create a isObject helper function [1766](https://github.com/i18next/react-i18next/pull/1766)
|
|
4
|
+
- optimize nodesToString [1765](https://github.com/i18next/react-i18next/pull/1765)
|
|
5
|
+
- Simplifies hasValidReactChildren [1764](https://github.com/i18next/react-i18next/pull/1764)
|
|
6
|
+
- create a isString helper to avoid code duplication [1763](https://github.com/i18next/react-i18next/pull/1763)
|
|
7
|
+
- use arrow functions where possible [1762](https://github.com/i18next/react-i18next/pull/1762)
|
|
8
|
+
- use the commented out async code [1761](https://github.com/i18next/react-i18next/pull/1761)
|
|
9
|
+
|
|
1
10
|
### 14.1.2
|
|
2
11
|
|
|
3
12
|
- bring back internal interpolationOverride handling for Trans component (if there are childrens), fixes [1754](https://github.com/i18next/react-i18next/issues/1754)
|
package/README.md
CHANGED
|
@@ -60,8 +60,6 @@ The general i18next documentation is published on [www.i18next.com](https://www.
|
|
|
60
60
|
...
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Head over to the **interactive playground** at [codesandbox](https://codesandbox.io/s/1zxox032q).
|
|
64
|
-
|
|
65
63
|
### 📖 What others say
|
|
66
64
|
|
|
67
65
|
- [How to properly internationalize a React application using i18next](https://locize.com/blog/react-i18next/) by Adriano Raiano
|
|
@@ -119,7 +119,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
119
119
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
120
120
|
args[_key] = arguments[_key];
|
|
121
121
|
}
|
|
122
|
-
if (
|
|
122
|
+
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
123
123
|
console.warn(...args);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -128,8 +128,8 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
128
128
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
129
129
|
args[_key2] = arguments[_key2];
|
|
130
130
|
}
|
|
131
|
-
if (
|
|
132
|
-
if (
|
|
131
|
+
if (isString(args[0]) && alreadyWarned[args[0]]) return;
|
|
132
|
+
if (isString(args[0])) alreadyWarned[args[0]] = new Date();
|
|
133
133
|
warn(...args);
|
|
134
134
|
}
|
|
135
135
|
const loadedClb = (i18n, cb) => () => {
|
|
@@ -145,17 +145,17 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
145
145
|
i18n.on('initialized', initialized);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
|
|
148
|
+
const loadNamespaces = (i18n, ns, cb) => {
|
|
149
149
|
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (
|
|
150
|
+
};
|
|
151
|
+
const loadLanguages = (i18n, lng, ns, cb) => {
|
|
152
|
+
if (isString(ns)) ns = [ns];
|
|
153
153
|
ns.forEach(n => {
|
|
154
154
|
if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
|
|
155
155
|
});
|
|
156
156
|
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
|
157
|
-
}
|
|
158
|
-
function
|
|
157
|
+
};
|
|
158
|
+
const oldI18nextHasLoadedNamespace = function (ns, i18n) {
|
|
159
159
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
160
160
|
const lng = i18n.languages[0];
|
|
161
161
|
const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
|
@@ -170,8 +170,8 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
170
170
|
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
|
|
171
171
|
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
172
172
|
return false;
|
|
173
|
-
}
|
|
174
|
-
function
|
|
173
|
+
};
|
|
174
|
+
const hasLoadedNamespace = function (ns, i18n) {
|
|
175
175
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
176
176
|
if (!i18n.languages || !i18n.languages.length) {
|
|
177
177
|
warnOnce('i18n.languages were undefined or empty', i18n.languages);
|
|
@@ -187,10 +187,10 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
187
187
|
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
};
|
|
191
|
+
const getDisplayName = Component => Component.displayName || Component.name || (isString(Component) && Component.length > 0 ? Component : 'Unknown');
|
|
192
|
+
const isString = obj => typeof obj === 'string';
|
|
193
|
+
const isObject = obj => typeof obj === 'object' && obj !== null;
|
|
194
194
|
|
|
195
195
|
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
196
196
|
const htmlEntities = {
|
|
@@ -228,77 +228,70 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
228
228
|
useSuspense: true,
|
|
229
229
|
unescape
|
|
230
230
|
};
|
|
231
|
-
function
|
|
231
|
+
const setDefaults = function () {
|
|
232
232
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
233
233
|
defaultOptions = {
|
|
234
234
|
...defaultOptions,
|
|
235
235
|
...options
|
|
236
236
|
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return defaultOptions;
|
|
240
|
-
}
|
|
237
|
+
};
|
|
238
|
+
const getDefaults = () => defaultOptions;
|
|
241
239
|
|
|
242
240
|
let i18nInstance;
|
|
243
|
-
|
|
241
|
+
const setI18n = instance => {
|
|
244
242
|
i18nInstance = instance;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return i18nInstance;
|
|
248
|
-
}
|
|
243
|
+
};
|
|
244
|
+
const getI18n = () => i18nInstance;
|
|
249
245
|
|
|
250
|
-
|
|
246
|
+
const hasChildren = (node, checkLength) => {
|
|
251
247
|
if (!node) return false;
|
|
252
248
|
const base = node.props ? node.props.children : node.children;
|
|
253
249
|
if (checkLength) return base.length > 0;
|
|
254
250
|
return !!base;
|
|
255
|
-
}
|
|
256
|
-
|
|
251
|
+
};
|
|
252
|
+
const getChildren = node => {
|
|
257
253
|
if (!node) return [];
|
|
258
254
|
const children = node.props ? node.props.children : node.children;
|
|
259
255
|
return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
function getAsArray(data) {
|
|
266
|
-
return Array.isArray(data) ? data : [data];
|
|
267
|
-
}
|
|
268
|
-
function mergeProps(source, target) {
|
|
256
|
+
};
|
|
257
|
+
const hasValidReactChildren = children => Array.isArray(children) && children.every(react.isValidElement);
|
|
258
|
+
const getAsArray = data => Array.isArray(data) ? data : [data];
|
|
259
|
+
const mergeProps = (source, target) => {
|
|
269
260
|
const newTarget = {
|
|
270
261
|
...target
|
|
271
262
|
};
|
|
272
263
|
newTarget.props = Object.assign(source.props, target.props);
|
|
273
264
|
return newTarget;
|
|
274
|
-
}
|
|
275
|
-
|
|
265
|
+
};
|
|
266
|
+
const nodesToString = (children, i18nOptions) => {
|
|
276
267
|
if (!children) return '';
|
|
277
268
|
let stringNode = '';
|
|
278
269
|
const childrenArray = getAsArray(children);
|
|
279
270
|
const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
|
|
280
271
|
childrenArray.forEach((child, childIndex) => {
|
|
281
|
-
if (
|
|
272
|
+
if (isString(child)) {
|
|
282
273
|
stringNode += `${child}`;
|
|
283
274
|
} else if (react.isValidElement(child)) {
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
275
|
+
const {
|
|
276
|
+
props,
|
|
277
|
+
type
|
|
278
|
+
} = child;
|
|
279
|
+
const childPropsCount = Object.keys(props).length;
|
|
280
|
+
const shouldKeepChild = keepArray.indexOf(type) > -1;
|
|
281
|
+
const childChildren = props.children;
|
|
282
|
+
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
283
|
+
stringNode += `<${type}/>`;
|
|
284
|
+
} else if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
292
285
|
stringNode += `<${childIndex}></${childIndex}>`;
|
|
293
|
-
} else if (shouldKeepChild && childPropsCount === 1 &&
|
|
294
|
-
stringNode += `<${
|
|
286
|
+
} else if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
|
|
287
|
+
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
295
288
|
} else {
|
|
296
289
|
const content = nodesToString(childChildren, i18nOptions);
|
|
297
290
|
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
298
291
|
}
|
|
299
292
|
} else if (child === null) {
|
|
300
293
|
warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
|
|
301
|
-
} else if (
|
|
294
|
+
} else if (isObject(child)) {
|
|
302
295
|
const {
|
|
303
296
|
format,
|
|
304
297
|
...clone
|
|
@@ -315,32 +308,32 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
315
308
|
}
|
|
316
309
|
});
|
|
317
310
|
return stringNode;
|
|
318
|
-
}
|
|
319
|
-
|
|
311
|
+
};
|
|
312
|
+
const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => {
|
|
320
313
|
if (targetString === '') return [];
|
|
321
314
|
const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
|
|
322
315
|
const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map(keep => `<${keep}`).join('|')).test(targetString);
|
|
323
316
|
if (!children && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString];
|
|
324
317
|
const data = {};
|
|
325
|
-
|
|
318
|
+
const getData = childs => {
|
|
326
319
|
const childrenArray = getAsArray(childs);
|
|
327
320
|
childrenArray.forEach(child => {
|
|
328
|
-
if (
|
|
329
|
-
if (hasChildren(child)) getData(getChildren(child));else if (
|
|
321
|
+
if (isString(child)) return;
|
|
322
|
+
if (hasChildren(child)) getData(getChildren(child));else if (isObject(child) && !react.isValidElement(child)) Object.assign(data, child);
|
|
330
323
|
});
|
|
331
|
-
}
|
|
324
|
+
};
|
|
332
325
|
getData(children);
|
|
333
326
|
const ast = c.parse(`<0>${targetString}</0>`);
|
|
334
327
|
const opts = {
|
|
335
328
|
...data,
|
|
336
329
|
...combinedTOpts
|
|
337
330
|
};
|
|
338
|
-
|
|
331
|
+
const renderInner = (child, node, rootReactNode) => {
|
|
339
332
|
const childs = getChildren(child);
|
|
340
333
|
const mappedChildren = mapAST(childs, node.children, rootReactNode);
|
|
341
334
|
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren;
|
|
342
|
-
}
|
|
343
|
-
|
|
335
|
+
};
|
|
336
|
+
const pushTranslatedJSX = (child, inner, mem, i, isVoid) => {
|
|
344
337
|
if (child.dummy) {
|
|
345
338
|
child.children = inner;
|
|
346
339
|
mem.push(react.cloneElement(child, {
|
|
@@ -359,8 +352,8 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
359
352
|
}, isVoid ? null : inner);
|
|
360
353
|
}));
|
|
361
354
|
}
|
|
362
|
-
}
|
|
363
|
-
|
|
355
|
+
};
|
|
356
|
+
const mapAST = (reactNode, astNode, rootReactNode) => {
|
|
364
357
|
const reactNodes = getAsArray(reactNode);
|
|
365
358
|
const astNodes = getAsArray(astNode);
|
|
366
359
|
return astNodes.reduce((mem, node, i) => {
|
|
@@ -374,9 +367,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
374
367
|
}, tmp) : tmp;
|
|
375
368
|
const isElement = react.isValidElement(child);
|
|
376
369
|
const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
|
|
377
|
-
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling &&
|
|
378
|
-
const isKnownComponent =
|
|
379
|
-
if (
|
|
370
|
+
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && isObject(child) && child.dummy && !isElement;
|
|
371
|
+
const isKnownComponent = isObject(children) && Object.hasOwnProperty.call(children, node.name);
|
|
372
|
+
if (isString(child)) {
|
|
380
373
|
const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
|
|
381
374
|
mem.push(value);
|
|
382
375
|
} else if (hasChildren(child) || isValidTranslationWithChildren) {
|
|
@@ -406,7 +399,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
406
399
|
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
407
400
|
mem.push(`<${node.name}>${inner}</${node.name}>`);
|
|
408
401
|
}
|
|
409
|
-
} else if (
|
|
402
|
+
} else if (isObject(child) && !isElement) {
|
|
410
403
|
const content = node.children[0] ? translationContent : null;
|
|
411
404
|
if (content) mem.push(content);
|
|
412
405
|
} else {
|
|
@@ -425,13 +418,13 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
425
418
|
}
|
|
426
419
|
return mem;
|
|
427
420
|
}, []);
|
|
428
|
-
}
|
|
421
|
+
};
|
|
429
422
|
const result = mapAST([{
|
|
430
423
|
dummy: true,
|
|
431
424
|
children: children || []
|
|
432
425
|
}], ast, getAsArray(children || []));
|
|
433
426
|
return getChildren(result[0]);
|
|
434
|
-
}
|
|
427
|
+
};
|
|
435
428
|
function Trans$1(_ref) {
|
|
436
429
|
let {
|
|
437
430
|
children,
|
|
@@ -460,7 +453,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
460
453
|
...(i18n.options && i18n.options.react)
|
|
461
454
|
};
|
|
462
455
|
let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
|
|
463
|
-
namespaces =
|
|
456
|
+
namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
|
|
464
457
|
const nodeAsString = nodesToString(children, reactI18nextOptions);
|
|
465
458
|
const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
|
|
466
459
|
const {
|
|
@@ -525,26 +518,17 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
525
518
|
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
|
|
526
519
|
});
|
|
527
520
|
}
|
|
528
|
-
getUsedNamespaces()
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
return
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
...i18nInitialProps
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
} else {
|
|
543
|
-
resolve(i18nInitialProps);
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
function getInitialProps() {
|
|
521
|
+
getUsedNamespaces = () => Object.keys(this.usedNamespaces);
|
|
522
|
+
}
|
|
523
|
+
const composeInitialProps = ForComponent => async ctx => {
|
|
524
|
+
const componentsInitialProps = ForComponent.getInitialProps ? await ForComponent.getInitialProps(ctx) : {};
|
|
525
|
+
const i18nInitialProps = getInitialProps();
|
|
526
|
+
return {
|
|
527
|
+
...componentsInitialProps,
|
|
528
|
+
...i18nInitialProps
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
const getInitialProps = () => {
|
|
548
532
|
const i18n = getI18n();
|
|
549
533
|
const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : [];
|
|
550
534
|
const ret = {};
|
|
@@ -558,7 +542,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
558
542
|
ret.initialI18nStore = initialI18nStore;
|
|
559
543
|
ret.initialLanguage = i18n.language;
|
|
560
544
|
return ret;
|
|
561
|
-
}
|
|
545
|
+
};
|
|
562
546
|
|
|
563
547
|
function Trans(_ref) {
|
|
564
548
|
let {
|
|
@@ -608,13 +592,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
608
592
|
}, [value, ignore]);
|
|
609
593
|
return ref.current;
|
|
610
594
|
};
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
function useMemoizedT(i18n, language, namespace, keyPrefix) {
|
|
615
|
-
return react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
|
|
616
|
-
}
|
|
617
|
-
function useTranslation(ns) {
|
|
595
|
+
const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
|
|
596
|
+
const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
|
|
597
|
+
const useTranslation = function (ns) {
|
|
618
598
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
619
599
|
const {
|
|
620
600
|
i18n: i18nFromProps
|
|
@@ -628,8 +608,8 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
628
608
|
if (!i18n) {
|
|
629
609
|
warnOnce('You will need to pass in an i18next instance by using initReactI18next');
|
|
630
610
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
631
|
-
if (
|
|
632
|
-
if (optsOrDefaultValue &&
|
|
611
|
+
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
612
|
+
if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
633
613
|
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
634
614
|
};
|
|
635
615
|
const retNotReady = [notReadyT, {}, false];
|
|
@@ -649,7 +629,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
649
629
|
keyPrefix
|
|
650
630
|
} = i18nOptions;
|
|
651
631
|
let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
652
|
-
namespaces =
|
|
632
|
+
namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
|
|
653
633
|
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
654
634
|
const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
|
|
655
635
|
const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
@@ -680,9 +660,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
680
660
|
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
681
661
|
setT(getNewT);
|
|
682
662
|
}
|
|
683
|
-
|
|
663
|
+
const boundReset = () => {
|
|
684
664
|
if (isMounted.current) setT(getNewT);
|
|
685
|
-
}
|
|
665
|
+
};
|
|
686
666
|
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
687
667
|
if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
|
|
688
668
|
return () => {
|
|
@@ -709,9 +689,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
709
689
|
loadNamespaces(i18n, namespaces, () => resolve());
|
|
710
690
|
}
|
|
711
691
|
});
|
|
712
|
-
}
|
|
692
|
+
};
|
|
713
693
|
|
|
714
|
-
function
|
|
694
|
+
const withTranslation = function (ns) {
|
|
715
695
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
716
696
|
return function Extend(WrappedComponent) {
|
|
717
697
|
function I18nextWithTranslation(_ref) {
|
|
@@ -743,7 +723,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
743
723
|
}));
|
|
744
724
|
return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
|
|
745
725
|
};
|
|
746
|
-
}
|
|
726
|
+
};
|
|
747
727
|
|
|
748
728
|
function Translation(props) {
|
|
749
729
|
const {
|
|
@@ -773,7 +753,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
773
753
|
}, children);
|
|
774
754
|
}
|
|
775
755
|
|
|
776
|
-
function
|
|
756
|
+
const useSSR = function (initialI18nStore, initialLanguage) {
|
|
777
757
|
let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
778
758
|
const {
|
|
779
759
|
i18n: i18nFromProps
|
|
@@ -798,27 +778,25 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
798
778
|
i18n.changeLanguage(initialLanguage);
|
|
799
779
|
i18n.initializedLanguageOnce = true;
|
|
800
780
|
}
|
|
801
|
-
}
|
|
781
|
+
};
|
|
802
782
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
};
|
|
821
|
-
}
|
|
783
|
+
const withSSR = () => function Extend(WrappedComponent) {
|
|
784
|
+
function I18nextWithSSR(_ref) {
|
|
785
|
+
let {
|
|
786
|
+
initialI18nStore,
|
|
787
|
+
initialLanguage,
|
|
788
|
+
...rest
|
|
789
|
+
} = _ref;
|
|
790
|
+
useSSR(initialI18nStore, initialLanguage);
|
|
791
|
+
return react.createElement(WrappedComponent, {
|
|
792
|
+
...rest
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent);
|
|
796
|
+
I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`;
|
|
797
|
+
I18nextWithSSR.WrappedComponent = WrappedComponent;
|
|
798
|
+
return I18nextWithSSR;
|
|
799
|
+
};
|
|
822
800
|
|
|
823
801
|
const date = () => '';
|
|
824
802
|
const time = () => '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
define(["exports","react"],(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=t({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}),i=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function r(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[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 o=new RegExp(i),a=null;null!==(a=o.exec(e));)if(a[0].trim())if(a[1]){var c=a[1].trim(),l=[c,""];c.indexOf("=")>-1&&(l=c.split("=")),n.attrs[l[0]]=l[1],o.lastIndex--}else a[2]&&(n.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return n}var o=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,a=/^\s*$/,c=Object.create(null);function l(e,n){switch(n.type){case"text":return e+n.content;case"tag":return e+="<"+n.name+(n.attrs?function(e){var n=[];for(var t in e)n.push(t+'="'+e[t]+'"');return n.length?" "+n.join(" "):""}(n.attrs):"")+(n.voidElement?"/>":">"),n.voidElement?e:e+n.children.reduce(l,"")+"</"+n.name+">";case"comment":return e+"\x3c!--"+n.comment+"--\x3e"}}var u={parse:function(e,n){n||(n={}),n.components||(n.components=c);var t,s=[],i=[],l=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(o,(function(o,c){if(u){if(o!=="</"+t.name+">")return;u=!1}var p,d="/"!==o.charAt(1),f=o.startsWith("\x3c!--"),g=c+o.length,m=e.charAt(g);if(f){var h=r(o);return l<0?(s.push(h),s):((p=i[l]).children.push(h),s)}if(d&&(l++,"tag"===(t=r(o)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!m||"<"===m||t.children.push({type:"text",content:e.slice(g,e.indexOf("<",g))}),0===l&&s.push(t),(p=i[l-1])&&p.children.push(t),i[l]=t),(!d||t.voidElement)&&(l>-1&&(t.voidElement||t.name===o.slice(2,-1))&&(l--,t=-1===l?s:i[l]),!u&&"<"!==m&&m)){p=-1===l?s:i[l].children;var y=e.indexOf("<",g),b=e.slice(g,-1===y?void 0:y);a.test(b)&&(b=" "),(y>-1&&l+p.length>=0||" "!==b)&&p.push({type:"text",content:b})}})),s},stringify:function(e){return e.reduce((function(e,n){return e+l("",n)}),"")}};function p(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&(n[0]=`react-i18next:: ${n[0]}`),console.warn(...n)}}const d={};function f(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&d[n[0]]||("string"==typeof n[0]&&(d[n[0]]=new Date),p(...n))}const g=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}};function m(e,n,t){e.loadNamespaces(n,g(e,t))}function h(e,n,t,s){"string"==typeof t&&(t=[t]),t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,g(e,s))}function y(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}const b=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,v={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},x=e=>v[e];let E,N={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(b,x)};function O(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N={...N,...e}}function $(){return N}function w(e){E=e}function k(){return E}function I(e,n){if(!e)return!1;const t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function S(e){if(!e)return[];const n=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?j(n):n}function j(e){return Array.isArray(e)?e:[e]}function C(e,t){if(!e)return"";let s="";const i=j(e),r=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return i.forEach(((e,i)=>{if("string"==typeof e)s+=`${e}`;else if(n.isValidElement(e)){const n=Object.keys(e.props).length,o=r.indexOf(e.type)>-1,a=e.props.children;if(!a&&o&&0===n)s+=`<${e.type}/>`;else if(a||o&&0===n)if(e.props.i18nIsDynamicList)s+=`<${i}></${i}>`;else if(o&&1===n&&"string"==typeof a)s+=`<${e.type}>${a}</${e.type}>`;else{const e=C(a,t);s+=`<${i}>${e}</${i}>`}else s+=`<${i}></${i}>`}else if(null===e)p("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"==typeof e){const{format:n,...t}=e,i=Object.keys(t);if(1===i.length){const e=n?`${i[0]}, ${n}`:i[0];s+=`{{${e}}}`}else p("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}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}}.",e)})),s}function R(e,t,s,i,r,o){if(""===t)return[];const a=i.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(a.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!c&&!o)return[t];const l={};!function e(t){j(t).forEach((t=>{"string"!=typeof t&&(I(t)?e(S(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))}))}(e);const p=u.parse(`<0>${t}</0>`),d={...l,...r};function f(e,t,s){const i=S(e),r=m(i,t.children,s);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((e=>n.isValidElement(e)))}(i)&&0===r.length||e.props&&e.props.i18nIsDynamicList?i:r}function g(e,t,s,i,r){e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:i},r?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:i,ref:e.ref},r?null:t)})))}function m(t,r,l){const u=j(t);return j(r).reduce(((t,r,p)=>{const h=r.children&&r.children[0]&&r.children[0].content&&s.services.interpolator.interpolate(r.children[0].content,d,s.language);if("tag"===r.type){let o=u[parseInt(r.name,10)];1!==l.length||o||(o=l[0][r.name]),o||(o={});const y=0!==Object.keys(r.attrs).length?function(e,n){const t={...n};return t.props=Object.assign(e.props,n.props),t}({props:r.attrs},o):o,b=n.isValidElement(y),v=b&&I(r,!0)&&!r.voidElement,x=c&&"object"==typeof y&&y.dummy&&!b,E="object"==typeof e&&null!==e&&Object.hasOwnProperty.call(e,r.name);if("string"==typeof y){const e=s.services.interpolator.interpolate(y,d,s.language);t.push(e)}else if(I(y)||v){g(y,f(y,r,l),t,p)}else if(x){g(y,m(u,r.children,l),t,p)}else if(Number.isNaN(parseFloat(r.name)))if(E){g(y,f(y,r,l),t,p,r.voidElement)}else if(i.transSupportBasicHtmlNodes&&a.indexOf(r.name)>-1)if(r.voidElement)t.push(n.createElement(r.name,{key:`${r.name}-${p}`}));else{const e=m(u,r.children,l);t.push(n.createElement(r.name,{key:`${r.name}-${p}`},e))}else if(r.voidElement)t.push(`<${r.name} />`);else{const e=m(u,r.children,l);t.push(`<${r.name}>${e}</${r.name}>`)}else if("object"!=typeof y||b)g(y,h,t,p,1!==r.children.length||!h);else{const e=r.children[0]?h:null;e&&t.push(e)}}else if("text"===r.type){const e=i.transWrapTextNodes,a=o?i.unescape(s.services.interpolator.interpolate(r.content,d,s.language)):s.services.interpolator.interpolate(r.content,d,s.language);e?t.push(n.createElement(e,{key:`${r.name}-${p}`},a)):t.push(a)}return t}),[])}return S(m([{dummy:!0,children:e||[]}],p,j(e||[]))[0])}function L(e){let{children:t,count:s,parent:i,i18nKey:r,context:o,tOptions:a={},values:c,defaults:l,components:u,ns:p,i18n:d,t:g,shouldUnescape:m,...h}=e;const y=d||k();if(!y)return f("You will need to pass in an i18next instance by using i18nextReactModule"),t;const b=g||y.t.bind(y)||(e=>e),v={...$(),...y.options&&y.options.react};let x=p||b.ns||y.options&&y.options.defaultNS;x="string"==typeof x?[x]:x||["translation"];const E=C(t,v),N=l||E||v.transEmptyNodeValue||r,{hashTransKey:O}=v,w=r||(O?O(E||N):E||N);y.options&&y.options.interpolation&&y.options.interpolation.defaultVariables&&(c=c&&Object.keys(c).length>0?{...c,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables});const I=c||void 0!==s||!t?a.interpolation:{interpolation:{...a.interpolation,prefix:"#$?",suffix:"?$#"}},S={...a,context:o||a.context,count:s,...c,...I,defaultValue:N,ns:x},j=w?b(w,S):N;u&&Object.keys(u).forEach((e=>{const t=u[e];"function"==typeof t.type||!t.props||!t.props.children||j.indexOf(`${e}/>`)<0&&j.indexOf(`${e} />`)<0||(u[e]=n.createElement((function(){return n.createElement(n.Fragment,null,t)})))}));const L=R(u||t,j,y,v,S,m),T=void 0!==i?i:v.defaultTransParent;return T?n.createElement(T,h,L):L}const T={type:"3rdParty",init(e){O(e.options.react),w(e)}},P=n.createContext();class V{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function z(e){return n=>new Promise((t=>{const s=A();e.getInitialProps?e.getInitialProps(n).then((e=>{t({...e,...s})})):t(s)}))}function A(){const e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},s={};return e.languages.forEach((t=>{s[t]={},n.forEach((n=>{s[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=s,t.initialLanguage=e.language,t}const B=(e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=t?s.current:e}),[e,t]),s.current};function F(e,n,t,s){return e.getFixedT(n,t,s)}function U(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:i,defaultNS:r}=n.useContext(P)||{},o=s||i||k();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new V),!o){f("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>"string"==typeof n?n:n&&"object"==typeof n&&"string"==typeof n.defaultValue?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}o.options.react&&void 0!==o.options.react.wait&&f("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...$(),...o.options.react,...t},{useSuspense:c,keyPrefix:l}=a;let u=e||r||o.options&&o.options.defaultNS;u="string"==typeof u?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const p=(o.isInitialized||o.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?void 0!==n.options.ignoreJSONStructure?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=n.languages[0],i=!!n.options&&n.options.fallbackLng,r=n.languages[n.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(e,t)=>{const s=n.services.backendConnector.state[`${e}|${t}`];return-1===s||2===s};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,e)||!n.hasResourceBundle(s,e)&&n.services.backendConnector.backend&&(!n.options.resources||n.options.partialBundledLanguages)&&(!o(s,e)||i&&!o(r,e)))}(e,n,t):(f("i18n.languages were undefined or empty",n.languages),!0)}(e,o,a))),d=function(e,t,s,i){return n.useCallback(F(e,t,s,i),[e,t,s,i])}(o,t.lng||null,"fallback"===a.nsMode?u:u[0],l),g=()=>d,y=()=>F(o,t.lng||null,"fallback"===a.nsMode?u:u[0],l),[b,v]=n.useState(g);let x=u.join();t.lng&&(x=`${t.lng}${x}`);const E=B(x),N=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=a;function s(){N.current&&v(y)}return N.current=!0,p||c||(t.lng?h(o,t.lng,u,(()=>{N.current&&v(y)})):m(o,u,(()=>{N.current&&v(y)}))),p&&E&&E!==x&&N.current&&v(y),e&&o&&o.on(e,s),n&&o&&o.store.on(n,s),()=>{N.current=!1,e&&o&&e.split(" ").forEach((e=>o.off(e,s))),n&&o&&n.split(" ").forEach((e=>o.store.off(e,s)))}}),[o,x]),n.useEffect((()=>{N.current&&p&&v(g)}),[o,l,p]);const O=[b,o,p];if(O.t=b,O.i18n=o,O.ready=p,p)return O;if(!p&&!c)return O;throw new Promise((e=>{t.lng?h(o,t.lng,u,(()=>e())):m(o,u,(()=>e()))}))}function K(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:i}=s,{i18n:r}=n.useContext(P)||{},o=i||r||k();o.options&&o.options.isClone||(e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),o.options.ns),o.initializedStoreOnce=!0,o.isInitialized=!0),t&&!o.initializedLanguageOnce&&(o.changeLanguage(t),o.initializedLanguageOnce=!0))}e.I18nContext=P,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:i}=e;const r=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(P.Provider,{value:r},i)},e.Trans=function(e){let{children:t,count:s,parent:i,i18nKey:r,context:o,tOptions:a={},values:c,defaults:l,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...m}=e;const{i18n:h,defaultNS:y}=n.useContext(P)||{},b=d||h||k(),v=f||b&&b.t.bind(b);return L({children:t,count:s,parent:i,i18nKey:r,context:o,tOptions:a,values:c,defaults:l,components:u,ns:p||v&&v.ns||y||b&&b.options&&b.options.defaultNS,i18n:b,t:f,shouldUnescape:g,...m})},e.TransWithoutContext=L,e.Translation=function(e){const{ns:n,children:t,...s}=e,[i,r,o]=U(n,s);return t(i,{i18n:r,lng:r.language},o)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=$,e.getI18n=k,e.getInitialProps=A,e.initReactI18next=T,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=K,e.useTranslation=U,e.withSSR=function(){return function(e){function t(t){let{initialI18nStore:s,initialLanguage:i,...r}=t;return K(s,i),n.createElement(e,{...r})}return t.getInitialProps=z(e),t.displayName=`withI18nextSSR(${y(e)})`,t.WrappedComponent=e,t}},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function i(i){let{forwardedRef:r,...o}=i;const[a,c,l]=U(e,{...o,keyPrefix:t.keyPrefix}),u={...o,t:a,i18n:c,tReady:l};return t.withRef&&r?u.ref=r:!t.withRef&&r&&(u.forwardedRef=r),n.createElement(s,u)}i.displayName=`withI18nextTranslation(${y(s)})`,i.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(i,Object.assign({},e,{forwardedRef:t})))):i}}}));
|
|
1
|
+
define(["exports","react"],(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=t({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}),a=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var r=new RegExp(a),o=null;null!==(o=r.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],r.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],a=[],c=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(r,(function(r,l){if(u){if(r!=="</"+t.name+">")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),g=l+r.length,h=e.charAt(g);if(f){var m=i(r);return c<0?(s.push(m),s):((p=a[c]).children.push(m),s)}if(d&&(c++,"tag"===(t=i(r)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!h||"<"===h||t.children.push({type:"text",content:e.slice(g,e.indexOf("<",g))}),0===c&&s.push(t),(p=a[c-1])&&p.children.push(t),a[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===r.slice(2,-1))&&(c--,t=-1===c?s:a[c]),!u&&"<"!==h&&h)){p=-1===c?s:a[c].children;var y=e.indexOf("<",g),v=e.slice(g,-1===y?void 0:y);o.test(v)&&(v=" "),(y>-1&&c+p.length>=0||" "!==v)&&p.push({type:"text",content:v})}})),s};function u(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];y(n[0])&&(n[0]=`react-i18next:: ${n[0]}`),console.warn(...n)}}const p={};function d(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];y(n[0])&&p[n[0]]||(y(n[0])&&(p[n[0]]=new Date),u(...n))}const f=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}},g=(e,n,t)=>{e.loadNamespaces(n,f(e,t))},h=(e,n,t,s)=>{y(t)&&(t=[t]),t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,f(e,s))},m=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,v=e=>"object"==typeof e&&null!==e,b=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,x={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},E=e=>x[e];let N={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(b,E)};const O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};N={...N,...e}},$=()=>N;let k;const w=e=>{k=e},I=()=>k,S=(e,n)=>{if(!e)return!1;const t=e.props?e.props.children:e.children;return n?t.length>0:!!t},C=e=>{if(!e)return[];const n=e.props?e.props.children:e.children;return e.props&&e.props.i18nIsDynamicList?j(n):n},j=e=>Array.isArray(e)?e:[e],R=(e,t)=>{if(!e)return"";let s="";const a=j(e),i=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return a.forEach(((e,a)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:r}=e,o=Object.keys(n).length,l=i.indexOf(r)>-1,c=n.children;if(c||!l||o)if(!c&&(!l||o)||n.i18nIsDynamicList)s+=`<${a}></${a}>`;else if(l&&1===o&&y(c))s+=`<${r}>${c}</${r}>`;else{const e=R(c,t);s+=`<${a}>${e}</${a}>`}else s+=`<${r}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(v(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[0];s+=`{{${e}}}`}else u("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else u("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}}.",e)})),s},L=(e,t,s,a,i,r)=>{if(""===t)return[];const o=a.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},p=e=>{j(e).forEach((e=>{y(e)||(S(e)?p(C(e)):v(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},g=(e,t,s)=>{const a=C(e),i=m(a,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(a)&&0===i.length||e.props&&e.props.i18nIsDynamicList?a:i},h=(e,t,s,a,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:a},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:a,ref:e.ref},i?null:t)})))},m=(t,i,c)=>{const u=j(t);return j(i).reduce(((t,i,p)=>{const d=i.children&&i.children[0]&&i.children[0].content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let r=u[parseInt(i.name,10)];1!==c.length||r||(r=c[0][i.name]),r||(r={});const b=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},r):r,x=n.isValidElement(b),E=x&&S(i,!0)&&!i.voidElement,N=l&&v(b)&&b.dummy&&!x,O=v(e)&&Object.hasOwnProperty.call(e,i.name);if(y(b)){const e=s.services.interpolator.interpolate(b,f,s.language);t.push(e)}else if(S(b)||E){const e=g(b,i,c);h(b,e,t,p)}else if(N){const e=m(u,i.children,c);h(b,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(O){const e=g(b,i,c);h(b,e,t,p,i.voidElement)}else if(a.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=m(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=m(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(v(b)&&!x){const e=i.children[0]?d:null;e&&t.push(e)}else h(b,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=a.transWrapTextNodes,o=r?a.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},b=m([{dummy:!0,children:e||[]}],d,j(e||[]));return C(b[0])};function T(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:h,...m}=e;const v=f||I();if(!v)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const b=g||v.t.bind(v)||(e=>e),x={...$(),...v.options&&v.options.react};let E=p||b.ns||v.options&&v.options.defaultNS;E=y(E)?[E]:E||["translation"];const N=R(t,x),O=c||N||x.transEmptyNodeValue||i,{hashTransKey:k}=x,w=i||(k?k(N||O):N||O);v.options&&v.options.interpolation&&v.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables});const S=l||void 0!==s||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},C={...o,context:r||o.context,count:s,...l,...S,defaultValue:O,ns:E},j=w?b(w,C):O;u&&Object.keys(u).forEach((e=>{const t=u[e];"function"==typeof t.type||!t.props||!t.props.children||j.indexOf(`${e}/>`)<0&&j.indexOf(`${e} />`)<0||(u[e]=n.createElement((function(){return n.createElement(n.Fragment,null,t)})))}));const T=L(u||t,j,v,x,C,h),P=void 0!==a?a:x.defaultTransParent;return P?n.createElement(P,m,T):T}const P={type:"3rdParty",init(e){O(e.options.react),w(e)}},A=n.createContext();class V{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces=()=>Object.keys(this.usedNamespaces)}const z=e=>async n=>({...e.getInitialProps?await e.getInitialProps(n):{},...B()}),B=()=>{const e=I(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},s={};return e.languages.forEach((t=>{s[t]={},n.forEach((n=>{s[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=s,t.initialLanguage=e.language,t};const F=(e,n,t,s)=>e.getFixedT(n,t,s),U=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:a,defaultNS:i}=n.useContext(A)||{},r=s||a||I();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new V),!r){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:v(n)&&y(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}r.options.react&&void 0!==r.options.react.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...$(),...r.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||r.options&&r.options.defaultNS;u=y(u)?[u]:u||["translation"],r.reportNamespaces.addUsedNamespaces&&r.reportNamespaces.addUsedNamespaces(u);const p=(r.isInitialized||r.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?void 0!==n.options.ignoreJSONStructure?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=n.languages[0],a=!!n.options&&n.options.fallbackLng,i=n.languages[n.languages.length-1];if("cimode"===s.toLowerCase())return!0;const r=(e,t)=>{const s=n.services.backendConnector.state[`${e}|${t}`];return-1===s||2===s};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e)||!n.hasResourceBundle(s,e)&&n.services.backendConnector.backend&&(!n.options.resources||n.options.partialBundledLanguages)&&(!r(s,e)||a&&!r(i,e)))}(e,n,t):(d("i18n.languages were undefined or empty",n.languages),!0)}(e,r,o))),f=((e,t,s,a)=>n.useCallback(F(e,t,s,a),[e,t,s,a]))(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),m=()=>f,b=()=>F(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[x,E]=n.useState(m);let N=u.join();t.lng&&(N=`${t.lng}${N}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=t?s.current:e}),[e,t]),s.current})(N),k=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;k.current=!0,p||l||(t.lng?h(r,t.lng,u,(()=>{k.current&&E(b)})):g(r,u,(()=>{k.current&&E(b)}))),p&&O&&O!==N&&k.current&&E(b);const s=()=>{k.current&&E(b)};return e&&r&&r.on(e,s),n&&r&&r.store.on(n,s),()=>{k.current=!1,e&&r&&e.split(" ").forEach((e=>r.off(e,s))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,s)))}}),[r,N]),n.useEffect((()=>{k.current&&p&&E(m)}),[r,c,p]);const w=[x,r,p];if(w.t=x,w.i18n=r,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?h(r,t.lng,u,(()=>e())):g(r,u,(()=>e()))}))};const K=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:a}=s,{i18n:i}=n.useContext(A)||{},r=a||i||I();r.options&&r.options.isClone||(e&&!r.initializedStoreOnce&&(r.services.resourceStore.data=e,r.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),r.options.ns),r.initializedStoreOnce=!0,r.isInitialized=!0),t&&!r.initializedLanguageOnce&&(r.changeLanguage(t),r.initializedLanguageOnce=!0))};e.I18nContext=A,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:a}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(A.Provider,{value:i},a)},e.Trans=function(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...h}=e;const{i18n:m,defaultNS:y}=n.useContext(A)||{},v=d||m||I(),b=f||v&&v.t.bind(v);return T({children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o,values:l,defaults:c,components:u,ns:p||b&&b.ns||y||v&&v.options&&v.options.defaultNS,i18n:v,t:f,shouldUnescape:g,...h})},e.TransWithoutContext=T,e.Translation=function(e){const{ns:n,children:t,...s}=e,[a,i,r]=U(n,s);return t(a,{i18n:i,lng:i.language},r)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=$,e.getI18n=I,e.getInitialProps=B,e.initReactI18next=P,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=K,e.useTranslation=U,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:a,...i}=t;return K(s,a),n.createElement(e,{...i})}return t.getInitialProps=z(e),t.displayName=`withI18nextSSR(${m(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function a(a){let{forwardedRef:i,...r}=a;const[o,l,c]=U(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),n.createElement(s,u)}a.displayName=`withI18nextTranslation(${m(s)})`,a.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(a,Object.assign({},e,{forwardedRef:t})))):a}}}));
|