react-i18next 15.3.0 → 15.4.1
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 +8 -0
- package/TransWithoutContext.d.ts +36 -0
- package/dist/amd/react-i18next.js +60 -36
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/TransWithoutContext.js +42 -18
- package/dist/commonjs/useTranslation.js +2 -2
- package/dist/commonjs/utils.js +16 -16
- package/dist/es/TransWithoutContext.js +42 -18
- package/dist/es/package.json +1 -1
- package/dist/es/useTranslation.js +2 -2
- package/dist/es/utils.js +16 -10
- package/dist/umd/react-i18next.js +60 -36
- package/dist/umd/react-i18next.min.js +1 -1
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/react-i18next.js +60 -36
- package/react-i18next.min.js +1 -1
- package/src/TransWithoutContext.js +46 -30
- package/src/useTranslation.js +7 -2
- package/src/utils.js +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
### 15.4.1
|
|
2
|
+
|
|
3
|
+
fix: unique key warning on componentized element [1835](https://github.com/i18next/react-i18next/pull/1835)
|
|
4
|
+
|
|
5
|
+
### 15.4.0
|
|
6
|
+
|
|
7
|
+
feat: add meta with codes on warnings to allow conditional logging [1826](https://github.com/i18next/react-i18next/pull/1826)
|
|
8
|
+
|
|
1
9
|
### 15.3.0
|
|
2
10
|
|
|
3
11
|
Uses the i18next logger instead of the default console logger, if there is a valid i18next instance. Now the debug i18next option is respected, and you can also inject your own logger module: https://www.i18next.com/misc/creating-own-plugins#logger
|
package/TransWithoutContext.d.ts
CHANGED
|
@@ -35,3 +35,39 @@ export function Trans<
|
|
|
35
35
|
TOpt extends TOptions & { context?: TContext } = { context: TContext },
|
|
36
36
|
E = React.HTMLProps<HTMLDivElement>,
|
|
37
37
|
>(props: TransProps<Key, Ns, KPrefix, TContext, TOpt, E>): React.ReactElement;
|
|
38
|
+
|
|
39
|
+
export type ErrorCode =
|
|
40
|
+
| 'NO_I18NEXT_INSTANCE'
|
|
41
|
+
| 'NO_LANGUAGES'
|
|
42
|
+
| 'DEPRECATED_OPTION'
|
|
43
|
+
| 'TRANS_NULL_VALUE'
|
|
44
|
+
| 'TRANS_INVALID_OBJ'
|
|
45
|
+
| 'TRANS_INVALID_VAR'
|
|
46
|
+
| 'TRANS_INVALID_COMPONENTS';
|
|
47
|
+
|
|
48
|
+
export type ErrorMeta = {
|
|
49
|
+
code: ErrorCode;
|
|
50
|
+
i18nKey?: string;
|
|
51
|
+
[x: string]: any;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Use to type the logger arguments
|
|
56
|
+
* @example
|
|
57
|
+
* ```
|
|
58
|
+
* import type { ErrorArgs } from 'react-i18next';
|
|
59
|
+
*
|
|
60
|
+
* const logger = {
|
|
61
|
+
* // ....
|
|
62
|
+
* warn: function (...args: ErrorArgs) {
|
|
63
|
+
* if (args[1]?.code === 'TRANS_INVALID_OBJ') {
|
|
64
|
+
* const [msg, { i18nKey, ...rest }] = args;
|
|
65
|
+
* return log(i18nKey, msg, rest);
|
|
66
|
+
* }
|
|
67
|
+
* log(...args);
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
70
|
+
* i18n.use(logger).use(i18nReactPlugin).init({...});
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export type ErrorArgs = readonly [string, ErrorMeta | undefined, ...any[]];
|
|
@@ -114,28 +114,26 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
const warn =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
const warn = (i18n, code, msg, rest) => {
|
|
118
|
+
const args = [msg, {
|
|
119
|
+
code,
|
|
120
|
+
...(rest || {})
|
|
121
|
+
}];
|
|
121
122
|
if (i18n?.services?.logger?.forward) {
|
|
122
|
-
i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
|
|
123
|
-
}
|
|
124
|
-
|
|
123
|
+
return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
|
|
124
|
+
}
|
|
125
|
+
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
126
|
+
if (i18n?.services?.logger?.warn) {
|
|
125
127
|
i18n.services.logger.warn(...args);
|
|
126
128
|
} else if (console?.warn) {
|
|
127
|
-
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
128
129
|
console.warn(...args);
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
132
|
const alreadyWarned = {};
|
|
132
|
-
const warnOnce =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (isString(args[0]) && alreadyWarned[args[0]]) return;
|
|
137
|
-
if (isString(args[0])) alreadyWarned[args[0]] = new Date();
|
|
138
|
-
warn(i18n, ...args);
|
|
133
|
+
const warnOnce = (i18n, code, msg, rest) => {
|
|
134
|
+
if (isString(msg) && alreadyWarned[msg]) return;
|
|
135
|
+
if (isString(msg)) alreadyWarned[msg] = new Date();
|
|
136
|
+
warn(i18n, code, msg, rest);
|
|
139
137
|
};
|
|
140
138
|
const loadedClb = (i18n, cb) => () => {
|
|
141
139
|
if (i18n.isInitialized) {
|
|
@@ -164,7 +162,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
164
162
|
const hasLoadedNamespace = function (ns, i18n) {
|
|
165
163
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
166
164
|
if (!i18n.languages || !i18n.languages.length) {
|
|
167
|
-
warnOnce(i18n, 'i18n.languages were undefined or empty',
|
|
165
|
+
warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
|
|
166
|
+
languages: i18n.languages
|
|
167
|
+
});
|
|
168
168
|
return true;
|
|
169
169
|
}
|
|
170
170
|
return i18n.hasLoadedNamespace(ns, {
|
|
@@ -257,7 +257,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
257
257
|
childrenArray.forEach((child, childIndex) => {
|
|
258
258
|
if (isString(child)) {
|
|
259
259
|
stringNode += `${child}`;
|
|
260
|
-
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (react.isValidElement(child)) {
|
|
261
263
|
const {
|
|
262
264
|
props,
|
|
263
265
|
type
|
|
@@ -267,17 +269,27 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
267
269
|
const childChildren = props.children;
|
|
268
270
|
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
269
271
|
stringNode += `<${type}/>`;
|
|
270
|
-
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
271
275
|
stringNode += `<${childIndex}></${childIndex}>`;
|
|
272
|
-
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
|
|
273
279
|
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
274
|
-
|
|
275
|
-
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
276
|
-
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
280
|
+
return;
|
|
277
281
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
283
|
+
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (child === null) {
|
|
287
|
+
warn(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
|
|
288
|
+
i18nKey
|
|
289
|
+
});
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (isObject(child)) {
|
|
281
293
|
const {
|
|
282
294
|
format,
|
|
283
295
|
...clone
|
|
@@ -286,12 +298,18 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
286
298
|
if (keys.length === 1) {
|
|
287
299
|
const value = format ? `${keys[0]}, ${format}` : keys[0];
|
|
288
300
|
stringNode += `{{${value}}}`;
|
|
289
|
-
|
|
290
|
-
warn(i18n, `react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child, i18nKey);
|
|
301
|
+
return;
|
|
291
302
|
}
|
|
292
|
-
|
|
293
|
-
|
|
303
|
+
warn(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
|
|
304
|
+
i18nKey,
|
|
305
|
+
child
|
|
306
|
+
});
|
|
307
|
+
return;
|
|
294
308
|
}
|
|
309
|
+
warn(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
|
|
310
|
+
i18nKey,
|
|
311
|
+
child
|
|
312
|
+
});
|
|
295
313
|
});
|
|
296
314
|
return stringNode;
|
|
297
315
|
};
|
|
@@ -422,7 +440,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
422
440
|
function Componentized() {
|
|
423
441
|
return react.createElement(react.Fragment, null, comp);
|
|
424
442
|
}
|
|
425
|
-
return react.createElement(Componentized
|
|
443
|
+
return react.createElement(Componentized, {
|
|
444
|
+
key: componentKey
|
|
445
|
+
});
|
|
426
446
|
};
|
|
427
447
|
const generateArrayComponents = (components, translation) => components.map((c, index) => fixComponentProps(c, index, translation));
|
|
428
448
|
const generateObjectComponents = (components, translation) => {
|
|
@@ -434,7 +454,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
434
454
|
});
|
|
435
455
|
return componentMap;
|
|
436
456
|
};
|
|
437
|
-
const generateComponents = (components, translation, i18n) => {
|
|
457
|
+
const generateComponents = (components, translation, i18n, i18nKey) => {
|
|
438
458
|
if (!components) return null;
|
|
439
459
|
if (Array.isArray(components)) {
|
|
440
460
|
return generateArrayComponents(components, translation);
|
|
@@ -442,7 +462,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
442
462
|
if (isObject(components)) {
|
|
443
463
|
return generateObjectComponents(components, translation);
|
|
444
464
|
}
|
|
445
|
-
warnOnce(i18n, '
|
|
465
|
+
warnOnce(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
|
|
466
|
+
i18nKey
|
|
467
|
+
});
|
|
446
468
|
return null;
|
|
447
469
|
};
|
|
448
470
|
function Trans$1(_ref) {
|
|
@@ -464,7 +486,9 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
464
486
|
} = _ref;
|
|
465
487
|
const i18n = i18nFromProps || getI18n();
|
|
466
488
|
if (!i18n) {
|
|
467
|
-
warnOnce(i18n, 'You
|
|
489
|
+
warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
|
|
490
|
+
i18nKey
|
|
491
|
+
});
|
|
468
492
|
return children;
|
|
469
493
|
}
|
|
470
494
|
const t = tFromProps || i18n.t.bind(i18n) || (k => k);
|
|
@@ -505,7 +529,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
505
529
|
ns: namespaces
|
|
506
530
|
};
|
|
507
531
|
const translation = key ? t(key, combinedTOpts) : defaultValue;
|
|
508
|
-
const generatedComponents = generateComponents(components, translation, i18n);
|
|
532
|
+
const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
|
|
509
533
|
const content = renderNodes(generatedComponents || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
|
|
510
534
|
const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
|
|
511
535
|
return useAsParent ? react.createElement(useAsParent, additionalProps, content) : content;
|
|
@@ -619,7 +643,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
619
643
|
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
620
644
|
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
|
|
621
645
|
if (!i18n) {
|
|
622
|
-
warnOnce(i18n, 'You will need to pass in an i18next instance by using initReactI18next');
|
|
646
|
+
warnOnce(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
|
|
623
647
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
624
648
|
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
625
649
|
if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
@@ -631,7 +655,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
|
|
|
631
655
|
retNotReady.ready = false;
|
|
632
656
|
return retNotReady;
|
|
633
657
|
}
|
|
634
|
-
if (i18n.options.react?.wait) warnOnce(i18n, 'It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
658
|
+
if (i18n.options.react?.wait) warnOnce(i18n, 'DEPRECATED_OPTION', 'useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
635
659
|
const i18nOptions = {
|
|
636
660
|
...getDefaults(),
|
|
637
661
|
...i18n.options.react,
|
|
@@ -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}),a=/\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 i=new RegExp(a),o=null;null!==(o=i.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],i.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var i=/<[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(i,(function(i,l){if(u){if(i!=="</"+t.name+">")return;u=!1}var p,d="/"!==i.charAt(1),f=i.startsWith("\x3c!--"),m=l+i.length,g=e.charAt(m);if(f){var h=r(i);return c<0?(s.push(h),s):((p=a[c]).children.push(h),s)}if(d&&(c++,"tag"===(t=r(i)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!g||"<"===g||t.children.push({type:"text",content:e.slice(m,e.indexOf("<",m))}),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===i.slice(2,-1))&&(c--,t=-1===c?s:a[c]),!u&&"<"!==g&&g)){p=-1===c?s:a[c].children;var y=e.indexOf("<",m),v=e.slice(m,-1===y?void 0:y);o.test(v)&&(v=" "),(y>-1&&c+p.length>=0||" "!==v)&&p.push({type:"text",content:v})}})),s};const u=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];e?.services?.logger?.forward?e.services.logger.forward(t,"warn","react-i18next::",!0):e?.services?.logger?.warn?(y(t[0])&&(t[0]=`react-i18next:: ${t[0]}`),e.services.logger.warn(...t)):console?.warn&&(y(t[0])&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t))},p={},d=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];y(t[0])&&p[t[0]]||(y(t[0])&&(p[t[0]]=new Date),u(e,...t))},f=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}},m=(e,n,t)=>{e.loadNamespaces(n,f(e,t))},g=(e,n,t,s)=>{if(y(t)&&(t=[t]),e.options.preload&&e.options.preload.indexOf(n)>-1)return m(e,t,s);t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,f(e,s))},h=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,v=e=>"object"==typeof e&&null!==e,x=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,b={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},E=e=>b[e];let O={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(x,E)};const w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O={...O,...e}},N=()=>O;let $;const k=e=>{$=e},I=()=>$,S=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},j=e=>{if(!e)return[];const n=e.props?.children??e.children;return e.props?.i18nIsDynamicList?R(n):n},R=e=>Array.isArray(e)?e:[e],T=(e,t,s,a)=>{if(!e)return"";let r="";const i=R(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return i.forEach(((e,i)=>{if(y(e))r+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:l}=e,c=Object.keys(n).length,u=o.indexOf(l)>-1,p=n.children;if(p||!u||c)if(!p&&(!u||c)||n.i18nIsDynamicList)r+=`<${i}></${i}>`;else if(u&&1===c&&y(p))r+=`<${l}>${p}</${l}>`;else{const e=T(p,t,s,a);r+=`<${i}>${e}</${i}>`}else r+=`<${l}/>`}else if(null===e)u(s,"Trans: the passed in value is invalid - seems you passed in a null child.");else if(v(e)){const{format:n,...t}=e,i=Object.keys(t);if(1===i.length){const e=n?`${i[0]}, ${n}`:i[0];r+=`{{${e}}}`}else u(s,"react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e,a)}else u(s,"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,a)})),r},C=(e,t,s,a,r,i)=>{if(""===t)return[];const o=a.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!i)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(S(e)?p(j(e)):v(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...r},m=(e,t,s)=>{const a=j(e),r=h(a,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(a)&&0===r.length||e.props?.i18nIsDynamicList?a:r},g=(e,t,s,a,r)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:a},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:a,ref:e.ref},r?null:t)})))},h=(t,r,c)=>{const u=R(t);return R(r).reduce(((t,r,p)=>{const d=r.children?.[0]?.content&&s.services.interpolator.interpolate(r.children[0].content,f,s.language);if("tag"===r.type){let i=u[parseInt(r.name,10)];1!==c.length||i||(i=c[0][r.name]),i||(i={});const x=0!==Object.keys(r.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:r.attrs},i):i,b=n.isValidElement(x),E=b&&S(r,!0)&&!r.voidElement,O=l&&v(x)&&x.dummy&&!b,w=v(e)&&Object.hasOwnProperty.call(e,r.name);if(y(x)){const e=s.services.interpolator.interpolate(x,f,s.language);t.push(e)}else if(S(x)||E){const e=m(x,r,c);g(x,e,t,p)}else if(O){const e=h(u,r.children,c);g(x,e,t,p)}else if(Number.isNaN(parseFloat(r.name)))if(w){const e=m(x,r,c);g(x,e,t,p,r.voidElement)}else if(a.transSupportBasicHtmlNodes&&o.indexOf(r.name)>-1)if(r.voidElement)t.push(n.createElement(r.name,{key:`${r.name}-${p}`}));else{const e=h(u,r.children,c);t.push(n.createElement(r.name,{key:`${r.name}-${p}`},e))}else if(r.voidElement)t.push(`<${r.name} />`);else{const e=h(u,r.children,c);t.push(`<${r.name}>${e}</${r.name}>`)}else if(v(x)&&!b){const e=r.children[0]?d:null;e&&t.push(e)}else g(x,d,t,p,1!==r.children.length||!d)}else if("text"===r.type){const e=a.transWrapTextNodes,o=i?a.unescape(s.services.interpolator.interpolate(r.content,f,s.language)):s.services.interpolator.interpolate(r.content,f,s.language);e?t.push(n.createElement(e,{key:`${r.name}-${p}`},o)):t.push(o)}return t}),[])},x=h([{dummy:!0,children:e||[]}],d,R(e||[]));return j(x[0])},A=(e,t,s)=>{const a=e.key||t,r=n.cloneElement(e,{key:a});if(!r.props||!r.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return r;return n.createElement((function(){return n.createElement(n.Fragment,null,r)}))},P=(e,n,t)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>A(e,t,n))))(e,n):v(e)?((e,n)=>{const t={};return Object.keys(e).forEach((s=>{Object.assign(t,{[s]:A(e[s],s,n)})})),t})(e,n):(d(t,"<Trans /> component prop expects an object or an array"),null):null;function L(e){let{children:t,count:s,parent:a,i18nKey:r,context:i,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:m,shouldUnescape:g,...h}=e;const v=f||I();if(!v)return d(v,"You will need to pass in an i18next instance by using i18nextReactModule"),t;const x=m||v.t.bind(v)||(e=>e),b={...N(),...v.options?.react};let E=p||x.ns||v.options?.defaultNS;E=y(E)?[E]:E||["translation"];const O=T(t,b,v,r),w=c||O||b.transEmptyNodeValue||r,{hashTransKey:$}=b,k=r||($?$(O||w):O||w);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&&!v.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},j={...o,context:i||o.context,count:s,...l,...S,defaultValue:w,ns:E},R=k?x(k,j):w,A=P(u,R,v),L=C(A||t,R,v,b,j,g),V=a??b.defaultTransParent;return V?n.createElement(V,h,L):L}const V={type:"3rdParty",init(e){w(e.options.react),k(e)}},z=n.createContext();class F{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const U=e=>async n=>({...await(e.getInitialProps?.(n))??{},...B()}),B=()=>{const e=I(),n=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 D=(e,n,t,s)=>e.getFixedT(n,t,s),K=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:a,defaultNS:r}=n.useContext(z)||{},i=s||a||I();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new F),!i){d(i,"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}i.options.react?.wait&&d(i,"It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...N(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||r||i.options?.defaultNS;u=y(u)?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces?.(u);const p=(i.isInitialized||i.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n?.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):(d(n,"i18n.languages were undefined or empty",n.languages),!0)}(e,i,o))),f=((e,t,s,a)=>n.useCallback(D(e,t,s,a),[e,t,s,a]))(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,x=()=>D(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[b,E]=n.useState(h);let O=u.join();t.lng&&(O=`${t.lng}${O}`);const w=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(O),$=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;$.current=!0,p||l||(t.lng?g(i,t.lng,u,(()=>{$.current&&E(x)})):m(i,u,(()=>{$.current&&E(x)}))),p&&w&&w!==O&&$.current&&E(x);const s=()=>{$.current&&E(x)};return e&&i?.on(e,s),n&&i?.store.on(n,s),()=>{$.current=!1,i&&e?.split(" ").forEach((e=>i.off(e,s))),n&&i&&n.split(" ").forEach((e=>i.store.off(e,s)))}}),[i,O]),n.useEffect((()=>{$.current&&p&&E(h)}),[i,c,p]);const k=[b,i,p];if(k.t=b,k.i18n=i,k.ready=p,p)return k;if(!p&&!l)return k;throw new Promise((e=>{t.lng?g(i,t.lng,u,(()=>e())):m(i,u,(()=>e()))}))};const W=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:a}=s,{i18n:r}=n.useContext(z)||{},i=a||r||I();i.options?.isClone||(e&&!i.initializedStoreOnce&&(i.services.resourceStore.data=e,i.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),i.options.ns),i.initializedStoreOnce=!0,i.isInitialized=!0),t&&!i.initializedLanguageOnce&&(i.changeLanguage(t),i.initializedLanguageOnce=!0))};e.I18nContext=z,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:a}=e;const r=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(z.Provider,{value:r},a)},e.Trans=function(e){let{children:t,count:s,parent:a,i18nKey:r,context:i,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:m,...g}=e;const{i18n:h,defaultNS:y}=n.useContext(z)||{},v=d||h||I(),x=f||v?.t.bind(v);return L({children:t,count:s,parent:a,i18nKey:r,context:i,tOptions:o,values:l,defaults:c,components:u,ns:p||x?.ns||y||v?.options?.defaultNS,i18n:v,t:f,shouldUnescape:m,...g})},e.TransWithoutContext=L,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[a,r,i]=K(n,s);return t(a,{i18n:r,lng:r.language},i)},e.composeInitialProps=U,e.date=()=>"",e.getDefaults=N,e.getI18n=I,e.getInitialProps=B,e.initReactI18next=V,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=w,e.setI18n=k,e.time=()=>"",e.useSSR=W,e.useTranslation=K,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:a,...r}=t;return W(s,a),n.createElement(e,{...r})}return t.getInitialProps=U(e),t.displayName=`withI18nextSSR(${h(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:r,...i}=a;const[o,l,c]=K(e,{...i,keyPrefix:t.keyPrefix}),u={...i,t:o,i18n:l,tReady:c};return t.withRef&&r?u.ref=r:!t.withRef&&r&&(u.forwardedRef=r),n.createElement(s,u)}a.displayName=`withI18nextTranslation(${h(s)})`,a.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(a,Object.assign({},e,{forwardedRef:t})))):a}}}));
|
|
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}),r=/\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 i=new RegExp(r),o=null;null!==(o=i.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],i.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var i=/<[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=[],r=[],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(i,(function(i,l){if(u){if(i!=="</"+t.name+">")return;u=!1}var p,d="/"!==i.charAt(1),f=i.startsWith("\x3c!--"),g=l+i.length,m=e.charAt(g);if(f){var h=a(i);return c<0?(s.push(h),s):((p=r[c]).children.push(h),s)}if(d&&(c++,"tag"===(t=a(i)).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===c&&s.push(t),(p=r[c-1])&&p.children.push(t),r[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===i.slice(2,-1))&&(c--,t=-1===c?s:r[c]),!u&&"<"!==m&&m)){p=-1===c?s:r[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};const u=(e,n,t,s)=>{const r=[t,{code:n,...s||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(r,"warn","react-i18next::",!0);y(r[0])&&(r[0]=`react-i18next:: ${r[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...r):console?.warn&&console.warn(...r)},p={},d=(e,n,t,s)=>{y(t)&&p[t]||(y(t)&&(p[t]=new Date),u(e,n,t,s))},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))},m=(e,n,t,s)=>{if(y(t)&&(t=[t]),e.options.preload&&e.options.preload.indexOf(n)>-1)return g(e,t,s);t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,f(e,s))},h=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,v=e=>"object"==typeof e&&null!==e,N=/&(?: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 b={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(N,E)};const O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b={...b,...e}},I=()=>b;let S;const w=e=>{S=e},$=()=>S,k=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},T=e=>{if(!e)return[];const n=e.props?.children??e.children;return e.props?.i18nIsDynamicList?A(n):n},A=e=>Array.isArray(e)?e:[e],R=(e,t,s,r)=>{if(!e)return"";let a="";const i=A(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return i.forEach(((e,i)=>{if(y(e))a+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:l}=e,c=Object.keys(n).length,u=o.indexOf(l)>-1,p=n.children;if(!p&&u&&!c)return void(a+=`<${l}/>`);if(!p&&(!u||c)||n.i18nIsDynamicList)return void(a+=`<${i}></${i}>`);if(u&&1===c&&y(p))return void(a+=`<${l}>${p}</${l}>`);const d=R(p,t,s,r);a+=`<${i}>${d}</${i}>`}else if(null!==e)if(v(e)){const{format:n,...t}=e,i=Object.keys(t);if(1===i.length){const e=n?`${i[0]}, ${n}`:i[0];return void(a+=`{{${e}}}`)}u(s,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:r,child:e})}else u(s,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:r,child:e});else u(s,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:r})})),a},j=(e,t,s,r,a,i)=>{if(""===t)return[];const o=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!i)return[t];const u={},p=e=>{A(e).forEach((e=>{y(e)||(k(e)?p(T(e)):v(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...a},g=(e,t,s)=>{const r=T(e),a=h(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===a.length||e.props?.i18nIsDynamicList?r:a},m=(e,t,s,r,a)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:r},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:r,ref:e.ref},a?null:t)})))},h=(t,a,c)=>{const u=A(t);return A(a).reduce(((t,a,p)=>{const d=a.children?.[0]?.content&&s.services.interpolator.interpolate(a.children[0].content,f,s.language);if("tag"===a.type){let i=u[parseInt(a.name,10)];1!==c.length||i||(i=c[0][a.name]),i||(i={});const N=0!==Object.keys(a.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:a.attrs},i):i,x=n.isValidElement(N),E=x&&k(a,!0)&&!a.voidElement,b=l&&v(N)&&N.dummy&&!x,O=v(e)&&Object.hasOwnProperty.call(e,a.name);if(y(N)){const e=s.services.interpolator.interpolate(N,f,s.language);t.push(e)}else if(k(N)||E){const e=g(N,a,c);m(N,e,t,p)}else if(b){const e=h(u,a.children,c);m(N,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=g(N,a,c);m(N,e,t,p,a.voidElement)}else if(r.transSupportBasicHtmlNodes&&o.indexOf(a.name)>-1)if(a.voidElement)t.push(n.createElement(a.name,{key:`${a.name}-${p}`}));else{const e=h(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=h(u,a.children,c);t.push(`<${a.name}>${e}</${a.name}>`)}else if(v(N)&&!x){const e=a.children[0]?d:null;e&&t.push(e)}else m(N,d,t,p,1!==a.children.length||!d)}else if("text"===a.type){const e=r.transWrapTextNodes,o=i?r.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}`},o)):t.push(o)}return t}),[])},N=h([{dummy:!0,children:e||[]}],d,A(e||[]));return T(N[0])},C=(e,t,s)=>{const r=e.key||t,a=n.cloneElement(e,{key:r});if(!a.props||!a.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return a;return n.createElement((function(){return n.createElement(n.Fragment,null,a)}),{key:r})},L=(e,n,t,s)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>C(e,t,n))))(e,n):v(e)?((e,n)=>{const t={};return Object.keys(e).forEach((s=>{Object.assign(t,{[s]:C(e[s],s,n)})})),t})(e,n):(d(t,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:s}),null):null;function P(e){let{children:t,count:s,parent:r,i18nKey:a,context:i,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:m,...h}=e;const v=f||$();if(!v)return d(v,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:a}),t;const N=g||v.t.bind(v)||(e=>e),x={...I(),...v.options?.react};let E=p||N.ns||v.options?.defaultNS;E=y(E)?[E]:E||["translation"];const b=R(t,x,v,a),O=c||b||x.transEmptyNodeValue||a,{hashTransKey:S}=x,w=a||(S?S(b||O):b||O);v.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables});const k=l||void 0!==s&&!v.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},T={...o,context:i||o.context,count:s,...l,...k,defaultValue:O,ns:E},A=w?N(w,T):O,C=L(u,A,v,a),P=j(C||t,A,v,x,T,m),V=r??x.defaultTransParent;return V?n.createElement(V,h,P):P}const V={type:"3rdParty",init(e){O(e.options.react),w(e)}},_=n.createContext();class D{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const K=e=>async n=>({...await(e.getInitialProps?.(n))??{},...z()}),z=()=>{const e=$(),n=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 U=(e,n,t,s)=>e.getFixedT(n,t,s),F=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:r,defaultNS:a}=n.useContext(_)||{},i=s||r||$();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new D),!i){d(i,"NO_I18NEXT_INSTANCE","useTranslation: 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}i.options.react?.wait&&d(i,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...I(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||a||i.options?.defaultNS;u=y(u)?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces?.(u);const p=(i.isInitialized||i.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n?.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):(d(n,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:n.languages}),!0)}(e,i,o))),f=((e,t,s,r)=>n.useCallback(U(e,t,s,r),[e,t,s,r]))(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,N=()=>U(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[x,E]=n.useState(h);let b=u.join();t.lng&&(b=`${t.lng}${b}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(b),S=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;S.current=!0,p||l||(t.lng?m(i,t.lng,u,(()=>{S.current&&E(N)})):g(i,u,(()=>{S.current&&E(N)}))),p&&O&&O!==b&&S.current&&E(N);const s=()=>{S.current&&E(N)};return e&&i?.on(e,s),n&&i?.store.on(n,s),()=>{S.current=!1,i&&e?.split(" ").forEach((e=>i.off(e,s))),n&&i&&n.split(" ").forEach((e=>i.store.off(e,s)))}}),[i,b]),n.useEffect((()=>{S.current&&p&&E(h)}),[i,c,p]);const w=[x,i,p];if(w.t=x,w.i18n=i,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?m(i,t.lng,u,(()=>e())):g(i,u,(()=>e()))}))};const B=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:r}=s,{i18n:a}=n.useContext(_)||{},i=r||a||$();i.options?.isClone||(e&&!i.initializedStoreOnce&&(i.services.resourceStore.data=e,i.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),i.options.ns),i.initializedStoreOnce=!0,i.isInitialized=!0),t&&!i.initializedLanguageOnce&&(i.changeLanguage(t),i.initializedLanguageOnce=!0))};e.I18nContext=_,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:r}=e;const a=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(_.Provider,{value:a},r)},e.Trans=function(e){let{children:t,count:s,parent:r,i18nKey:a,context:i,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...m}=e;const{i18n:h,defaultNS:y}=n.useContext(_)||{},v=d||h||$(),N=f||v?.t.bind(v);return P({children:t,count:s,parent:r,i18nKey:a,context:i,tOptions:o,values:l,defaults:c,components:u,ns:p||N?.ns||y||v?.options?.defaultNS,i18n:v,t:f,shouldUnescape:g,...m})},e.TransWithoutContext=P,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[r,a,i]=F(n,s);return t(r,{i18n:a,lng:a.language},i)},e.composeInitialProps=K,e.date=()=>"",e.getDefaults=I,e.getI18n=$,e.getInitialProps=z,e.initReactI18next=V,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=B,e.useTranslation=F,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:r,...a}=t;return B(s,r),n.createElement(e,{...a})}return t.getInitialProps=K(e),t.displayName=`withI18nextSSR(${h(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function r(r){let{forwardedRef:a,...i}=r;const[o,l,c]=F(e,{...i,keyPrefix:t.keyPrefix}),u={...i,t:o,i18n:l,tReady:c};return t.withRef&&a?u.ref=a:!t.withRef&&a&&(u.forwardedRef=a),n.createElement(s,u)}r.displayName=`withI18nextTranslation(${h(s)})`,r.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(r,Object.assign({},e,{forwardedRef:t})))):r}}}));
|
|
@@ -39,7 +39,9 @@ const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
|
39
39
|
childrenArray.forEach((child, childIndex) => {
|
|
40
40
|
if ((0, _utils.isString)(child)) {
|
|
41
41
|
stringNode += `${child}`;
|
|
42
|
-
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if ((0, _react.isValidElement)(child)) {
|
|
43
45
|
const {
|
|
44
46
|
props,
|
|
45
47
|
type
|
|
@@ -49,17 +51,27 @@ const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
|
49
51
|
const childChildren = props.children;
|
|
50
52
|
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
51
53
|
stringNode += `<${type}/>`;
|
|
52
|
-
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
53
57
|
stringNode += `<${childIndex}></${childIndex}>`;
|
|
54
|
-
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (shouldKeepChild && childPropsCount === 1 && (0, _utils.isString)(childChildren)) {
|
|
55
61
|
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
56
|
-
|
|
57
|
-
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
58
|
-
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
62
|
+
return;
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
65
|
+
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (child === null) {
|
|
69
|
+
(0, _utils.warn)(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
|
|
70
|
+
i18nKey
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if ((0, _utils.isObject)(child)) {
|
|
63
75
|
const {
|
|
64
76
|
format,
|
|
65
77
|
...clone
|
|
@@ -68,12 +80,18 @@ const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
|
68
80
|
if (keys.length === 1) {
|
|
69
81
|
const value = format ? `${keys[0]}, ${format}` : keys[0];
|
|
70
82
|
stringNode += `{{${value}}}`;
|
|
71
|
-
|
|
72
|
-
(0, _utils.warn)(i18n, `react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child, i18nKey);
|
|
83
|
+
return;
|
|
73
84
|
}
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
(0, _utils.warn)(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
|
|
86
|
+
i18nKey,
|
|
87
|
+
child
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
76
90
|
}
|
|
91
|
+
(0, _utils.warn)(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
|
|
92
|
+
i18nKey,
|
|
93
|
+
child
|
|
94
|
+
});
|
|
77
95
|
});
|
|
78
96
|
return stringNode;
|
|
79
97
|
};
|
|
@@ -205,7 +223,9 @@ const fixComponentProps = (component, index, translation) => {
|
|
|
205
223
|
function Componentized() {
|
|
206
224
|
return (0, _react.createElement)(_react.Fragment, null, comp);
|
|
207
225
|
}
|
|
208
|
-
return (0, _react.createElement)(Componentized
|
|
226
|
+
return (0, _react.createElement)(Componentized, {
|
|
227
|
+
key: componentKey
|
|
228
|
+
});
|
|
209
229
|
};
|
|
210
230
|
const generateArrayComponents = (components, translation) => components.map((c, index) => fixComponentProps(c, index, translation));
|
|
211
231
|
const generateObjectComponents = (components, translation) => {
|
|
@@ -217,7 +237,7 @@ const generateObjectComponents = (components, translation) => {
|
|
|
217
237
|
});
|
|
218
238
|
return componentMap;
|
|
219
239
|
};
|
|
220
|
-
const generateComponents = (components, translation, i18n) => {
|
|
240
|
+
const generateComponents = (components, translation, i18n, i18nKey) => {
|
|
221
241
|
if (!components) return null;
|
|
222
242
|
if (Array.isArray(components)) {
|
|
223
243
|
return generateArrayComponents(components, translation);
|
|
@@ -225,7 +245,9 @@ const generateComponents = (components, translation, i18n) => {
|
|
|
225
245
|
if ((0, _utils.isObject)(components)) {
|
|
226
246
|
return generateObjectComponents(components, translation);
|
|
227
247
|
}
|
|
228
|
-
(0, _utils.warnOnce)(i18n, '
|
|
248
|
+
(0, _utils.warnOnce)(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
|
|
249
|
+
i18nKey
|
|
250
|
+
});
|
|
229
251
|
return null;
|
|
230
252
|
};
|
|
231
253
|
function Trans(_ref) {
|
|
@@ -247,7 +269,9 @@ function Trans(_ref) {
|
|
|
247
269
|
} = _ref;
|
|
248
270
|
const i18n = i18nFromProps || (0, _i18nInstance.getI18n)();
|
|
249
271
|
if (!i18n) {
|
|
250
|
-
(0, _utils.warnOnce)(i18n, 'You
|
|
272
|
+
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
|
|
273
|
+
i18nKey
|
|
274
|
+
});
|
|
251
275
|
return children;
|
|
252
276
|
}
|
|
253
277
|
const t = tFromProps || i18n.t.bind(i18n) || (k => k);
|
|
@@ -288,7 +312,7 @@ function Trans(_ref) {
|
|
|
288
312
|
ns: namespaces
|
|
289
313
|
};
|
|
290
314
|
const translation = key ? t(key, combinedTOpts) : defaultValue;
|
|
291
|
-
const generatedComponents = generateComponents(components, translation, i18n);
|
|
315
|
+
const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
|
|
292
316
|
const content = renderNodes(generatedComponents || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
|
|
293
317
|
const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
|
|
294
318
|
return useAsParent ? (0, _react.createElement)(useAsParent, additionalProps, content) : content;
|
|
@@ -28,7 +28,7 @@ const useTranslation = function (ns) {
|
|
|
28
28
|
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
|
|
29
29
|
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new _context.ReportNamespaces();
|
|
30
30
|
if (!i18n) {
|
|
31
|
-
(0, _utils.warnOnce)(i18n, 'You will need to pass in an i18next instance by using initReactI18next');
|
|
31
|
+
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
|
|
32
32
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
33
33
|
if ((0, _utils.isString)(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
34
34
|
if ((0, _utils.isObject)(optsOrDefaultValue) && (0, _utils.isString)(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
@@ -40,7 +40,7 @@ const useTranslation = function (ns) {
|
|
|
40
40
|
retNotReady.ready = false;
|
|
41
41
|
return retNotReady;
|
|
42
42
|
}
|
|
43
|
-
if (i18n.options.react?.wait) (0, _utils.warnOnce)(i18n, 'It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
43
|
+
if (i18n.options.react?.wait) (0, _utils.warnOnce)(i18n, 'DEPRECATED_OPTION', 'useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
44
44
|
const i18nOptions = {
|
|
45
45
|
...(0, _context.getDefaults)(),
|
|
46
46
|
...i18n.options.react,
|
package/dist/commonjs/utils.js
CHANGED
|
@@ -4,29 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.warnOnce = exports.warn = exports.loadNamespaces = exports.loadLanguages = exports.isString = exports.isObject = exports.hasLoadedNamespace = exports.getDisplayName = void 0;
|
|
7
|
-
const warn =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const warn = (i18n, code, msg, rest) => {
|
|
8
|
+
const args = [msg, {
|
|
9
|
+
code,
|
|
10
|
+
...(rest || {})
|
|
11
|
+
}];
|
|
11
12
|
if (i18n?.services?.logger?.forward) {
|
|
12
|
-
i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
|
|
13
|
-
}
|
|
14
|
-
|
|
13
|
+
return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
|
|
14
|
+
}
|
|
15
|
+
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
16
|
+
if (i18n?.services?.logger?.warn) {
|
|
15
17
|
i18n.services.logger.warn(...args);
|
|
16
18
|
} else if (console?.warn) {
|
|
17
|
-
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
18
19
|
console.warn(...args);
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
exports.warn = warn;
|
|
22
23
|
const alreadyWarned = {};
|
|
23
|
-
const warnOnce =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (isString(args[0]) && alreadyWarned[args[0]]) return;
|
|
28
|
-
if (isString(args[0])) alreadyWarned[args[0]] = new Date();
|
|
29
|
-
warn(i18n, ...args);
|
|
24
|
+
const warnOnce = (i18n, code, msg, rest) => {
|
|
25
|
+
if (isString(msg) && alreadyWarned[msg]) return;
|
|
26
|
+
if (isString(msg)) alreadyWarned[msg] = new Date();
|
|
27
|
+
warn(i18n, code, msg, rest);
|
|
30
28
|
};
|
|
31
29
|
exports.warnOnce = warnOnce;
|
|
32
30
|
const loadedClb = (i18n, cb) => () => {
|
|
@@ -58,7 +56,9 @@ exports.loadLanguages = loadLanguages;
|
|
|
58
56
|
const hasLoadedNamespace = function (ns, i18n) {
|
|
59
57
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
60
58
|
if (!i18n.languages || !i18n.languages.length) {
|
|
61
|
-
warnOnce(i18n, 'i18n.languages were undefined or empty',
|
|
59
|
+
warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
|
|
60
|
+
languages: i18n.languages
|
|
61
|
+
});
|
|
62
62
|
return true;
|
|
63
63
|
}
|
|
64
64
|
return i18n.hasLoadedNamespace(ns, {
|
|
@@ -31,7 +31,9 @@ export const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
|
31
31
|
childrenArray.forEach((child, childIndex) => {
|
|
32
32
|
if (isString(child)) {
|
|
33
33
|
stringNode += `${child}`;
|
|
34
|
-
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (isValidElement(child)) {
|
|
35
37
|
const {
|
|
36
38
|
props,
|
|
37
39
|
type
|
|
@@ -41,17 +43,27 @@ export const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
|
41
43
|
const childChildren = props.children;
|
|
42
44
|
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
43
45
|
stringNode += `<${type}/>`;
|
|
44
|
-
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
45
49
|
stringNode += `<${childIndex}></${childIndex}>`;
|
|
46
|
-
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
|
|
47
53
|
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
48
|
-
|
|
49
|
-
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
50
|
-
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
54
|
+
return;
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
57
|
+
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (child === null) {
|
|
61
|
+
warn(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
|
|
62
|
+
i18nKey
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (isObject(child)) {
|
|
55
67
|
const {
|
|
56
68
|
format,
|
|
57
69
|
...clone
|
|
@@ -60,12 +72,18 @@ export const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
|
60
72
|
if (keys.length === 1) {
|
|
61
73
|
const value = format ? `${keys[0]}, ${format}` : keys[0];
|
|
62
74
|
stringNode += `{{${value}}}`;
|
|
63
|
-
|
|
64
|
-
warn(i18n, `react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child, i18nKey);
|
|
75
|
+
return;
|
|
65
76
|
}
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
warn(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
|
|
78
|
+
i18nKey,
|
|
79
|
+
child
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
68
82
|
}
|
|
83
|
+
warn(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
|
|
84
|
+
i18nKey,
|
|
85
|
+
child
|
|
86
|
+
});
|
|
69
87
|
});
|
|
70
88
|
return stringNode;
|
|
71
89
|
};
|
|
@@ -196,7 +214,9 @@ const fixComponentProps = (component, index, translation) => {
|
|
|
196
214
|
function Componentized() {
|
|
197
215
|
return createElement(Fragment, null, comp);
|
|
198
216
|
}
|
|
199
|
-
return createElement(Componentized
|
|
217
|
+
return createElement(Componentized, {
|
|
218
|
+
key: componentKey
|
|
219
|
+
});
|
|
200
220
|
};
|
|
201
221
|
const generateArrayComponents = (components, translation) => components.map((c, index) => fixComponentProps(c, index, translation));
|
|
202
222
|
const generateObjectComponents = (components, translation) => {
|
|
@@ -208,7 +228,7 @@ const generateObjectComponents = (components, translation) => {
|
|
|
208
228
|
});
|
|
209
229
|
return componentMap;
|
|
210
230
|
};
|
|
211
|
-
const generateComponents = (components, translation, i18n) => {
|
|
231
|
+
const generateComponents = (components, translation, i18n, i18nKey) => {
|
|
212
232
|
if (!components) return null;
|
|
213
233
|
if (Array.isArray(components)) {
|
|
214
234
|
return generateArrayComponents(components, translation);
|
|
@@ -216,7 +236,9 @@ const generateComponents = (components, translation, i18n) => {
|
|
|
216
236
|
if (isObject(components)) {
|
|
217
237
|
return generateObjectComponents(components, translation);
|
|
218
238
|
}
|
|
219
|
-
warnOnce(i18n, '
|
|
239
|
+
warnOnce(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
|
|
240
|
+
i18nKey
|
|
241
|
+
});
|
|
220
242
|
return null;
|
|
221
243
|
};
|
|
222
244
|
export function Trans({
|
|
@@ -237,7 +259,9 @@ export function Trans({
|
|
|
237
259
|
}) {
|
|
238
260
|
const i18n = i18nFromProps || getI18n();
|
|
239
261
|
if (!i18n) {
|
|
240
|
-
warnOnce(i18n, 'You
|
|
262
|
+
warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
|
|
263
|
+
i18nKey
|
|
264
|
+
});
|
|
241
265
|
return children;
|
|
242
266
|
}
|
|
243
267
|
const t = tFromProps || i18n.t.bind(i18n) || (k => k);
|
|
@@ -278,7 +302,7 @@ export function Trans({
|
|
|
278
302
|
ns: namespaces
|
|
279
303
|
};
|
|
280
304
|
const translation = key ? t(key, combinedTOpts) : defaultValue;
|
|
281
|
-
const generatedComponents = generateComponents(components, translation, i18n);
|
|
305
|
+
const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
|
|
282
306
|
const content = renderNodes(generatedComponents || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
|
|
283
307
|
const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
|
|
284
308
|
return useAsParent ? createElement(useAsParent, additionalProps, content) : content;
|
package/dist/es/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"15.
|
|
1
|
+
{"type":"module","version":"15.4.1"}
|
|
@@ -21,7 +21,7 @@ export const useTranslation = (ns, props = {}) => {
|
|
|
21
21
|
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
22
22
|
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
|
|
23
23
|
if (!i18n) {
|
|
24
|
-
warnOnce(i18n, 'You will need to pass in an i18next instance by using initReactI18next');
|
|
24
|
+
warnOnce(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
|
|
25
25
|
const notReadyT = (k, optsOrDefaultValue) => {
|
|
26
26
|
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
27
27
|
if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
@@ -33,7 +33,7 @@ export const useTranslation = (ns, props = {}) => {
|
|
|
33
33
|
retNotReady.ready = false;
|
|
34
34
|
return retNotReady;
|
|
35
35
|
}
|
|
36
|
-
if (i18n.options.react?.wait) warnOnce(i18n, 'It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
36
|
+
if (i18n.options.react?.wait) warnOnce(i18n, 'DEPRECATED_OPTION', 'useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
|
|
37
37
|
const i18nOptions = {
|
|
38
38
|
...getDefaults(),
|
|
39
39
|
...i18n.options.react,
|