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
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
124
124
|
args[_key] = arguments[_key];
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
126
|
+
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
127
127
|
console.warn(...args);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -132,8 +132,8 @@
|
|
|
132
132
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
133
133
|
args[_key2] = arguments[_key2];
|
|
134
134
|
}
|
|
135
|
-
if (
|
|
136
|
-
if (
|
|
135
|
+
if (isString(args[0]) && alreadyWarned[args[0]]) return;
|
|
136
|
+
if (isString(args[0])) alreadyWarned[args[0]] = new Date();
|
|
137
137
|
warn(...args);
|
|
138
138
|
}
|
|
139
139
|
const loadedClb = (i18n, cb) => () => {
|
|
@@ -149,17 +149,17 @@
|
|
|
149
149
|
i18n.on('initialized', initialized);
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
|
|
152
|
+
const loadNamespaces = (i18n, ns, cb) => {
|
|
153
153
|
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (
|
|
154
|
+
};
|
|
155
|
+
const loadLanguages = (i18n, lng, ns, cb) => {
|
|
156
|
+
if (isString(ns)) ns = [ns];
|
|
157
157
|
ns.forEach(n => {
|
|
158
158
|
if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
|
|
159
159
|
});
|
|
160
160
|
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
|
161
|
-
}
|
|
162
|
-
function
|
|
161
|
+
};
|
|
162
|
+
const oldI18nextHasLoadedNamespace = function (ns, i18n) {
|
|
163
163
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
164
164
|
const lng = i18n.languages[0];
|
|
165
165
|
const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
|
@@ -174,8 +174,8 @@
|
|
|
174
174
|
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
|
|
175
175
|
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
176
176
|
return false;
|
|
177
|
-
}
|
|
178
|
-
function
|
|
177
|
+
};
|
|
178
|
+
const hasLoadedNamespace = function (ns, i18n) {
|
|
179
179
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
180
180
|
if (!i18n.languages || !i18n.languages.length) {
|
|
181
181
|
warnOnce('i18n.languages were undefined or empty', i18n.languages);
|
|
@@ -191,10 +191,10 @@
|
|
|
191
191
|
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
};
|
|
195
|
+
const getDisplayName = Component => Component.displayName || Component.name || (isString(Component) && Component.length > 0 ? Component : 'Unknown');
|
|
196
|
+
const isString = obj => typeof obj === 'string';
|
|
197
|
+
const isObject = obj => typeof obj === 'object' && obj !== null;
|
|
198
198
|
|
|
199
199
|
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
200
200
|
const htmlEntities = {
|
|
@@ -232,77 +232,70 @@
|
|
|
232
232
|
useSuspense: true,
|
|
233
233
|
unescape
|
|
234
234
|
};
|
|
235
|
-
function
|
|
235
|
+
const setDefaults = function () {
|
|
236
236
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
237
237
|
defaultOptions = {
|
|
238
238
|
...defaultOptions,
|
|
239
239
|
...options
|
|
240
240
|
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return defaultOptions;
|
|
244
|
-
}
|
|
241
|
+
};
|
|
242
|
+
const getDefaults = () => defaultOptions;
|
|
245
243
|
|
|
246
244
|
let i18nInstance;
|
|
247
|
-
|
|
245
|
+
const setI18n = instance => {
|
|
248
246
|
i18nInstance = instance;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return i18nInstance;
|
|
252
|
-
}
|
|
247
|
+
};
|
|
248
|
+
const getI18n = () => i18nInstance;
|
|
253
249
|
|
|
254
|
-
|
|
250
|
+
const hasChildren = (node, checkLength) => {
|
|
255
251
|
if (!node) return false;
|
|
256
252
|
const base = node.props ? node.props.children : node.children;
|
|
257
253
|
if (checkLength) return base.length > 0;
|
|
258
254
|
return !!base;
|
|
259
|
-
}
|
|
260
|
-
|
|
255
|
+
};
|
|
256
|
+
const getChildren = node => {
|
|
261
257
|
if (!node) return [];
|
|
262
258
|
const children = node.props ? node.props.children : node.children;
|
|
263
259
|
return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
function getAsArray(data) {
|
|
270
|
-
return Array.isArray(data) ? data : [data];
|
|
271
|
-
}
|
|
272
|
-
function mergeProps(source, target) {
|
|
260
|
+
};
|
|
261
|
+
const hasValidReactChildren = children => Array.isArray(children) && children.every(react.isValidElement);
|
|
262
|
+
const getAsArray = data => Array.isArray(data) ? data : [data];
|
|
263
|
+
const mergeProps = (source, target) => {
|
|
273
264
|
const newTarget = {
|
|
274
265
|
...target
|
|
275
266
|
};
|
|
276
267
|
newTarget.props = Object.assign(source.props, target.props);
|
|
277
268
|
return newTarget;
|
|
278
|
-
}
|
|
279
|
-
|
|
269
|
+
};
|
|
270
|
+
const nodesToString = (children, i18nOptions) => {
|
|
280
271
|
if (!children) return '';
|
|
281
272
|
let stringNode = '';
|
|
282
273
|
const childrenArray = getAsArray(children);
|
|
283
274
|
const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
|
|
284
275
|
childrenArray.forEach((child, childIndex) => {
|
|
285
|
-
if (
|
|
276
|
+
if (isString(child)) {
|
|
286
277
|
stringNode += `${child}`;
|
|
287
278
|
} else if (react.isValidElement(child)) {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
279
|
+
const {
|
|
280
|
+
props,
|
|
281
|
+
type
|
|
282
|
+
} = child;
|
|
283
|
+
const childPropsCount = Object.keys(props).length;
|
|
284
|
+
const shouldKeepChild = keepArray.indexOf(type) > -1;
|
|
285
|
+
const childChildren = props.children;
|
|
286
|
+
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
287
|
+
stringNode += `<${type}/>`;
|
|
288
|
+
} else if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
296
289
|
stringNode += `<${childIndex}></${childIndex}>`;
|
|
297
|
-
} else if (shouldKeepChild && childPropsCount === 1 &&
|
|
298
|
-
stringNode += `<${
|
|
290
|
+
} else if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
|
|
291
|
+
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
299
292
|
} else {
|
|
300
293
|
const content = nodesToString(childChildren, i18nOptions);
|
|
301
294
|
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
302
295
|
}
|
|
303
296
|
} else if (child === null) {
|
|
304
297
|
warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
|
|
305
|
-
} else if (
|
|
298
|
+
} else if (isObject(child)) {
|
|
306
299
|
const {
|
|
307
300
|
format,
|
|
308
301
|
...clone
|
|
@@ -319,32 +312,32 @@
|
|
|
319
312
|
}
|
|
320
313
|
});
|
|
321
314
|
return stringNode;
|
|
322
|
-
}
|
|
323
|
-
|
|
315
|
+
};
|
|
316
|
+
const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => {
|
|
324
317
|
if (targetString === '') return [];
|
|
325
318
|
const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
|
|
326
319
|
const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map(keep => `<${keep}`).join('|')).test(targetString);
|
|
327
320
|
if (!children && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString];
|
|
328
321
|
const data = {};
|
|
329
|
-
|
|
322
|
+
const getData = childs => {
|
|
330
323
|
const childrenArray = getAsArray(childs);
|
|
331
324
|
childrenArray.forEach(child => {
|
|
332
|
-
if (
|
|
333
|
-
if (hasChildren(child)) getData(getChildren(child));else if (
|
|
325
|
+
if (isString(child)) return;
|
|
326
|
+
if (hasChildren(child)) getData(getChildren(child));else if (isObject(child) && !react.isValidElement(child)) Object.assign(data, child);
|
|
334
327
|
});
|
|
335
|
-
}
|
|
328
|
+
};
|
|
336
329
|
getData(children);
|
|
337
330
|
const ast = c.parse(`<0>${targetString}</0>`);
|
|
338
331
|
const opts = {
|
|
339
332
|
...data,
|
|
340
333
|
...combinedTOpts
|
|
341
334
|
};
|
|
342
|
-
|
|
335
|
+
const renderInner = (child, node, rootReactNode) => {
|
|
343
336
|
const childs = getChildren(child);
|
|
344
337
|
const mappedChildren = mapAST(childs, node.children, rootReactNode);
|
|
345
338
|
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren;
|
|
346
|
-
}
|
|
347
|
-
|
|
339
|
+
};
|
|
340
|
+
const pushTranslatedJSX = (child, inner, mem, i, isVoid) => {
|
|
348
341
|
if (child.dummy) {
|
|
349
342
|
child.children = inner;
|
|
350
343
|
mem.push(react.cloneElement(child, {
|
|
@@ -363,8 +356,8 @@
|
|
|
363
356
|
}, isVoid ? null : inner);
|
|
364
357
|
}));
|
|
365
358
|
}
|
|
366
|
-
}
|
|
367
|
-
|
|
359
|
+
};
|
|
360
|
+
const mapAST = (reactNode, astNode, rootReactNode) => {
|
|
368
361
|
const reactNodes = getAsArray(reactNode);
|
|
369
362
|
const astNodes = getAsArray(astNode);
|
|
370
363
|
return astNodes.reduce((mem, node, i) => {
|
|
@@ -378,9 +371,9 @@
|
|
|
378
371
|
}, tmp) : tmp;
|
|
379
372
|
const isElement = react.isValidElement(child);
|
|
380
373
|
const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
|
|
381
|
-
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling &&
|
|
382
|
-
const isKnownComponent =
|
|
383
|
-
if (
|
|
374
|
+
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && isObject(child) && child.dummy && !isElement;
|
|
375
|
+
const isKnownComponent = isObject(children) && Object.hasOwnProperty.call(children, node.name);
|
|
376
|
+
if (isString(child)) {
|
|
384
377
|
const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
|
|
385
378
|
mem.push(value);
|
|
386
379
|
} else if (hasChildren(child) || isValidTranslationWithChildren) {
|
|
@@ -410,7 +403,7 @@
|
|
|
410
403
|
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
411
404
|
mem.push(`<${node.name}>${inner}</${node.name}>`);
|
|
412
405
|
}
|
|
413
|
-
} else if (
|
|
406
|
+
} else if (isObject(child) && !isElement) {
|
|
414
407
|
const content = node.children[0] ? translationContent : null;
|
|
415
408
|
if (content) mem.push(content);
|
|
416
409
|
} else {
|
|
@@ -429,13 +422,13 @@
|
|
|
429
422
|
}
|
|
430
423
|
return mem;
|
|
431
424
|
}, []);
|
|
432
|
-
}
|
|
425
|
+
};
|
|
433
426
|
const result = mapAST([{
|
|
434
427
|
dummy: true,
|
|
435
428
|
children: children || []
|
|
436
429
|
}], ast, getAsArray(children || []));
|
|
437
430
|
return getChildren(result[0]);
|
|
438
|
-
}
|
|
431
|
+
};
|
|
439
432
|
function Trans$1(_ref) {
|
|
440
433
|
let {
|
|
441
434
|
children,
|
|
@@ -464,7 +457,7 @@
|
|
|
464
457
|
...(i18n.options && i18n.options.react)
|
|
465
458
|
};
|
|
466
459
|
let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
|
|
467
|
-
namespaces =
|
|
460
|
+
namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
|
|
468
461
|
const nodeAsString = nodesToString(children, reactI18nextOptions);
|
|
469
462
|
const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
|
|
470
463
|
const {
|
|
@@ -529,26 +522,17 @@
|
|
|
529
522
|
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
|
|
530
523
|
});
|
|
531
524
|
}
|
|
532
|
-
getUsedNamespaces()
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
...i18nInitialProps
|
|
544
|
-
});
|
|
545
|
-
});
|
|
546
|
-
} else {
|
|
547
|
-
resolve(i18nInitialProps);
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
function getInitialProps() {
|
|
525
|
+
getUsedNamespaces = () => Object.keys(this.usedNamespaces);
|
|
526
|
+
}
|
|
527
|
+
const composeInitialProps = ForComponent => async ctx => {
|
|
528
|
+
const componentsInitialProps = ForComponent.getInitialProps ? await ForComponent.getInitialProps(ctx) : {};
|
|
529
|
+
const i18nInitialProps = getInitialProps();
|
|
530
|
+
return {
|
|
531
|
+
...componentsInitialProps,
|
|
532
|
+
...i18nInitialProps
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
const getInitialProps = () => {
|
|
552
536
|
const i18n = getI18n();
|
|
553
537
|
const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : [];
|
|
554
538
|
const ret = {};
|
|
@@ -562,7 +546,7 @@
|
|
|
562
546
|
ret.initialI18nStore = initialI18nStore;
|
|
563
547
|
ret.initialLanguage = i18n.language;
|
|
564
548
|
return ret;
|
|
565
|
-
}
|
|
549
|
+
};
|
|
566
550
|
|
|
567
551
|
function Trans(_ref) {
|
|
568
552
|
let {
|
|
@@ -612,13 +596,9 @@
|
|
|
612
596
|
}, [value, ignore]);
|
|
613
597
|
return ref.current;
|
|
614
598
|
};
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
function useMemoizedT(i18n, language, namespace, keyPrefix) {
|
|
619
|
-
return react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
|
|
620
|
-
}
|
|
621
|
-
function useTranslation(ns) {
|
|
599
|
+
const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
|
|
600
|
+
const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
|
|
601
|
+
const useTranslation = function (ns) {
|
|
622
602
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
623
603
|
const {
|
|
624
604
|
i18n: i18nFromProps
|
|
@@ -632,8 +612,8 @@
|
|
|
632
612
|
if (!i18n) {
|
|
633
613
|
warnOnce('You will need to pass in an i18next instance by using initReactI18next');
|
|
634
614
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
635
|
-
if (
|
|
636
|
-
if (optsOrDefaultValue &&
|
|
615
|
+
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
616
|
+
if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
637
617
|
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
638
618
|
};
|
|
639
619
|
const retNotReady = [notReadyT, {}, false];
|
|
@@ -653,7 +633,7 @@
|
|
|
653
633
|
keyPrefix
|
|
654
634
|
} = i18nOptions;
|
|
655
635
|
let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
656
|
-
namespaces =
|
|
636
|
+
namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
|
|
657
637
|
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
658
638
|
const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
|
|
659
639
|
const memoGetT = useMemoizedT(i18n, props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
@@ -684,9 +664,9 @@
|
|
|
684
664
|
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
685
665
|
setT(getNewT);
|
|
686
666
|
}
|
|
687
|
-
|
|
667
|
+
const boundReset = () => {
|
|
688
668
|
if (isMounted.current) setT(getNewT);
|
|
689
|
-
}
|
|
669
|
+
};
|
|
690
670
|
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
691
671
|
if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
|
|
692
672
|
return () => {
|
|
@@ -713,9 +693,9 @@
|
|
|
713
693
|
loadNamespaces(i18n, namespaces, () => resolve());
|
|
714
694
|
}
|
|
715
695
|
});
|
|
716
|
-
}
|
|
696
|
+
};
|
|
717
697
|
|
|
718
|
-
function
|
|
698
|
+
const withTranslation = function (ns) {
|
|
719
699
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
720
700
|
return function Extend(WrappedComponent) {
|
|
721
701
|
function I18nextWithTranslation(_ref) {
|
|
@@ -747,7 +727,7 @@
|
|
|
747
727
|
}));
|
|
748
728
|
return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
|
|
749
729
|
};
|
|
750
|
-
}
|
|
730
|
+
};
|
|
751
731
|
|
|
752
732
|
function Translation(props) {
|
|
753
733
|
const {
|
|
@@ -777,7 +757,7 @@
|
|
|
777
757
|
}, children);
|
|
778
758
|
}
|
|
779
759
|
|
|
780
|
-
function
|
|
760
|
+
const useSSR = function (initialI18nStore, initialLanguage) {
|
|
781
761
|
let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
782
762
|
const {
|
|
783
763
|
i18n: i18nFromProps
|
|
@@ -802,27 +782,25 @@
|
|
|
802
782
|
i18n.changeLanguage(initialLanguage);
|
|
803
783
|
i18n.initializedLanguageOnce = true;
|
|
804
784
|
}
|
|
805
|
-
}
|
|
785
|
+
};
|
|
806
786
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
};
|
|
825
|
-
}
|
|
787
|
+
const withSSR = () => function Extend(WrappedComponent) {
|
|
788
|
+
function I18nextWithSSR(_ref) {
|
|
789
|
+
let {
|
|
790
|
+
initialI18nStore,
|
|
791
|
+
initialLanguage,
|
|
792
|
+
...rest
|
|
793
|
+
} = _ref;
|
|
794
|
+
useSSR(initialI18nStore, initialLanguage);
|
|
795
|
+
return react.createElement(WrappedComponent, {
|
|
796
|
+
...rest
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent);
|
|
800
|
+
I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`;
|
|
801
|
+
I18nextWithSSR.WrappedComponent = WrappedComponent;
|
|
802
|
+
return I18nextWithSSR;
|
|
803
|
+
};
|
|
826
804
|
|
|
827
805
|
const date = () => '';
|
|
828
806
|
const time = () => '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i=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}),s=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function o(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(i[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var o=e.indexOf("--\x3e");return{type:"comment",comment:-1!==o?e.slice(4,o):""}}for(var r=new RegExp(s),a=null;null!==(a=r.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],r.lastIndex--}else a[2]&&(n.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return n}var r=/<[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,i=[],s=[],l=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");i.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(r,(function(r,c){if(u){if(r!=="</"+t.name+">")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),g=c+r.length,h=e.charAt(g);if(f){var m=o(r);return l<0?(i.push(m),i):((p=s[l]).children.push(m),i)}if(d&&(l++,"tag"===(t=o(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===l&&i.push(t),(p=s[l-1])&&p.children.push(t),s[l]=t),(!d||t.voidElement)&&(l>-1&&(t.voidElement||t.name===r.slice(2,-1))&&(l--,t=-1===l?i:s[l]),!u&&"<"!==h&&h)){p=-1===l?i:s[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})}})),i},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 h(e,n,t){e.loadNamespaces(n,g(e,t))}function m(e,n,t,i){"string"==typeof t&&(t=[t]),t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,g(e,i))}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 i="";const s=j(e),o=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return s.forEach(((e,s)=>{if("string"==typeof e)i+=`${e}`;else if(n.isValidElement(e)){const n=Object.keys(e.props).length,r=o.indexOf(e.type)>-1,a=e.props.children;if(!a&&r&&0===n)i+=`<${e.type}/>`;else if(a||r&&0===n)if(e.props.i18nIsDynamicList)i+=`<${s}></${s}>`;else if(r&&1===n&&"string"==typeof a)i+=`<${e.type}>${a}</${e.type}>`;else{const e=C(a,t);i+=`<${s}>${e}</${s}>`}else i+=`<${s}></${s}>`}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,s=Object.keys(t);if(1===s.length){const e=n?`${s[0]}, ${n}`:s[0];i+=`{{${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)})),i}function R(e,t,i,s,o,r){if(""===t)return[];const a=s.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(a.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!c&&!r)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,...o};function f(e,t,i){const s=S(e),o=h(s,t.children,i);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((e=>n.isValidElement(e)))}(s)&&0===o.length||e.props&&e.props.i18nIsDynamicList?s:o}function g(e,t,i,s,o){e.dummy?(e.children=t,i.push(n.cloneElement(e,{key:s},o?void 0:t))):i.push(...n.Children.map([e],(e=>{const i={...e.props};return delete i.i18nIsDynamicList,n.createElement(e.type,{...i,key:s,ref:e.ref},o?null:t)})))}function h(t,o,l){const u=j(t);return j(o).reduce(((t,o,p)=>{const m=o.children&&o.children[0]&&o.children[0].content&&i.services.interpolator.interpolate(o.children[0].content,d,i.language);if("tag"===o.type){let r=u[parseInt(o.name,10)];1!==l.length||r||(r=l[0][o.name]),r||(r={});const y=0!==Object.keys(o.attrs).length?function(e,n){const t={...n};return t.props=Object.assign(e.props,n.props),t}({props:o.attrs},r):r,b=n.isValidElement(y),v=b&&I(o,!0)&&!o.voidElement,x=c&&"object"==typeof y&&y.dummy&&!b,E="object"==typeof e&&null!==e&&Object.hasOwnProperty.call(e,o.name);if("string"==typeof y){const e=i.services.interpolator.interpolate(y,d,i.language);t.push(e)}else if(I(y)||v){g(y,f(y,o,l),t,p)}else if(x){g(y,h(u,o.children,l),t,p)}else if(Number.isNaN(parseFloat(o.name)))if(E){g(y,f(y,o,l),t,p,o.voidElement)}else if(s.transSupportBasicHtmlNodes&&a.indexOf(o.name)>-1)if(o.voidElement)t.push(n.createElement(o.name,{key:`${o.name}-${p}`}));else{const e=h(u,o.children,l);t.push(n.createElement(o.name,{key:`${o.name}-${p}`},e))}else if(o.voidElement)t.push(`<${o.name} />`);else{const e=h(u,o.children,l);t.push(`<${o.name}>${e}</${o.name}>`)}else if("object"!=typeof y||b)g(y,m,t,p,1!==o.children.length||!m);else{const e=o.children[0]?m:null;e&&t.push(e)}}else if("text"===o.type){const e=s.transWrapTextNodes,a=r?s.unescape(i.services.interpolator.interpolate(o.content,d,i.language)):i.services.interpolator.interpolate(o.content,d,i.language);e?t.push(n.createElement(e,{key:`${o.name}-${p}`},a)):t.push(a)}return t}),[])}return S(h([{dummy:!0,children:e||[]}],p,j(e||[]))[0])}function T(e){let{children:t,count:i,parent:s,i18nKey:o,context:r,tOptions:a={},values:c,defaults:l,components:u,ns:p,i18n:d,t:g,shouldUnescape:h,...m}=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||o,{hashTransKey:O}=v,w=o||(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!==i||!t?a.interpolation:{interpolation:{...a.interpolation,prefix:"#$?",suffix:"?$#"}},S={...a,context:r||a.context,count:i,...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 T=R(u||t,j,y,v,S,h),L=void 0!==s?s:v.defaultTransParent;return L?n.createElement(L,m,T):T}const L={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 i=A();e.getInitialProps?e.getInitialProps(n).then((e=>{t({...e,...i})})):t(i)}))}function A(){const e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},i={};return e.languages.forEach((t=>{i[t]={},n.forEach((n=>{i[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=i,t.initialLanguage=e.language,t}const B=(e,t)=>{const i=n.useRef();return n.useEffect((()=>{i.current=t?i.current:e}),[e,t]),i.current};function F(e,n,t,i){return e.getFixedT(n,t,i)}function U(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:i}=t,{i18n:s,defaultNS:o}=n.useContext(P)||{},r=i||s||k();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new V),!r){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}r.options.react&&void 0!==r.options.react.wait&&f("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...$(),...r.options.react,...t},{useSuspense:c,keyPrefix:l}=a;let u=e||o||r.options&&r.options.defaultNS;u="string"==typeof 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,i)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!i(n.isLanguageChangingTo,e))return!1}}):function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=n.languages[0],s=!!n.options&&n.options.fallbackLng,o=n.languages[n.languages.length-1];if("cimode"===i.toLowerCase())return!0;const r=(e,t)=>{const i=n.services.backendConnector.state[`${e}|${t}`];return-1===i||2===i};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e)||!n.hasResourceBundle(i,e)&&n.services.backendConnector.backend&&(!n.options.resources||n.options.partialBundledLanguages)&&(!r(i,e)||s&&!r(o,e)))}(e,n,t):(f("i18n.languages were undefined or empty",n.languages),!0)}(e,r,a))),d=function(e,t,i,s){return n.useCallback(F(e,t,i,s),[e,t,i,s])}(r,t.lng||null,"fallback"===a.nsMode?u:u[0],l),g=()=>d,y=()=>F(r,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 i(){N.current&&v(y)}return N.current=!0,p||c||(t.lng?m(r,t.lng,u,(()=>{N.current&&v(y)})):h(r,u,(()=>{N.current&&v(y)}))),p&&E&&E!==x&&N.current&&v(y),e&&r&&r.on(e,i),n&&r&&r.store.on(n,i),()=>{N.current=!1,e&&r&&e.split(" ").forEach((e=>r.off(e,i))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,i)))}}),[r,x]),n.useEffect((()=>{N.current&&p&&v(g)}),[r,l,p]);const O=[b,r,p];if(O.t=b,O.i18n=r,O.ready=p,p)return O;if(!p&&!c)return O;throw new Promise((e=>{t.lng?m(r,t.lng,u,(()=>e())):h(r,u,(()=>e()))}))}function K(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:s}=i,{i18n:o}=n.useContext(P)||{},r=s||o||k();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=P,e.I18nextProvider=function(e){let{i18n:t,defaultNS:i,children:s}=e;const o=n.useMemo((()=>({i18n:t,defaultNS:i})),[t,i]);return n.createElement(P.Provider,{value:o},s)},e.Trans=function(e){let{children:t,count:i,parent:s,i18nKey:o,context:r,tOptions:a={},values:c,defaults:l,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...h}=e;const{i18n:m,defaultNS:y}=n.useContext(P)||{},b=d||m||k(),v=f||b&&b.t.bind(b);return T({children:t,count:i,parent:s,i18nKey:o,context:r,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,...h})},e.TransWithoutContext=T,e.Translation=function(e){const{ns:n,children:t,...i}=e,[s,o,r]=U(n,i);return t(s,{i18n:o,lng:o.language},r)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=$,e.getI18n=k,e.getInitialProps=A,e.initReactI18next=L,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:i,initialLanguage:s,...o}=t;return K(i,s),n.createElement(e,{...o})}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(i){function s(s){let{forwardedRef:o,...r}=s;const[a,c,l]=U(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:a,i18n:c,tReady:l};return t.withRef&&o?u.ref=o:!t.withRef&&o&&(u.forwardedRef=o),n.createElement(i,u)}s.displayName=`withI18nextTranslation(${y(i)})`,s.WrappedComponent=i;return t.withRef?n.forwardRef(((e,t)=>n.createElement(s,Object.assign({},e,{forwardedRef:t})))):s}}}));
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ReactI18next={},e.React)}(this,(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 a(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 a=e.indexOf("--\x3e");return{type:"comment",comment:-1!==a?e.slice(4,a):""}}for(var o=new RegExp(i),r=null;null!==(r=o.exec(e));)if(r[0].trim())if(r[1]){var l=r[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],o.lastIndex--}else r[2]&&(n.attrs[r[2]]=r[3].trim().substring(1,r[3].length-1));return n}var o=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,r=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],i=[],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(o,(function(o,l){if(u){if(o!=="</"+t.name+">")return;u=!1}var p,d="/"!==o.charAt(1),f=o.startsWith("\x3c!--"),g=l+o.length,h=e.charAt(g);if(f){var m=a(o);return c<0?(s.push(m),s):((p=i[c]).children.push(m),s)}if(d&&(c++,"tag"===(t=a(o)).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=i[c-1])&&p.children.push(t),i[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===o.slice(2,-1))&&(c--,t=-1===c?s:i[c]),!u&&"<"!==h&&h)){p=-1===c?s:i[c].children;var y=e.indexOf("<",g),b=e.slice(g,-1===y?void 0:y);r.test(b)&&(b=" "),(y>-1&&c+p.length>=0||" "!==b)&&p.push({type:"text",content:b})}})),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,b=e=>"object"==typeof e&&null!==e,v=/&(?: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(v,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?R(n):n},R=e=>Array.isArray(e)?e:[e],j=(e,t)=>{if(!e)return"";let s="";const i=R(e),a=t.transSupportBasicHtmlNodes&&t.transKeepBasicHtmlNodesFor?t.transKeepBasicHtmlNodesFor:[];return i.forEach(((e,i)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:o}=e,r=Object.keys(n).length,l=a.indexOf(o)>-1,c=n.children;if(c||!l||r)if(!c&&(!l||r)||n.i18nIsDynamicList)s+=`<${i}></${i}>`;else if(l&&1===r&&y(c))s+=`<${o}>${c}</${o}>`;else{const e=j(c,t);s+=`<${i}>${e}</${i}>`}else s+=`<${o}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(b(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 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},T=(e,t,s,i,a,o)=>{if(""===t)return[];const r=i.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(r.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!o)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(S(e)?p(C(e)):b(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...a},g=(e,t,s)=>{const i=C(e),a=m(i,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(i)&&0===a.length||e.props&&e.props.i18nIsDynamicList?i:a},h=(e,t,s,i,a)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:i},a?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},a?null:t)})))},m=(t,a,c)=>{const u=R(t);return R(a).reduce(((t,a,p)=>{const d=a.children&&a.children[0]&&a.children[0].content&&s.services.interpolator.interpolate(a.children[0].content,f,s.language);if("tag"===a.type){let o=u[parseInt(a.name,10)];1!==c.length||o||(o=c[0][a.name]),o||(o={});const v=0!==Object.keys(a.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:a.attrs},o):o,x=n.isValidElement(v),E=x&&S(a,!0)&&!a.voidElement,N=l&&b(v)&&v.dummy&&!x,O=b(e)&&Object.hasOwnProperty.call(e,a.name);if(y(v)){const e=s.services.interpolator.interpolate(v,f,s.language);t.push(e)}else if(S(v)||E){const e=g(v,a,c);h(v,e,t,p)}else if(N){const e=m(u,a.children,c);h(v,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=g(v,a,c);h(v,e,t,p,a.voidElement)}else if(i.transSupportBasicHtmlNodes&&r.indexOf(a.name)>-1)if(a.voidElement)t.push(n.createElement(a.name,{key:`${a.name}-${p}`}));else{const e=m(u,a.children,c);t.push(n.createElement(a.name,{key:`${a.name}-${p}`},e))}else if(a.voidElement)t.push(`<${a.name} />`);else{const e=m(u,a.children,c);t.push(`<${a.name}>${e}</${a.name}>`)}else if(b(v)&&!x){const e=a.children[0]?d:null;e&&t.push(e)}else h(v,d,t,p,1!==a.children.length||!d)}else if("text"===a.type){const e=i.transWrapTextNodes,r=o?i.unescape(s.services.interpolator.interpolate(a.content,f,s.language)):s.services.interpolator.interpolate(a.content,f,s.language);e?t.push(n.createElement(e,{key:`${a.name}-${p}`},r)):t.push(r)}return t}),[])},v=m([{dummy:!0,children:e||[]}],d,R(e||[]));return C(v[0])};function L(e){let{children:t,count:s,parent:i,i18nKey:a,context:o,tOptions:r={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:h,...m}=e;const b=f||I();if(!b)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const v=g||b.t.bind(b)||(e=>e),x={...$(),...b.options&&b.options.react};let E=p||v.ns||b.options&&b.options.defaultNS;E=y(E)?[E]:E||["translation"];const N=j(t,x),O=c||N||x.transEmptyNodeValue||a,{hashTransKey:k}=x,w=a||(k?k(N||O):N||O);b.options&&b.options.interpolation&&b.options.interpolation.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables});const S=l||void 0!==s||!t?r.interpolation:{interpolation:{...r.interpolation,prefix:"#$?",suffix:"?$#"}},C={...r,context:o||r.context,count:s,...l,...S,defaultValue:O,ns:E},R=w?v(w,C):O;u&&Object.keys(u).forEach((e=>{const t=u[e];"function"==typeof t.type||!t.props||!t.props.children||R.indexOf(`${e}/>`)<0&&R.indexOf(`${e} />`)<0||(u[e]=n.createElement((function(){return n.createElement(n.Fragment,null,t)})))}));const L=T(u||t,R,b,x,C,h),P=void 0!==i?i:x.defaultTransParent;return P?n.createElement(P,m,L):L}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:i,defaultNS:a}=n.useContext(A)||{},o=s||i||I();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new V),!o){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:b(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}o.options.react&&void 0!==o.options.react.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const r={...$(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=r;let u=e||a||o.options&&o.options.defaultNS;u=y(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,a=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(a,e)))}(e,n,t):(d("i18n.languages were undefined or empty",n.languages),!0)}(e,o,r))),f=((e,t,s,i)=>n.useCallback(F(e,t,s,i),[e,t,s,i]))(o,t.lng||null,"fallback"===r.nsMode?u:u[0],c),m=()=>f,v=()=>F(o,t.lng||null,"fallback"===r.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}=r;k.current=!0,p||l||(t.lng?h(o,t.lng,u,(()=>{k.current&&E(v)})):g(o,u,(()=>{k.current&&E(v)}))),p&&O&&O!==N&&k.current&&E(v);const s=()=>{k.current&&E(v)};return e&&o&&o.on(e,s),n&&o&&o.store.on(n,s),()=>{k.current=!1,e&&o&&e.split(" ").forEach((e=>o.off(e,s))),n&&o&&n.split(" ").forEach((e=>o.store.off(e,s)))}}),[o,N]),n.useEffect((()=>{k.current&&p&&E(m)}),[o,c,p]);const w=[x,o,p];if(w.t=x,w.i18n=o,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?h(o,t.lng,u,(()=>e())):g(o,u,(()=>e()))}))};const K=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:i}=s,{i18n:a}=n.useContext(A)||{},o=i||a||I();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=A,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:i}=e;const a=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(A.Provider,{value:a},i)},e.Trans=function(e){let{children:t,count:s,parent:i,i18nKey:a,context:o,tOptions:r={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...h}=e;const{i18n:m,defaultNS:y}=n.useContext(A)||{},b=d||m||I(),v=f||b&&b.t.bind(b);return L({children:t,count:s,parent:i,i18nKey:a,context:o,tOptions:r,values:l,defaults:c,components:u,ns:p||v&&v.ns||y||b&&b.options&&b.options.defaultNS,i18n:b,t:f,shouldUnescape:g,...h})},e.TransWithoutContext=L,e.Translation=function(e){const{ns:n,children:t,...s}=e,[i,a,o]=U(n,s);return t(i,{i18n:a,lng:a.language},o)},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:i,...a}=t;return K(s,i),n.createElement(e,{...a})}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 i(i){let{forwardedRef:a,...o}=i;const[r,l,c]=U(e,{...o,keyPrefix:t.keyPrefix}),u={...o,t:r,i18n:l,tReady:c};return t.withRef&&a?u.ref=a:!t.withRef&&a&&(u.forwardedRef=a),n.createElement(s,u)}i.displayName=`withI18nextTranslation(${m(s)})`,i.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(i,Object.assign({},e,{forwardedRef:t})))):i}}}));
|