react-i18next 15.2.0 → 15.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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('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('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,
package/dist/es/utils.js CHANGED
@@ -1,14 +1,23 @@
1
- export const warn = (...args) => {
2
- if (console?.warn) {
3
- if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
1
+ export const warn = (i18n, code, msg, rest) => {
2
+ const args = [msg, {
3
+ code,
4
+ ...(rest || {})
5
+ }];
6
+ if (i18n?.services?.logger?.forward) {
7
+ return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
8
+ }
9
+ if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
10
+ if (i18n?.services?.logger?.warn) {
11
+ i18n.services.logger.warn(...args);
12
+ } else if (console?.warn) {
4
13
  console.warn(...args);
5
14
  }
6
15
  };
7
16
  const alreadyWarned = {};
8
- export const warnOnce = (...args) => {
9
- if (isString(args[0]) && alreadyWarned[args[0]]) return;
10
- if (isString(args[0])) alreadyWarned[args[0]] = new Date();
11
- warn(...args);
17
+ export const warnOnce = (i18n, code, msg, rest) => {
18
+ if (isString(msg) && alreadyWarned[msg]) return;
19
+ if (isString(msg)) alreadyWarned[msg] = new Date();
20
+ warn(i18n, code, msg, rest);
12
21
  };
13
22
  const loadedClb = (i18n, cb) => () => {
14
23
  if (i18n.isInitialized) {
@@ -36,7 +45,9 @@ export const loadLanguages = (i18n, lng, ns, cb) => {
36
45
  };
37
46
  export const hasLoadedNamespace = (ns, i18n, options = {}) => {
38
47
  if (!i18n.languages || !i18n.languages.length) {
39
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
48
+ warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
49
+ languages: i18n.languages
50
+ });
40
51
  return true;
41
52
  }
42
53
  return i18n.hasLoadedNamespace(ns, {
@@ -118,23 +118,26 @@
118
118
  }
119
119
  };
120
120
 
121
- const warn = function () {
122
- if (console?.warn) {
123
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
124
- args[_key] = arguments[_key];
125
- }
126
- if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
121
+ const warn = (i18n, code, msg, rest) => {
122
+ const args = [msg, {
123
+ code,
124
+ ...(rest || {})
125
+ }];
126
+ if (i18n?.services?.logger?.forward) {
127
+ return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
128
+ }
129
+ if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
130
+ if (i18n?.services?.logger?.warn) {
131
+ i18n.services.logger.warn(...args);
132
+ } else if (console?.warn) {
127
133
  console.warn(...args);
128
134
  }
129
135
  };
130
136
  const alreadyWarned = {};
131
- const warnOnce = function () {
132
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
133
- args[_key2] = arguments[_key2];
134
- }
135
- if (isString(args[0]) && alreadyWarned[args[0]]) return;
136
- if (isString(args[0])) alreadyWarned[args[0]] = new Date();
137
- warn(...args);
137
+ const warnOnce = (i18n, code, msg, rest) => {
138
+ if (isString(msg) && alreadyWarned[msg]) return;
139
+ if (isString(msg)) alreadyWarned[msg] = new Date();
140
+ warn(i18n, code, msg, rest);
138
141
  };
139
142
  const loadedClb = (i18n, cb) => () => {
140
143
  if (i18n.isInitialized) {
@@ -163,7 +166,9 @@
163
166
  const hasLoadedNamespace = function (ns, i18n) {
164
167
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
165
168
  if (!i18n.languages || !i18n.languages.length) {
166
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
169
+ warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
170
+ languages: i18n.languages
171
+ });
167
172
  return true;
168
173
  }
169
174
  return i18n.hasLoadedNamespace(ns, {
@@ -248,7 +253,7 @@
248
253
  newTarget.props = Object.assign(source.props, target.props);
249
254
  return newTarget;
250
255
  };
251
- const nodesToString = (children, i18nOptions) => {
256
+ const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
252
257
  if (!children) return '';
253
258
  let stringNode = '';
254
259
  const childrenArray = getAsArray(children);
@@ -256,7 +261,9 @@
256
261
  childrenArray.forEach((child, childIndex) => {
257
262
  if (isString(child)) {
258
263
  stringNode += `${child}`;
259
- } else if (react.isValidElement(child)) {
264
+ return;
265
+ }
266
+ if (react.isValidElement(child)) {
260
267
  const {
261
268
  props,
262
269
  type
@@ -266,17 +273,27 @@
266
273
  const childChildren = props.children;
267
274
  if (!childChildren && shouldKeepChild && !childPropsCount) {
268
275
  stringNode += `<${type}/>`;
269
- } else if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
276
+ return;
277
+ }
278
+ if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
270
279
  stringNode += `<${childIndex}></${childIndex}>`;
271
- } else if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
280
+ return;
281
+ }
282
+ if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
272
283
  stringNode += `<${type}>${childChildren}</${type}>`;
273
- } else {
274
- const content = nodesToString(childChildren, i18nOptions);
275
- stringNode += `<${childIndex}>${content}</${childIndex}>`;
284
+ return;
276
285
  }
277
- } else if (child === null) {
278
- warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
279
- } else if (isObject(child)) {
286
+ const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
287
+ stringNode += `<${childIndex}>${content}</${childIndex}>`;
288
+ return;
289
+ }
290
+ if (child === null) {
291
+ warn(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
292
+ i18nKey
293
+ });
294
+ return;
295
+ }
296
+ if (isObject(child)) {
280
297
  const {
281
298
  format,
282
299
  ...clone
@@ -285,12 +302,18 @@
285
302
  if (keys.length === 1) {
286
303
  const value = format ? `${keys[0]}, ${format}` : keys[0];
287
304
  stringNode += `{{${value}}}`;
288
- } else {
289
- warn(`react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child);
305
+ return;
290
306
  }
291
- } else {
292
- warn(`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}}.`, child);
307
+ warn(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
308
+ i18nKey,
309
+ child
310
+ });
311
+ return;
293
312
  }
313
+ warn(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
314
+ i18nKey,
315
+ child
316
+ });
294
317
  });
295
318
  return stringNode;
296
319
  };
@@ -433,7 +456,7 @@
433
456
  });
434
457
  return componentMap;
435
458
  };
436
- const generateComponents = (components, translation) => {
459
+ const generateComponents = (components, translation, i18n, i18nKey) => {
437
460
  if (!components) return null;
438
461
  if (Array.isArray(components)) {
439
462
  return generateArrayComponents(components, translation);
@@ -441,7 +464,9 @@
441
464
  if (isObject(components)) {
442
465
  return generateObjectComponents(components, translation);
443
466
  }
444
- warnOnce('<Trans /> component prop expects an object or an array');
467
+ warnOnce(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
468
+ i18nKey
469
+ });
445
470
  return null;
446
471
  };
447
472
  function Trans$1(_ref) {
@@ -463,7 +488,9 @@
463
488
  } = _ref;
464
489
  const i18n = i18nFromProps || getI18n();
465
490
  if (!i18n) {
466
- warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
491
+ warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
492
+ i18nKey
493
+ });
467
494
  return children;
468
495
  }
469
496
  const t = tFromProps || i18n.t.bind(i18n) || (k => k);
@@ -473,7 +500,7 @@
473
500
  };
474
501
  let namespaces = ns || t.ns || i18n.options?.defaultNS;
475
502
  namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
476
- const nodeAsString = nodesToString(children, reactI18nextOptions);
503
+ const nodeAsString = nodesToString(children, reactI18nextOptions, i18n, i18nKey);
477
504
  const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
478
505
  const {
479
506
  hashTransKey
@@ -504,7 +531,7 @@
504
531
  ns: namespaces
505
532
  };
506
533
  const translation = key ? t(key, combinedTOpts) : defaultValue;
507
- const generatedComponents = generateComponents(components, translation);
534
+ const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
508
535
  const content = renderNodes(generatedComponents || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
509
536
  const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
510
537
  return useAsParent ? react.createElement(useAsParent, additionalProps, content) : content;
@@ -618,7 +645,7 @@
618
645
  const i18n = i18nFromProps || i18nFromContext || getI18n();
619
646
  if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
620
647
  if (!i18n) {
621
- warnOnce('You will need to pass in an i18next instance by using initReactI18next');
648
+ warnOnce(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
622
649
  const notReadyT = (k, optsOrDefaultValue) => {
623
650
  if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
624
651
  if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
@@ -630,7 +657,7 @@
630
657
  retNotReady.ready = false;
631
658
  return retNotReady;
632
659
  }
633
- if (i18n.options.react?.wait) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
660
+ 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.');
634
661
  const i18nOptions = {
635
662
  ...getDefaults(),
636
663
  ...i18n.options.react,
@@ -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 s=t({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),a=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var r=new RegExp(a),o=null;null!==(o=r.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],r.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],a=[],c=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(r,(function(r,l){if(u){if(r!=="</"+t.name+">")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),m=l+r.length,h=e.charAt(m);if(f){var g=i(r);return c<0?(s.push(g),s):((p=a[c]).children.push(g),s)}if(d&&(c++,"tag"===(t=i(r)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!h||"<"===h||t.children.push({type:"text",content:e.slice(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===r.slice(2,-1))&&(c--,t=-1===c?s:a[c]),!u&&"<"!==h&&h)){p=-1===c?s:a[c].children;var y=e.indexOf("<",m),x=e.slice(m,-1===y?void 0:y);o.test(x)&&(x=" "),(y>-1&&c+p.length>=0||" "!==x)&&p.push({type:"text",content:x})}})),s};const u=function(){if(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)}},p={},d=function(){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))},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))},h=(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))},g=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,x=e=>"object"==typeof e&&null!==e,b=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,v={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},E=e=>v[e];let O={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(b,E)};const N=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O={...O,...e}},$=()=>O;let w;const k=e=>{w=e},I=()=>w,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)=>{if(!e)return"";let s="";const a=R(e),i=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach(((e,a)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:r}=e,o=Object.keys(n).length,l=i.indexOf(r)>-1,c=n.children;if(c||!l||o)if(!c&&(!l||o)||n.i18nIsDynamicList)s+=`<${a}></${a}>`;else if(l&&1===o&&y(c))s+=`<${r}>${c}</${r}>`;else{const e=T(c,t);s+=`<${a}>${e}</${a}>`}else s+=`<${r}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(x(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[0];s+=`{{${e}}}`}else u("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else u("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)})),s},C=(e,t,s,a,i,r)=>{if(""===t)return[];const o=a.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(S(e)?p(j(e)):x(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},m=(e,t,s)=>{const a=j(e),i=g(a,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(a)&&0===i.length||e.props?.i18nIsDynamicList?a:i},h=(e,t,s,a,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:a},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:a,ref:e.ref},i?null:t)})))},g=(t,i,c)=>{const u=R(t);return R(i).reduce(((t,i,p)=>{const d=i.children?.[0]?.content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let r=u[parseInt(i.name,10)];1!==c.length||r||(r=c[0][i.name]),r||(r={});const b=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},r):r,v=n.isValidElement(b),E=v&&S(i,!0)&&!i.voidElement,O=l&&x(b)&&b.dummy&&!v,N=x(e)&&Object.hasOwnProperty.call(e,i.name);if(y(b)){const e=s.services.interpolator.interpolate(b,f,s.language);t.push(e)}else if(S(b)||E){const e=m(b,i,c);h(b,e,t,p)}else if(O){const e=g(u,i.children,c);h(b,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(N){const e=m(b,i,c);h(b,e,t,p,i.voidElement)}else if(a.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=g(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=g(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(x(b)&&!v){const e=i.children[0]?d:null;e&&t.push(e)}else h(b,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=a.transWrapTextNodes,o=r?a.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},b=g([{dummy:!0,children:e||[]}],d,R(e||[]));return j(b[0])},A=(e,t,s)=>{const a=e.key||t,i=n.cloneElement(e,{key:a});if(!i.props||!i.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return i;return n.createElement((function(){return n.createElement(n.Fragment,null,i)}))},P=(e,n)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>A(e,t,n))))(e,n):x(e)?((e,n)=>{const t={};return Object.keys(e).forEach((s=>{Object.assign(t,{[s]:A(e[s],s,n)})})),t})(e,n):(d("<Trans /> component prop expects an object or an array"),null):null;function L(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:m,shouldUnescape:h,...g}=e;const x=f||I();if(!x)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const b=m||x.t.bind(x)||(e=>e),v={...$(),...x.options?.react};let E=p||b.ns||x.options?.defaultNS;E=y(E)?[E]:E||["translation"];const O=T(t,v),N=c||O||v.transEmptyNodeValue||i,{hashTransKey:w}=v,k=i||(w?w(O||N):O||N);x.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...x.options.interpolation.defaultVariables}:{...x.options.interpolation.defaultVariables});const S=l||void 0!==s&&!x.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},j={...o,context:r||o.context,count:s,...l,...S,defaultValue:N,ns:E},R=k?b(k,j):N,A=P(u,R),L=C(A||t,R,x,v,j,h),V=a??v.defaultTransParent;return V?n.createElement(V,g,L):L}const V={type:"3rdParty",init(e){N(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:i}=n.useContext(z)||{},r=s||a||I();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new F),!r){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:x(n)&&y(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}r.options.react?.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...$(),...r.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||r.options?.defaultNS;u=y(u)?[u]:u||["translation"],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?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("i18n.languages were undefined or empty",n.languages),!0)}(e,r,o))),f=((e,t,s,a)=>n.useCallback(D(e,t,s,a),[e,t,s,a]))(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),g=()=>f,b=()=>D(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[v,E]=n.useState(g);let O=u.join();t.lng&&(O=`${t.lng}${O}`);const N=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(O),w=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;w.current=!0,p||l||(t.lng?h(r,t.lng,u,(()=>{w.current&&E(b)})):m(r,u,(()=>{w.current&&E(b)}))),p&&N&&N!==O&&w.current&&E(b);const s=()=>{w.current&&E(b)};return e&&r?.on(e,s),n&&r?.store.on(n,s),()=>{w.current=!1,r&&e?.split(" ").forEach((e=>r.off(e,s))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,s)))}}),[r,O]),n.useEffect((()=>{w.current&&p&&E(g)}),[r,c,p]);const k=[v,r,p];if(k.t=v,k.i18n=r,k.ready=p,p)return k;if(!p&&!l)return k;throw new Promise((e=>{t.lng?h(r,t.lng,u,(()=>e())):m(r,u,(()=>e()))}))};const W=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:a}=s,{i18n:i}=n.useContext(z)||{},r=a||i||I();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=z,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:a}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(z.Provider,{value:i},a)},e.Trans=function(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:m,...h}=e;const{i18n:g,defaultNS:y}=n.useContext(z)||{},x=d||g||I(),b=f||x?.t.bind(x);return L({children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o,values:l,defaults:c,components:u,ns:p||b?.ns||y||x?.options?.defaultNS,i18n:x,t:f,shouldUnescape:m,...h})},e.TransWithoutContext=L,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[a,i,r]=K(n,s);return t(a,{i18n:i,lng:i.language},r)},e.composeInitialProps=U,e.date=()=>"",e.getDefaults=$,e.getI18n=I,e.getInitialProps=B,e.initReactI18next=V,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=N,e.setI18n=k,e.time=()=>"",e.useSSR=W,e.useTranslation=K,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:a,...i}=t;return W(s,a),n.createElement(e,{...i})}return t.getInitialProps=U(e),t.displayName=`withI18nextSSR(${g(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function a(a){let{forwardedRef:i,...r}=a;const[o,l,c]=K(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),n.createElement(s,u)}a.displayName=`withI18nextTranslation(${g(s)})`,a.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(a,Object.assign({},e,{forwardedRef:t})))):a}}}));
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}),r=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var a=new RegExp(r),o=null;null!==(o=a.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],a.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var a=/<[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(a,(function(a,l){if(u){if(a!=="</"+t.name+">")return;u=!1}var p,d="/"!==a.charAt(1),f=a.startsWith("\x3c!--"),g=l+a.length,m=e.charAt(g);if(f){var h=i(a);return c<0?(s.push(h),s):((p=r[c]).children.push(h),s)}if(d&&(c++,"tag"===(t=i(a)).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===a.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),x=e.slice(g,-1===y?void 0:y);o.test(x)&&(x=" "),(y>-1&&c+p.length>=0||" "!==x)&&p.push({type:"text",content:x})}})),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,x=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,N={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},b=e=>N[e];let E={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(v,b)};const O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E={...E,...e}},I=()=>E;let S;const w=e=>{S=e},$=()=>S,T=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},k=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],A=(e,t,s,r)=>{if(!e)return"";let i="";const a=R(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach(((e,a)=>{if(y(e))i+=`${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(i+=`<${l}/>`);if(!p&&(!u||c)||n.i18nIsDynamicList)return void(i+=`<${a}></${a}>`);if(u&&1===c&&y(p))return void(i+=`<${l}>${p}</${l}>`);const d=A(p,t,s,r);i+=`<${a}>${d}</${a}>`}else if(null!==e)if(x(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[0];return void(i+=`{{${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})})),i},j=(e,t,s,r,i,a)=>{if(""===t)return[];const o=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!a)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(T(e)?p(k(e)):x(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},g=(e,t,s)=>{const r=k(e),i=h(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===i.length||e.props?.i18nIsDynamicList?r:i},m=(e,t,s,r,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:r},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:r,ref:e.ref},i?null:t)})))},h=(t,i,c)=>{const u=R(t);return R(i).reduce(((t,i,p)=>{const d=i.children?.[0]?.content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let a=u[parseInt(i.name,10)];1!==c.length||a||(a=c[0][i.name]),a||(a={});const v=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},a):a,N=n.isValidElement(v),b=N&&T(i,!0)&&!i.voidElement,E=l&&x(v)&&v.dummy&&!N,O=x(e)&&Object.hasOwnProperty.call(e,i.name);if(y(v)){const e=s.services.interpolator.interpolate(v,f,s.language);t.push(e)}else if(T(v)||b){const e=g(v,i,c);m(v,e,t,p)}else if(E){const e=h(u,i.children,c);m(v,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(O){const e=g(v,i,c);m(v,e,t,p,i.voidElement)}else if(r.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=h(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=h(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(x(v)&&!N){const e=i.children[0]?d:null;e&&t.push(e)}else m(v,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=r.transWrapTextNodes,o=a?r.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},v=h([{dummy:!0,children:e||[]}],d,R(e||[]));return k(v[0])},C=(e,t,s)=>{const r=e.key||t,i=n.cloneElement(e,{key:r});if(!i.props||!i.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return i;return n.createElement((function(){return n.createElement(n.Fragment,null,i)}))},L=(e,n,t,s)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>C(e,t,n))))(e,n):x(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:i,context:a,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:m,...h}=e;const x=f||$();if(!x)return d(x,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:i}),t;const v=g||x.t.bind(x)||(e=>e),N={...I(),...x.options?.react};let b=p||v.ns||x.options?.defaultNS;b=y(b)?[b]:b||["translation"];const E=A(t,N,x,i),O=c||E||N.transEmptyNodeValue||i,{hashTransKey:S}=N,w=i||(S?S(E||O):E||O);x.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...x.options.interpolation.defaultVariables}:{...x.options.interpolation.defaultVariables});const T=l||void 0!==s&&!x.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},k={...o,context:a||o.context,count:s,...l,...T,defaultValue:O,ns:b},R=w?v(w,k):O,C=L(u,R,x,i),P=j(C||t,R,x,N,k,m),V=r??N.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:i}=n.useContext(_)||{},a=s||r||$();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new D),!a){d(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:x(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}a.options.react?.wait&&d(a,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...I(),...a.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||a.options?.defaultNS;u=y(u)?[u]:u||["translation"],a.reportNamespaces.addUsedNamespaces?.(u);const p=(a.isInitialized||a.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,a,o))),f=((e,t,s,r)=>n.useCallback(U(e,t,s,r),[e,t,s,r]))(a,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,v=()=>U(a,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[N,b]=n.useState(h);let E=u.join();t.lng&&(E=`${t.lng}${E}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(E),S=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;S.current=!0,p||l||(t.lng?m(a,t.lng,u,(()=>{S.current&&b(v)})):g(a,u,(()=>{S.current&&b(v)}))),p&&O&&O!==E&&S.current&&b(v);const s=()=>{S.current&&b(v)};return e&&a?.on(e,s),n&&a?.store.on(n,s),()=>{S.current=!1,a&&e?.split(" ").forEach((e=>a.off(e,s))),n&&a&&n.split(" ").forEach((e=>a.store.off(e,s)))}}),[a,E]),n.useEffect((()=>{S.current&&p&&b(h)}),[a,c,p]);const w=[N,a,p];if(w.t=N,w.i18n=a,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?m(a,t.lng,u,(()=>e())):g(a,u,(()=>e()))}))};const B=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:r}=s,{i18n:i}=n.useContext(_)||{},a=r||i||$();a.options?.isClone||(e&&!a.initializedStoreOnce&&(a.services.resourceStore.data=e,a.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),a.options.ns),a.initializedStoreOnce=!0,a.isInitialized=!0),t&&!a.initializedLanguageOnce&&(a.changeLanguage(t),a.initializedLanguageOnce=!0))};e.I18nContext=_,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:r}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(_.Provider,{value:i},r)},e.Trans=function(e){let{children:t,count:s,parent:r,i18nKey:i,context:a,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(_)||{},x=d||h||$(),v=f||x?.t.bind(x);return P({children:t,count:s,parent:r,i18nKey:i,context:a,tOptions:o,values:l,defaults:c,components:u,ns:p||v?.ns||y||x?.options?.defaultNS,i18n:x,t:f,shouldUnescape:g,...m})},e.TransWithoutContext=P,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[r,i,a]=F(n,s);return t(r,{i18n:i,lng:i.language},a)},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,...i}=t;return B(s,r),n.createElement(e,{...i})}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:i,...a}=r;const[o,l,c]=F(e,{...a,keyPrefix:t.keyPrefix}),u={...a,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),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}}}));
package/index.d.ts CHANGED
@@ -10,11 +10,11 @@ import type {
10
10
  KeyPrefix,
11
11
  } from 'i18next';
12
12
  import * as React from 'react';
13
- import { Trans, TransProps } from './TransWithoutContext.js';
13
+ import { Trans, TransProps, ErrorCode, ErrorArgs } from './TransWithoutContext.js';
14
14
  export { initReactI18next } from './initReactI18next.js';
15
15
 
16
16
  export const TransWithoutContext: typeof Trans;
17
- export { Trans, TransProps };
17
+ export { Trans, TransProps, ErrorArgs, ErrorCode };
18
18
 
19
19
  export function setDefaults(options: ReactOptions): void;
20
20
  export function getDefaults(): ReactOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-i18next",
3
- "version": "15.2.0",
3
+ "version": "15.4.0",
4
4
  "description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "types": "./index.d.mts",
package/react-i18next.js CHANGED
@@ -118,23 +118,26 @@
118
118
  }
119
119
  };
120
120
 
121
- const warn = function () {
122
- if (console?.warn) {
123
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
124
- args[_key] = arguments[_key];
125
- }
126
- if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
121
+ const warn = (i18n, code, msg, rest) => {
122
+ const args = [msg, {
123
+ code,
124
+ ...(rest || {})
125
+ }];
126
+ if (i18n?.services?.logger?.forward) {
127
+ return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
128
+ }
129
+ if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
130
+ if (i18n?.services?.logger?.warn) {
131
+ i18n.services.logger.warn(...args);
132
+ } else if (console?.warn) {
127
133
  console.warn(...args);
128
134
  }
129
135
  };
130
136
  const alreadyWarned = {};
131
- const warnOnce = function () {
132
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
133
- args[_key2] = arguments[_key2];
134
- }
135
- if (isString(args[0]) && alreadyWarned[args[0]]) return;
136
- if (isString(args[0])) alreadyWarned[args[0]] = new Date();
137
- warn(...args);
137
+ const warnOnce = (i18n, code, msg, rest) => {
138
+ if (isString(msg) && alreadyWarned[msg]) return;
139
+ if (isString(msg)) alreadyWarned[msg] = new Date();
140
+ warn(i18n, code, msg, rest);
138
141
  };
139
142
  const loadedClb = (i18n, cb) => () => {
140
143
  if (i18n.isInitialized) {
@@ -163,7 +166,9 @@
163
166
  const hasLoadedNamespace = function (ns, i18n) {
164
167
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
165
168
  if (!i18n.languages || !i18n.languages.length) {
166
- warnOnce('i18n.languages were undefined or empty', i18n.languages);
169
+ warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
170
+ languages: i18n.languages
171
+ });
167
172
  return true;
168
173
  }
169
174
  return i18n.hasLoadedNamespace(ns, {
@@ -248,7 +253,7 @@
248
253
  newTarget.props = Object.assign(source.props, target.props);
249
254
  return newTarget;
250
255
  };
251
- const nodesToString = (children, i18nOptions) => {
256
+ const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
252
257
  if (!children) return '';
253
258
  let stringNode = '';
254
259
  const childrenArray = getAsArray(children);
@@ -256,7 +261,9 @@
256
261
  childrenArray.forEach((child, childIndex) => {
257
262
  if (isString(child)) {
258
263
  stringNode += `${child}`;
259
- } else if (react.isValidElement(child)) {
264
+ return;
265
+ }
266
+ if (react.isValidElement(child)) {
260
267
  const {
261
268
  props,
262
269
  type
@@ -266,17 +273,27 @@
266
273
  const childChildren = props.children;
267
274
  if (!childChildren && shouldKeepChild && !childPropsCount) {
268
275
  stringNode += `<${type}/>`;
269
- } else if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
276
+ return;
277
+ }
278
+ if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
270
279
  stringNode += `<${childIndex}></${childIndex}>`;
271
- } else if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
280
+ return;
281
+ }
282
+ if (shouldKeepChild && childPropsCount === 1 && isString(childChildren)) {
272
283
  stringNode += `<${type}>${childChildren}</${type}>`;
273
- } else {
274
- const content = nodesToString(childChildren, i18nOptions);
275
- stringNode += `<${childIndex}>${content}</${childIndex}>`;
284
+ return;
276
285
  }
277
- } else if (child === null) {
278
- warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
279
- } else if (isObject(child)) {
286
+ const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
287
+ stringNode += `<${childIndex}>${content}</${childIndex}>`;
288
+ return;
289
+ }
290
+ if (child === null) {
291
+ warn(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
292
+ i18nKey
293
+ });
294
+ return;
295
+ }
296
+ if (isObject(child)) {
280
297
  const {
281
298
  format,
282
299
  ...clone
@@ -285,12 +302,18 @@
285
302
  if (keys.length === 1) {
286
303
  const value = format ? `${keys[0]}, ${format}` : keys[0];
287
304
  stringNode += `{{${value}}}`;
288
- } else {
289
- warn(`react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child);
305
+ return;
290
306
  }
291
- } else {
292
- warn(`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}}.`, child);
307
+ warn(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
308
+ i18nKey,
309
+ child
310
+ });
311
+ return;
293
312
  }
313
+ warn(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
314
+ i18nKey,
315
+ child
316
+ });
294
317
  });
295
318
  return stringNode;
296
319
  };
@@ -433,7 +456,7 @@
433
456
  });
434
457
  return componentMap;
435
458
  };
436
- const generateComponents = (components, translation) => {
459
+ const generateComponents = (components, translation, i18n, i18nKey) => {
437
460
  if (!components) return null;
438
461
  if (Array.isArray(components)) {
439
462
  return generateArrayComponents(components, translation);
@@ -441,7 +464,9 @@
441
464
  if (isObject(components)) {
442
465
  return generateObjectComponents(components, translation);
443
466
  }
444
- warnOnce('<Trans /> component prop expects an object or an array');
467
+ warnOnce(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
468
+ i18nKey
469
+ });
445
470
  return null;
446
471
  };
447
472
  function Trans$1(_ref) {
@@ -463,7 +488,9 @@
463
488
  } = _ref;
464
489
  const i18n = i18nFromProps || getI18n();
465
490
  if (!i18n) {
466
- warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
491
+ warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
492
+ i18nKey
493
+ });
467
494
  return children;
468
495
  }
469
496
  const t = tFromProps || i18n.t.bind(i18n) || (k => k);
@@ -473,7 +500,7 @@
473
500
  };
474
501
  let namespaces = ns || t.ns || i18n.options?.defaultNS;
475
502
  namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
476
- const nodeAsString = nodesToString(children, reactI18nextOptions);
503
+ const nodeAsString = nodesToString(children, reactI18nextOptions, i18n, i18nKey);
477
504
  const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
478
505
  const {
479
506
  hashTransKey
@@ -504,7 +531,7 @@
504
531
  ns: namespaces
505
532
  };
506
533
  const translation = key ? t(key, combinedTOpts) : defaultValue;
507
- const generatedComponents = generateComponents(components, translation);
534
+ const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
508
535
  const content = renderNodes(generatedComponents || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
509
536
  const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
510
537
  return useAsParent ? react.createElement(useAsParent, additionalProps, content) : content;
@@ -618,7 +645,7 @@
618
645
  const i18n = i18nFromProps || i18nFromContext || getI18n();
619
646
  if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
620
647
  if (!i18n) {
621
- warnOnce('You will need to pass in an i18next instance by using initReactI18next');
648
+ warnOnce(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
622
649
  const notReadyT = (k, optsOrDefaultValue) => {
623
650
  if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
624
651
  if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
@@ -630,7 +657,7 @@
630
657
  retNotReady.ready = false;
631
658
  return retNotReady;
632
659
  }
633
- if (i18n.options.react?.wait) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
660
+ 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.');
634
661
  const i18nOptions = {
635
662
  ...getDefaults(),
636
663
  ...i18n.options.react,
@@ -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 s=t({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),a=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var r=new RegExp(a),o=null;null!==(o=r.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],r.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],a=[],c=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(r,(function(r,l){if(u){if(r!=="</"+t.name+">")return;u=!1}var p,d="/"!==r.charAt(1),f=r.startsWith("\x3c!--"),m=l+r.length,h=e.charAt(m);if(f){var g=i(r);return c<0?(s.push(g),s):((p=a[c]).children.push(g),s)}if(d&&(c++,"tag"===(t=i(r)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!h||"<"===h||t.children.push({type:"text",content:e.slice(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===r.slice(2,-1))&&(c--,t=-1===c?s:a[c]),!u&&"<"!==h&&h)){p=-1===c?s:a[c].children;var y=e.indexOf("<",m),x=e.slice(m,-1===y?void 0:y);o.test(x)&&(x=" "),(y>-1&&c+p.length>=0||" "!==x)&&p.push({type:"text",content:x})}})),s};const u=function(){if(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)}},p={},d=function(){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))},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))},h=(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))},g=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,x=e=>"object"==typeof e&&null!==e,b=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,v={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},E=e=>v[e];let O={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(b,E)};const N=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O={...O,...e}},$=()=>O;let w;const k=e=>{w=e},I=()=>w,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)=>{if(!e)return"";let s="";const a=R(e),i=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach(((e,a)=>{if(y(e))s+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:r}=e,o=Object.keys(n).length,l=i.indexOf(r)>-1,c=n.children;if(c||!l||o)if(!c&&(!l||o)||n.i18nIsDynamicList)s+=`<${a}></${a}>`;else if(l&&1===o&&y(c))s+=`<${r}>${c}</${r}>`;else{const e=T(c,t);s+=`<${a}>${e}</${a}>`}else s+=`<${r}/>`}else if(null===e)u("Trans: the passed in value is invalid - seems you passed in a null child.");else if(x(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[0];s+=`{{${e}}}`}else u("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else u("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)})),s},C=(e,t,s,a,i,r)=>{if(""===t)return[];const o=a.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!r)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(S(e)?p(j(e)):x(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},m=(e,t,s)=>{const a=j(e),i=g(a,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(a)&&0===i.length||e.props?.i18nIsDynamicList?a:i},h=(e,t,s,a,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:a},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:a,ref:e.ref},i?null:t)})))},g=(t,i,c)=>{const u=R(t);return R(i).reduce(((t,i,p)=>{const d=i.children?.[0]?.content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let r=u[parseInt(i.name,10)];1!==c.length||r||(r=c[0][i.name]),r||(r={});const b=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},r):r,v=n.isValidElement(b),E=v&&S(i,!0)&&!i.voidElement,O=l&&x(b)&&b.dummy&&!v,N=x(e)&&Object.hasOwnProperty.call(e,i.name);if(y(b)){const e=s.services.interpolator.interpolate(b,f,s.language);t.push(e)}else if(S(b)||E){const e=m(b,i,c);h(b,e,t,p)}else if(O){const e=g(u,i.children,c);h(b,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(N){const e=m(b,i,c);h(b,e,t,p,i.voidElement)}else if(a.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=g(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=g(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(x(b)&&!v){const e=i.children[0]?d:null;e&&t.push(e)}else h(b,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=a.transWrapTextNodes,o=r?a.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},b=g([{dummy:!0,children:e||[]}],d,R(e||[]));return j(b[0])},A=(e,t,s)=>{const a=e.key||t,i=n.cloneElement(e,{key:a});if(!i.props||!i.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return i;return n.createElement((function(){return n.createElement(n.Fragment,null,i)}))},P=(e,n)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>A(e,t,n))))(e,n):x(e)?((e,n)=>{const t={};return Object.keys(e).forEach((s=>{Object.assign(t,{[s]:A(e[s],s,n)})})),t})(e,n):(d("<Trans /> component prop expects an object or an array"),null):null;function L(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:m,shouldUnescape:h,...g}=e;const x=f||I();if(!x)return d("You will need to pass in an i18next instance by using i18nextReactModule"),t;const b=m||x.t.bind(x)||(e=>e),v={...$(),...x.options?.react};let E=p||b.ns||x.options?.defaultNS;E=y(E)?[E]:E||["translation"];const O=T(t,v),N=c||O||v.transEmptyNodeValue||i,{hashTransKey:w}=v,k=i||(w?w(O||N):O||N);x.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...x.options.interpolation.defaultVariables}:{...x.options.interpolation.defaultVariables});const S=l||void 0!==s&&!x.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},j={...o,context:r||o.context,count:s,...l,...S,defaultValue:N,ns:E},R=k?b(k,j):N,A=P(u,R),L=C(A||t,R,x,v,j,h),V=a??v.defaultTransParent;return V?n.createElement(V,g,L):L}const V={type:"3rdParty",init(e){N(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:i}=n.useContext(z)||{},r=s||a||I();if(r&&!r.reportNamespaces&&(r.reportNamespaces=new F),!r){d("You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:x(n)&&y(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}r.options.react?.wait&&d("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...$(),...r.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||r.options?.defaultNS;u=y(u)?[u]:u||["translation"],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?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("i18n.languages were undefined or empty",n.languages),!0)}(e,r,o))),f=((e,t,s,a)=>n.useCallback(D(e,t,s,a),[e,t,s,a]))(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),g=()=>f,b=()=>D(r,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[v,E]=n.useState(g);let O=u.join();t.lng&&(O=`${t.lng}${O}`);const N=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(O),w=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;w.current=!0,p||l||(t.lng?h(r,t.lng,u,(()=>{w.current&&E(b)})):m(r,u,(()=>{w.current&&E(b)}))),p&&N&&N!==O&&w.current&&E(b);const s=()=>{w.current&&E(b)};return e&&r?.on(e,s),n&&r?.store.on(n,s),()=>{w.current=!1,r&&e?.split(" ").forEach((e=>r.off(e,s))),n&&r&&n.split(" ").forEach((e=>r.store.off(e,s)))}}),[r,O]),n.useEffect((()=>{w.current&&p&&E(g)}),[r,c,p]);const k=[v,r,p];if(k.t=v,k.i18n=r,k.ready=p,p)return k;if(!p&&!l)return k;throw new Promise((e=>{t.lng?h(r,t.lng,u,(()=>e())):m(r,u,(()=>e()))}))};const W=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:a}=s,{i18n:i}=n.useContext(z)||{},r=a||i||I();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=z,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:a}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(z.Provider,{value:i},a)},e.Trans=function(e){let{children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:m,...h}=e;const{i18n:g,defaultNS:y}=n.useContext(z)||{},x=d||g||I(),b=f||x?.t.bind(x);return L({children:t,count:s,parent:a,i18nKey:i,context:r,tOptions:o,values:l,defaults:c,components:u,ns:p||b?.ns||y||x?.options?.defaultNS,i18n:x,t:f,shouldUnescape:m,...h})},e.TransWithoutContext=L,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[a,i,r]=K(n,s);return t(a,{i18n:i,lng:i.language},r)},e.composeInitialProps=U,e.date=()=>"",e.getDefaults=$,e.getI18n=I,e.getInitialProps=B,e.initReactI18next=V,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=N,e.setI18n=k,e.time=()=>"",e.useSSR=W,e.useTranslation=K,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:a,...i}=t;return W(s,a),n.createElement(e,{...i})}return t.getInitialProps=U(e),t.displayName=`withI18nextSSR(${g(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function a(a){let{forwardedRef:i,...r}=a;const[o,l,c]=K(e,{...r,keyPrefix:t.keyPrefix}),u={...r,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),n.createElement(s,u)}a.displayName=`withI18nextTranslation(${g(s)})`,a.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(a,Object.assign({},e,{forwardedRef:t})))):a}}}));
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}),r=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function i(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var a=new RegExp(r),o=null;null!==(o=a.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],a.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var a=/<[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(a,(function(a,l){if(u){if(a!=="</"+t.name+">")return;u=!1}var p,d="/"!==a.charAt(1),f=a.startsWith("\x3c!--"),g=l+a.length,m=e.charAt(g);if(f){var h=i(a);return c<0?(s.push(h),s):((p=r[c]).children.push(h),s)}if(d&&(c++,"tag"===(t=i(a)).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===a.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),x=e.slice(g,-1===y?void 0:y);o.test(x)&&(x=" "),(y>-1&&c+p.length>=0||" "!==x)&&p.push({type:"text",content:x})}})),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,x=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,N={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},b=e=>N[e];let E={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(v,b)};const O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E={...E,...e}},I=()=>E;let S;const w=e=>{S=e},$=()=>S,T=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},k=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],A=(e,t,s,r)=>{if(!e)return"";let i="";const a=R(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach(((e,a)=>{if(y(e))i+=`${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(i+=`<${l}/>`);if(!p&&(!u||c)||n.i18nIsDynamicList)return void(i+=`<${a}></${a}>`);if(u&&1===c&&y(p))return void(i+=`<${l}>${p}</${l}>`);const d=A(p,t,s,r);i+=`<${a}>${d}</${a}>`}else if(null!==e)if(x(e)){const{format:n,...t}=e,a=Object.keys(t);if(1===a.length){const e=n?`${a[0]}, ${n}`:a[0];return void(i+=`{{${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})})),i},j=(e,t,s,r,i,a)=>{if(""===t)return[];const o=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!a)return[t];const u={},p=e=>{R(e).forEach((e=>{y(e)||(T(e)?p(k(e)):x(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...i},g=(e,t,s)=>{const r=k(e),i=h(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===i.length||e.props?.i18nIsDynamicList?r:i},m=(e,t,s,r,i)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:r},i?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:r,ref:e.ref},i?null:t)})))},h=(t,i,c)=>{const u=R(t);return R(i).reduce(((t,i,p)=>{const d=i.children?.[0]?.content&&s.services.interpolator.interpolate(i.children[0].content,f,s.language);if("tag"===i.type){let a=u[parseInt(i.name,10)];1!==c.length||a||(a=c[0][i.name]),a||(a={});const v=0!==Object.keys(i.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:i.attrs},a):a,N=n.isValidElement(v),b=N&&T(i,!0)&&!i.voidElement,E=l&&x(v)&&v.dummy&&!N,O=x(e)&&Object.hasOwnProperty.call(e,i.name);if(y(v)){const e=s.services.interpolator.interpolate(v,f,s.language);t.push(e)}else if(T(v)||b){const e=g(v,i,c);m(v,e,t,p)}else if(E){const e=h(u,i.children,c);m(v,e,t,p)}else if(Number.isNaN(parseFloat(i.name)))if(O){const e=g(v,i,c);m(v,e,t,p,i.voidElement)}else if(r.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)t.push(n.createElement(i.name,{key:`${i.name}-${p}`}));else{const e=h(u,i.children,c);t.push(n.createElement(i.name,{key:`${i.name}-${p}`},e))}else if(i.voidElement)t.push(`<${i.name} />`);else{const e=h(u,i.children,c);t.push(`<${i.name}>${e}</${i.name}>`)}else if(x(v)&&!N){const e=i.children[0]?d:null;e&&t.push(e)}else m(v,d,t,p,1!==i.children.length||!d)}else if("text"===i.type){const e=r.transWrapTextNodes,o=a?r.unescape(s.services.interpolator.interpolate(i.content,f,s.language)):s.services.interpolator.interpolate(i.content,f,s.language);e?t.push(n.createElement(e,{key:`${i.name}-${p}`},o)):t.push(o)}return t}),[])},v=h([{dummy:!0,children:e||[]}],d,R(e||[]));return k(v[0])},C=(e,t,s)=>{const r=e.key||t,i=n.cloneElement(e,{key:r});if(!i.props||!i.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return i;return n.createElement((function(){return n.createElement(n.Fragment,null,i)}))},L=(e,n,t,s)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>C(e,t,n))))(e,n):x(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:i,context:a,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:m,...h}=e;const x=f||$();if(!x)return d(x,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:i}),t;const v=g||x.t.bind(x)||(e=>e),N={...I(),...x.options?.react};let b=p||v.ns||x.options?.defaultNS;b=y(b)?[b]:b||["translation"];const E=A(t,N,x,i),O=c||E||N.transEmptyNodeValue||i,{hashTransKey:S}=N,w=i||(S?S(E||O):E||O);x.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...x.options.interpolation.defaultVariables}:{...x.options.interpolation.defaultVariables});const T=l||void 0!==s&&!x.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},k={...o,context:a||o.context,count:s,...l,...T,defaultValue:O,ns:b},R=w?v(w,k):O,C=L(u,R,x,i),P=j(C||t,R,x,N,k,m),V=r??N.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:i}=n.useContext(_)||{},a=s||r||$();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new D),!a){d(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:x(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}a.options.react?.wait&&d(a,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...I(),...a.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||i||a.options?.defaultNS;u=y(u)?[u]:u||["translation"],a.reportNamespaces.addUsedNamespaces?.(u);const p=(a.isInitialized||a.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,a,o))),f=((e,t,s,r)=>n.useCallback(U(e,t,s,r),[e,t,s,r]))(a,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,v=()=>U(a,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[N,b]=n.useState(h);let E=u.join();t.lng&&(E=`${t.lng}${E}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(E),S=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;S.current=!0,p||l||(t.lng?m(a,t.lng,u,(()=>{S.current&&b(v)})):g(a,u,(()=>{S.current&&b(v)}))),p&&O&&O!==E&&S.current&&b(v);const s=()=>{S.current&&b(v)};return e&&a?.on(e,s),n&&a?.store.on(n,s),()=>{S.current=!1,a&&e?.split(" ").forEach((e=>a.off(e,s))),n&&a&&n.split(" ").forEach((e=>a.store.off(e,s)))}}),[a,E]),n.useEffect((()=>{S.current&&p&&b(h)}),[a,c,p]);const w=[N,a,p];if(w.t=N,w.i18n=a,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?m(a,t.lng,u,(()=>e())):g(a,u,(()=>e()))}))};const B=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:r}=s,{i18n:i}=n.useContext(_)||{},a=r||i||$();a.options?.isClone||(e&&!a.initializedStoreOnce&&(a.services.resourceStore.data=e,a.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),a.options.ns),a.initializedStoreOnce=!0,a.isInitialized=!0),t&&!a.initializedLanguageOnce&&(a.changeLanguage(t),a.initializedLanguageOnce=!0))};e.I18nContext=_,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:r}=e;const i=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(_.Provider,{value:i},r)},e.Trans=function(e){let{children:t,count:s,parent:r,i18nKey:i,context:a,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(_)||{},x=d||h||$(),v=f||x?.t.bind(x);return P({children:t,count:s,parent:r,i18nKey:i,context:a,tOptions:o,values:l,defaults:c,components:u,ns:p||v?.ns||y||x?.options?.defaultNS,i18n:x,t:f,shouldUnescape:g,...m})},e.TransWithoutContext=P,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[r,i,a]=F(n,s);return t(r,{i18n:i,lng:i.language},a)},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,...i}=t;return B(s,r),n.createElement(e,{...i})}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:i,...a}=r;const[o,l,c]=F(e,{...a,keyPrefix:t.keyPrefix}),u={...a,t:o,i18n:l,tReady:c};return t.withRef&&i?u.ref=i:!t.withRef&&i&&(u.forwardedRef=i),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}}}));