react-i18next 15.5.2 → 15.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 15.5.3
2
+
3
+ chore: update `@babel/runtime` [1851](https://github.com/i18next/react-i18next/pull/1851)
4
+
1
5
  ### 15.5.2
2
6
 
3
7
  fix element.ref access issue with react 19 [1846](https://github.com/i18next/react-i18next/pull/1846)
@@ -159,8 +159,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
159
159
  });
160
160
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
161
161
  };
162
- const hasLoadedNamespace = function (ns, i18n) {
163
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
162
+ const hasLoadedNamespace = (ns, i18n, options = {}) => {
164
163
  if (!i18n.languages || !i18n.languages.length) {
165
164
  warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
166
165
  languages: i18n.languages
@@ -214,8 +213,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
214
213
  useSuspense: true,
215
214
  unescape
216
215
  };
217
- const setDefaults = function () {
218
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
216
+ const setDefaults = (options = {}) => {
219
217
  defaultOptions = {
220
218
  ...defaultOptions,
221
219
  ...options
@@ -467,23 +465,22 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
467
465
  });
468
466
  return null;
469
467
  };
470
- function Trans$1(_ref) {
471
- let {
472
- children,
473
- count,
474
- parent,
475
- i18nKey,
476
- context,
477
- tOptions = {},
478
- values,
479
- defaults,
480
- components,
481
- ns,
482
- i18n: i18nFromProps,
483
- t: tFromProps,
484
- shouldUnescape,
485
- ...additionalProps
486
- } = _ref;
468
+ function Trans$1({
469
+ children,
470
+ count,
471
+ parent,
472
+ i18nKey,
473
+ context,
474
+ tOptions = {},
475
+ values,
476
+ defaults,
477
+ components,
478
+ ns,
479
+ i18n: i18nFromProps,
480
+ t: tFromProps,
481
+ shouldUnescape,
482
+ ...additionalProps
483
+ }) {
487
484
  const i18n = i18nFromProps || getI18n();
488
485
  if (!i18n) {
489
486
  warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -581,23 +578,22 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
581
578
  return ret;
582
579
  };
583
580
 
584
- function Trans(_ref) {
585
- let {
586
- children,
587
- count,
588
- parent,
589
- i18nKey,
590
- context,
591
- tOptions = {},
592
- values,
593
- defaults,
594
- components,
595
- ns,
596
- i18n: i18nFromProps,
597
- t: tFromProps,
598
- shouldUnescape,
599
- ...additionalProps
600
- } = _ref;
581
+ function Trans({
582
+ children,
583
+ count,
584
+ parent,
585
+ i18nKey,
586
+ context,
587
+ tOptions = {},
588
+ values,
589
+ defaults,
590
+ components,
591
+ ns,
592
+ i18n: i18nFromProps,
593
+ t: tFromProps,
594
+ shouldUnescape,
595
+ ...additionalProps
596
+ }) {
601
597
  const {
602
598
  i18n: i18nFromContext,
603
599
  defaultNS: defaultNSFromContext
@@ -631,8 +627,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
631
627
  };
632
628
  const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
633
629
  const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
634
- const useTranslation = function (ns) {
635
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
630
+ const useTranslation = (ns, props = {}) => {
636
631
  const {
637
632
  i18n: i18nFromProps
638
633
  } = props;
@@ -728,46 +723,41 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
728
723
  });
729
724
  };
730
725
 
731
- const withTranslation = function (ns) {
732
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
733
- return function Extend(WrappedComponent) {
734
- function I18nextWithTranslation(_ref) {
735
- let {
736
- forwardedRef,
737
- ...rest
738
- } = _ref;
739
- const [t, i18n, ready] = useTranslation(ns, {
740
- ...rest,
741
- keyPrefix: options.keyPrefix
742
- });
743
- const passDownProps = {
744
- ...rest,
745
- t,
746
- i18n,
747
- tReady: ready
748
- };
749
- if (options.withRef && forwardedRef) {
750
- passDownProps.ref = forwardedRef;
751
- } else if (!options.withRef && forwardedRef) {
752
- passDownProps.forwardedRef = forwardedRef;
753
- }
754
- return react.createElement(WrappedComponent, passDownProps);
726
+ const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
727
+ function I18nextWithTranslation({
728
+ forwardedRef,
729
+ ...rest
730
+ }) {
731
+ const [t, i18n, ready] = useTranslation(ns, {
732
+ ...rest,
733
+ keyPrefix: options.keyPrefix
734
+ });
735
+ const passDownProps = {
736
+ ...rest,
737
+ t,
738
+ i18n,
739
+ tReady: ready
740
+ };
741
+ if (options.withRef && forwardedRef) {
742
+ passDownProps.ref = forwardedRef;
743
+ } else if (!options.withRef && forwardedRef) {
744
+ passDownProps.forwardedRef = forwardedRef;
755
745
  }
756
- I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
757
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
758
- const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
759
- forwardedRef: ref
760
- }));
761
- return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
762
- };
746
+ return react.createElement(WrappedComponent, passDownProps);
747
+ }
748
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
749
+ I18nextWithTranslation.WrappedComponent = WrappedComponent;
750
+ const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
751
+ forwardedRef: ref
752
+ }));
753
+ return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
763
754
  };
764
755
 
765
- const Translation = _ref => {
766
- let {
767
- ns,
768
- children,
769
- ...options
770
- } = _ref;
756
+ const Translation = ({
757
+ ns,
758
+ children,
759
+ ...options
760
+ }) => {
771
761
  const [t, i18n, ready] = useTranslation(ns, options);
772
762
  return children(t, {
773
763
  i18n,
@@ -775,12 +765,11 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
775
765
  }, ready);
776
766
  };
777
767
 
778
- function I18nextProvider(_ref) {
779
- let {
780
- i18n,
781
- defaultNS,
782
- children
783
- } = _ref;
768
+ function I18nextProvider({
769
+ i18n,
770
+ defaultNS,
771
+ children
772
+ }) {
784
773
  const value = react.useMemo(() => ({
785
774
  i18n,
786
775
  defaultNS
@@ -790,8 +779,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
790
779
  }, children);
791
780
  }
792
781
 
793
- const useSSR = function (initialI18nStore, initialLanguage) {
794
- let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
782
+ const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
795
783
  const {
796
784
  i18n: i18nFromProps
797
785
  } = props;
@@ -818,12 +806,11 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
818
806
  };
819
807
 
820
808
  const withSSR = () => function Extend(WrappedComponent) {
821
- function I18nextWithSSR(_ref) {
822
- let {
823
- initialI18nStore,
824
- initialLanguage,
825
- ...rest
826
- } = _ref;
809
+ function I18nextWithSSR({
810
+ initialI18nStore,
811
+ initialLanguage,
812
+ ...rest
813
+ }) {
827
814
  useSSR(initialI18nStore, initialLanguage);
828
815
  return react.createElement(WrappedComponent, {
829
816
  ...rest
@@ -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}),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={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},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.props.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}}}));
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!--"),m=l+i.length,g=e.charAt(m);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||!g||"<"===g||t.children.push({type:"text",content:e.slice(m,e.indexOf("<",m))}),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&&"<"!==g&&g)){p=-1===c?s:r[c].children;var y=e.indexOf("<",m),N=e.slice(m,-1===y?void 0:y);o.test(N)&&(N=" "),(y>-1&&c+p.length>=0||" "!==N)&&p.push({type:"text",content:N})}})),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)}},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,N=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,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 b={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(x,E)};const O=(e={})=>{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(N(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)):N(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...a},m=(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},g=(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.props.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 x=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,v=n.isValidElement(x),E=v&&k(a,!0)&&!a.voidElement,b=l&&N(x)&&x.dummy&&!v,O=N(e)&&Object.hasOwnProperty.call(e,a.name);if(y(x)){const e=s.services.interpolator.interpolate(x,f,s.language);t.push(e)}else if(k(x)||E){const e=m(x,a,c);g(x,e,t,p)}else if(b){const e=h(u,a.children,c);g(x,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=m(x,a,c);g(x,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(N(x)&&!v){const e=a.children[0]?d:null;e&&t.push(e)}else g(x,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}),[])},x=h([{dummy:!0,children:e||[]}],d,A(e||[]));return T(x[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):N(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({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:f,shouldUnescape:m,...g}){const h=p||$();if(!h)return d(h,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:r}),e;const N=f||h.t.bind(h)||(e=>e),x={...I(),...h.options?.react};let v=u||N.ns||h.options?.defaultNS;v=y(v)?[v]:v||["translation"];const E=R(e,x,h,r),b=l||E||x.transEmptyNodeValue||r,{hashTransKey:O}=x,S=r||(O?O(E||b):E||b);h.options?.interpolation?.defaultVariables&&(o=o&&Object.keys(o).length>0?{...o,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables});const w=o||void 0!==t&&!h.options?.interpolation?.alwaysFormat||!e?i.interpolation:{interpolation:{...i.interpolation,prefix:"#$?",suffix:"?$#"}},k={...i,context:a||i.context,count:t,...o,...w,defaultValue:b,ns:v},T=S?N(S,k):b,A=L(c,T,h,r),C=j(A||e,T,h,x,k,m),P=s??x.defaultTransParent;return P?n.createElement(P,g,C):C}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=(e,t={})=>{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:N(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=>((e,n,t={})=>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,x=()=>U(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[v,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?g(i,t.lng,u,(()=>{S.current&&E(x)})):m(i,u,(()=>{S.current&&E(x)}))),p&&O&&O!==b&&S.current&&E(x);const s=()=>{S.current&&E(x)};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=[v,i,p];if(w.t=v,w.i18n=i,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?g(i,t.lng,u,(()=>e())):m(i,u,(()=>e()))}))};const B=(e,t,s={})=>{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({i18n:e,defaultNS:t,children:s}){const r=n.useMemo((()=>({i18n:e,defaultNS:t})),[e,t]);return n.createElement(_.Provider,{value:r},s)},e.Trans=function({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:d,shouldUnescape:f,...m}){const{i18n:g,defaultNS:h}=n.useContext(_)||{},y=p||g||$(),N=d||y?.t.bind(y);return P({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i,values:o,defaults:l,components:c,ns:u||N?.ns||h||y?.options?.defaultNS,i18n:y,t:d,shouldUnescape:f,...m})},e.TransWithoutContext=P,e.Translation=({ns:e,children:n,...t})=>{const[s,r,a]=F(e,t);return n(s,{i18n:r,lng:r.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({initialI18nStore:t,initialLanguage:s,...r}){return B(t,s),n.createElement(e,{...r})}return t.getInitialProps=K(e),t.displayName=`withI18nextSSR(${h(e)})`,t.WrappedComponent=e,t},e.withTranslation=(e,t={})=>function(s){function r({forwardedRef:r,...a}){const[i,o,l]=F(e,{...a,keyPrefix:t.keyPrefix}),c={...a,t:i,i18n:o,tReady:l};return t.withRef&&r?c.ref=r:!t.withRef&&r&&(c.forwardedRef=r),n.createElement(s,c)}r.displayName=`withI18nextTranslation(${h(s)})`,r.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(r,Object.assign({},e,{forwardedRef:t})))):r}}));
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.I18nextProvider = I18nextProvider;
7
7
  var _react = require("react");
8
8
  var _context = require("./context.js");
9
- function I18nextProvider(_ref) {
10
- let {
11
- i18n,
12
- defaultNS,
13
- children
14
- } = _ref;
9
+ function I18nextProvider({
10
+ i18n,
11
+ defaultNS,
12
+ children
13
+ }) {
15
14
  const value = (0, _react.useMemo)(() => ({
16
15
  i18n,
17
16
  defaultNS
@@ -13,23 +13,22 @@ Object.defineProperty(exports, "nodesToString", {
13
13
  var _react = require("react");
14
14
  var _TransWithoutContext = require("./TransWithoutContext.js");
15
15
  var _context = require("./context.js");
16
- function Trans(_ref) {
17
- let {
18
- children,
19
- count,
20
- parent,
21
- i18nKey,
22
- context,
23
- tOptions = {},
24
- values,
25
- defaults,
26
- components,
27
- ns,
28
- i18n: i18nFromProps,
29
- t: tFromProps,
30
- shouldUnescape,
31
- ...additionalProps
32
- } = _ref;
16
+ function Trans({
17
+ children,
18
+ count,
19
+ parent,
20
+ i18nKey,
21
+ context,
22
+ tOptions = {},
23
+ values,
24
+ defaults,
25
+ components,
26
+ ns,
27
+ i18n: i18nFromProps,
28
+ t: tFromProps,
29
+ shouldUnescape,
30
+ ...additionalProps
31
+ }) {
33
32
  const {
34
33
  i18n: i18nFromContext,
35
34
  defaultNS: defaultNSFromContext
@@ -250,23 +250,22 @@ const generateComponents = (components, translation, i18n, i18nKey) => {
250
250
  });
251
251
  return null;
252
252
  };
253
- function Trans(_ref) {
254
- let {
255
- children,
256
- count,
257
- parent,
258
- i18nKey,
259
- context,
260
- tOptions = {},
261
- values,
262
- defaults,
263
- components,
264
- ns,
265
- i18n: i18nFromProps,
266
- t: tFromProps,
267
- shouldUnescape,
268
- ...additionalProps
269
- } = _ref;
253
+ function Trans({
254
+ children,
255
+ count,
256
+ parent,
257
+ i18nKey,
258
+ context,
259
+ tOptions = {},
260
+ values,
261
+ defaults,
262
+ components,
263
+ ns,
264
+ i18n: i18nFromProps,
265
+ t: tFromProps,
266
+ shouldUnescape,
267
+ ...additionalProps
268
+ }) {
270
269
  const i18n = i18nFromProps || (0, _i18nInstance.getI18n)();
271
270
  if (!i18n) {
272
271
  (0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Translation = void 0;
7
7
  var _useTranslation = require("./useTranslation.js");
8
- const Translation = _ref => {
9
- let {
10
- ns,
11
- children,
12
- ...options
13
- } = _ref;
8
+ const Translation = ({
9
+ ns,
10
+ children,
11
+ ...options
12
+ }) => {
14
13
  const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, options);
15
14
  return children(t, {
16
15
  i18n,
@@ -15,8 +15,7 @@ let defaultOptions = {
15
15
  useSuspense: true,
16
16
  unescape: _unescape.unescape
17
17
  };
18
- const setDefaults = function () {
19
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
+ const setDefaults = (options = {}) => {
20
19
  defaultOptions = {
21
20
  ...defaultOptions,
22
21
  ...options
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useSSR = void 0;
7
7
  var _react = require("react");
8
8
  var _context = require("./context.js");
9
- const useSSR = function (initialI18nStore, initialLanguage) {
10
- let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
9
+ const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
11
10
  const {
12
11
  i18n: i18nFromProps
13
12
  } = props;
@@ -16,8 +16,7 @@ const usePrevious = (value, ignore) => {
16
16
  };
17
17
  const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
18
18
  const useMemoizedT = (i18n, language, namespace, keyPrefix) => (0, _react.useCallback)(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
19
- const useTranslation = function (ns) {
20
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ const useTranslation = (ns, props = {}) => {
21
20
  const {
22
21
  i18n: i18nFromProps
23
22
  } = props;
@@ -53,8 +53,7 @@ const loadLanguages = (i18n, lng, ns, cb) => {
53
53
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
54
54
  };
55
55
  exports.loadLanguages = loadLanguages;
56
- const hasLoadedNamespace = function (ns, i18n) {
57
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
56
+ const hasLoadedNamespace = (ns, i18n, options = {}) => {
58
57
  if (!i18n.languages || !i18n.languages.length) {
59
58
  warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
60
59
  languages: i18n.languages
@@ -9,12 +9,11 @@ var _useSSR = require("./useSSR.js");
9
9
  var _context = require("./context.js");
10
10
  var _utils = require("./utils.js");
11
11
  const withSSR = () => function Extend(WrappedComponent) {
12
- function I18nextWithSSR(_ref) {
13
- let {
14
- initialI18nStore,
15
- initialLanguage,
16
- ...rest
17
- } = _ref;
12
+ function I18nextWithSSR({
13
+ initialI18nStore,
14
+ initialLanguage,
15
+ ...rest
16
+ }) {
18
17
  (0, _useSSR.useSSR)(initialI18nStore, initialLanguage);
19
18
  return (0, _react.createElement)(WrappedComponent, {
20
19
  ...rest
@@ -7,37 +7,33 @@ exports.withTranslation = void 0;
7
7
  var _react = require("react");
8
8
  var _useTranslation = require("./useTranslation.js");
9
9
  var _utils = require("./utils.js");
10
- const withTranslation = function (ns) {
11
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12
- return function Extend(WrappedComponent) {
13
- function I18nextWithTranslation(_ref) {
14
- let {
15
- forwardedRef,
16
- ...rest
17
- } = _ref;
18
- const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, {
19
- ...rest,
20
- keyPrefix: options.keyPrefix
21
- });
22
- const passDownProps = {
23
- ...rest,
24
- t,
25
- i18n,
26
- tReady: ready
27
- };
28
- if (options.withRef && forwardedRef) {
29
- passDownProps.ref = forwardedRef;
30
- } else if (!options.withRef && forwardedRef) {
31
- passDownProps.forwardedRef = forwardedRef;
32
- }
33
- return (0, _react.createElement)(WrappedComponent, passDownProps);
10
+ const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
11
+ function I18nextWithTranslation({
12
+ forwardedRef,
13
+ ...rest
14
+ }) {
15
+ const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, {
16
+ ...rest,
17
+ keyPrefix: options.keyPrefix
18
+ });
19
+ const passDownProps = {
20
+ ...rest,
21
+ t,
22
+ i18n,
23
+ tReady: ready
24
+ };
25
+ if (options.withRef && forwardedRef) {
26
+ passDownProps.ref = forwardedRef;
27
+ } else if (!options.withRef && forwardedRef) {
28
+ passDownProps.forwardedRef = forwardedRef;
34
29
  }
35
- I18nextWithTranslation.displayName = `withI18nextTranslation(${(0, _utils.getDisplayName)(WrappedComponent)})`;
36
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
37
- const forwardRef = (props, ref) => (0, _react.createElement)(I18nextWithTranslation, Object.assign({}, props, {
38
- forwardedRef: ref
39
- }));
40
- return options.withRef ? (0, _react.forwardRef)(forwardRef) : I18nextWithTranslation;
41
- };
30
+ return (0, _react.createElement)(WrappedComponent, passDownProps);
31
+ }
32
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${(0, _utils.getDisplayName)(WrappedComponent)})`;
33
+ I18nextWithTranslation.WrappedComponent = WrappedComponent;
34
+ const forwardRef = (props, ref) => (0, _react.createElement)(I18nextWithTranslation, Object.assign({}, props, {
35
+ forwardedRef: ref
36
+ }));
37
+ return options.withRef ? (0, _react.forwardRef)(forwardRef) : I18nextWithTranslation;
42
38
  };
43
39
  exports.withTranslation = withTranslation;
@@ -1 +1 @@
1
- {"type":"module","version":"15.5.2"}
1
+ {"type":"module","version":"15.5.3"}
@@ -163,8 +163,7 @@
163
163
  });
164
164
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
165
165
  };
166
- const hasLoadedNamespace = function (ns, i18n) {
167
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
166
+ const hasLoadedNamespace = (ns, i18n, options = {}) => {
168
167
  if (!i18n.languages || !i18n.languages.length) {
169
168
  warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
170
169
  languages: i18n.languages
@@ -218,8 +217,7 @@
218
217
  useSuspense: true,
219
218
  unescape
220
219
  };
221
- const setDefaults = function () {
222
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
220
+ const setDefaults = (options = {}) => {
223
221
  defaultOptions = {
224
222
  ...defaultOptions,
225
223
  ...options
@@ -471,23 +469,22 @@
471
469
  });
472
470
  return null;
473
471
  };
474
- function Trans$1(_ref) {
475
- let {
476
- children,
477
- count,
478
- parent,
479
- i18nKey,
480
- context,
481
- tOptions = {},
482
- values,
483
- defaults,
484
- components,
485
- ns,
486
- i18n: i18nFromProps,
487
- t: tFromProps,
488
- shouldUnescape,
489
- ...additionalProps
490
- } = _ref;
472
+ function Trans$1({
473
+ children,
474
+ count,
475
+ parent,
476
+ i18nKey,
477
+ context,
478
+ tOptions = {},
479
+ values,
480
+ defaults,
481
+ components,
482
+ ns,
483
+ i18n: i18nFromProps,
484
+ t: tFromProps,
485
+ shouldUnescape,
486
+ ...additionalProps
487
+ }) {
491
488
  const i18n = i18nFromProps || getI18n();
492
489
  if (!i18n) {
493
490
  warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -585,23 +582,22 @@
585
582
  return ret;
586
583
  };
587
584
 
588
- function Trans(_ref) {
589
- let {
590
- children,
591
- count,
592
- parent,
593
- i18nKey,
594
- context,
595
- tOptions = {},
596
- values,
597
- defaults,
598
- components,
599
- ns,
600
- i18n: i18nFromProps,
601
- t: tFromProps,
602
- shouldUnescape,
603
- ...additionalProps
604
- } = _ref;
585
+ function Trans({
586
+ children,
587
+ count,
588
+ parent,
589
+ i18nKey,
590
+ context,
591
+ tOptions = {},
592
+ values,
593
+ defaults,
594
+ components,
595
+ ns,
596
+ i18n: i18nFromProps,
597
+ t: tFromProps,
598
+ shouldUnescape,
599
+ ...additionalProps
600
+ }) {
605
601
  const {
606
602
  i18n: i18nFromContext,
607
603
  defaultNS: defaultNSFromContext
@@ -635,8 +631,7 @@
635
631
  };
636
632
  const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
637
633
  const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
638
- const useTranslation = function (ns) {
639
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
634
+ const useTranslation = (ns, props = {}) => {
640
635
  const {
641
636
  i18n: i18nFromProps
642
637
  } = props;
@@ -732,46 +727,41 @@
732
727
  });
733
728
  };
734
729
 
735
- const withTranslation = function (ns) {
736
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
737
- return function Extend(WrappedComponent) {
738
- function I18nextWithTranslation(_ref) {
739
- let {
740
- forwardedRef,
741
- ...rest
742
- } = _ref;
743
- const [t, i18n, ready] = useTranslation(ns, {
744
- ...rest,
745
- keyPrefix: options.keyPrefix
746
- });
747
- const passDownProps = {
748
- ...rest,
749
- t,
750
- i18n,
751
- tReady: ready
752
- };
753
- if (options.withRef && forwardedRef) {
754
- passDownProps.ref = forwardedRef;
755
- } else if (!options.withRef && forwardedRef) {
756
- passDownProps.forwardedRef = forwardedRef;
757
- }
758
- return react.createElement(WrappedComponent, passDownProps);
730
+ const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
731
+ function I18nextWithTranslation({
732
+ forwardedRef,
733
+ ...rest
734
+ }) {
735
+ const [t, i18n, ready] = useTranslation(ns, {
736
+ ...rest,
737
+ keyPrefix: options.keyPrefix
738
+ });
739
+ const passDownProps = {
740
+ ...rest,
741
+ t,
742
+ i18n,
743
+ tReady: ready
744
+ };
745
+ if (options.withRef && forwardedRef) {
746
+ passDownProps.ref = forwardedRef;
747
+ } else if (!options.withRef && forwardedRef) {
748
+ passDownProps.forwardedRef = forwardedRef;
759
749
  }
760
- I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
761
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
762
- const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
763
- forwardedRef: ref
764
- }));
765
- return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
766
- };
750
+ return react.createElement(WrappedComponent, passDownProps);
751
+ }
752
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
753
+ I18nextWithTranslation.WrappedComponent = WrappedComponent;
754
+ const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
755
+ forwardedRef: ref
756
+ }));
757
+ return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
767
758
  };
768
759
 
769
- const Translation = _ref => {
770
- let {
771
- ns,
772
- children,
773
- ...options
774
- } = _ref;
760
+ const Translation = ({
761
+ ns,
762
+ children,
763
+ ...options
764
+ }) => {
775
765
  const [t, i18n, ready] = useTranslation(ns, options);
776
766
  return children(t, {
777
767
  i18n,
@@ -779,12 +769,11 @@
779
769
  }, ready);
780
770
  };
781
771
 
782
- function I18nextProvider(_ref) {
783
- let {
784
- i18n,
785
- defaultNS,
786
- children
787
- } = _ref;
772
+ function I18nextProvider({
773
+ i18n,
774
+ defaultNS,
775
+ children
776
+ }) {
788
777
  const value = react.useMemo(() => ({
789
778
  i18n,
790
779
  defaultNS
@@ -794,8 +783,7 @@
794
783
  }, children);
795
784
  }
796
785
 
797
- const useSSR = function (initialI18nStore, initialLanguage) {
798
- let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
786
+ const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
799
787
  const {
800
788
  i18n: i18nFromProps
801
789
  } = props;
@@ -822,12 +810,11 @@
822
810
  };
823
811
 
824
812
  const withSSR = () => function Extend(WrappedComponent) {
825
- function I18nextWithSSR(_ref) {
826
- let {
827
- initialI18nStore,
828
- initialLanguage,
829
- ...rest
830
- } = _ref;
813
+ function I18nextWithSSR({
814
+ initialI18nStore,
815
+ initialLanguage,
816
+ ...rest
817
+ }) {
831
818
  useSSR(initialI18nStore, initialLanguage);
832
819
  return react.createElement(WrappedComponent, {
833
820
  ...rest
@@ -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}),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.props.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)}),{key:r})},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}}}));
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 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!--"),m=l+i.length,g=e.charAt(m);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||!g||"<"===g||t.children.push({type:"text",content:e.slice(m,e.indexOf("<",m))}),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&&"<"!==g&&g)){p=-1===c?s:r[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=(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)}},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,x=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,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},v=e=>b[e];let E={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(N,v)};const O=(e={})=>{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 a="";const i=R(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=A(p,t,s,r);a+=`<${i}>${d}</${i}>`}else if(null!==e)if(x(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=>{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,...a},m=(e,t,s)=>{const r=k(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},g=(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.props.ref??e.ref},a?null:t)})))},h=(t,a,c)=>{const u=R(t);return R(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,b=n.isValidElement(N),v=b&&T(a,!0)&&!a.voidElement,E=l&&x(N)&&N.dummy&&!b,O=x(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(T(N)||v){const e=m(N,a,c);g(N,e,t,p)}else if(E){const e=h(u,a.children,c);g(N,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=m(N,a,c);g(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(x(N)&&!b){const e=a.children[0]?d:null;e&&t.push(e)}else g(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,R(e||[]));return k(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):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({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:f,shouldUnescape:m,...g}){const h=p||$();if(!h)return d(h,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:r}),e;const x=f||h.t.bind(h)||(e=>e),N={...I(),...h.options?.react};let b=u||x.ns||h.options?.defaultNS;b=y(b)?[b]:b||["translation"];const v=A(e,N,h,r),E=l||v||N.transEmptyNodeValue||r,{hashTransKey:O}=N,S=r||(O?O(v||E):v||E);h.options?.interpolation?.defaultVariables&&(o=o&&Object.keys(o).length>0?{...o,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables});const w=o||void 0!==t&&!h.options?.interpolation?.alwaysFormat||!e?i.interpolation:{interpolation:{...i.interpolation,prefix:"#$?",suffix:"?$#"}},T={...i,context:a||i.context,count:t,...o,...w,defaultValue:E,ns:b},k=S?x(S,T):E,R=L(c,k,h,r),C=j(R||e,k,h,N,T,m),P=s??N.defaultTransParent;return P?n.createElement(P,g,C):C}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=(e,t={})=>{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: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}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=>((e,n,t={})=>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),[b,v]=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?g(i,t.lng,u,(()=>{S.current&&v(N)})):m(i,u,(()=>{S.current&&v(N)}))),p&&O&&O!==E&&S.current&&v(N);const s=()=>{S.current&&v(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,E]),n.useEffect((()=>{S.current&&p&&v(h)}),[i,c,p]);const w=[b,i,p];if(w.t=b,w.i18n=i,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?g(i,t.lng,u,(()=>e())):m(i,u,(()=>e()))}))};const B=(e,t,s={})=>{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({i18n:e,defaultNS:t,children:s}){const r=n.useMemo((()=>({i18n:e,defaultNS:t})),[e,t]);return n.createElement(_.Provider,{value:r},s)},e.Trans=function({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:d,shouldUnescape:f,...m}){const{i18n:g,defaultNS:h}=n.useContext(_)||{},y=p||g||$(),x=d||y?.t.bind(y);return P({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i,values:o,defaults:l,components:c,ns:u||x?.ns||h||y?.options?.defaultNS,i18n:y,t:d,shouldUnescape:f,...m})},e.TransWithoutContext=P,e.Translation=({ns:e,children:n,...t})=>{const[s,r,a]=F(e,t);return n(s,{i18n:r,lng:r.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({initialI18nStore:t,initialLanguage:s,...r}){return B(t,s),n.createElement(e,{...r})}return t.getInitialProps=K(e),t.displayName=`withI18nextSSR(${h(e)})`,t.WrappedComponent=e,t},e.withTranslation=(e,t={})=>function(s){function r({forwardedRef:r,...a}){const[i,o,l]=F(e,{...a,keyPrefix:t.keyPrefix}),c={...a,t:i,i18n:o,tReady:l};return t.withRef&&r?c.ref=r:!t.withRef&&r&&(c.forwardedRef=r),n.createElement(s,c)}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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-i18next",
3
- "version": "15.5.2",
3
+ "version": "15.5.3",
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",
@@ -64,7 +64,7 @@
64
64
  "url": "https://github.com/i18next/react-i18next.git"
65
65
  },
66
66
  "dependencies": {
67
- "@babel/runtime": "^7.25.0",
67
+ "@babel/runtime": "^7.27.6",
68
68
  "html-parse-stringify": "^3.0.1"
69
69
  },
70
70
  "peerDependencies": {
@@ -84,17 +84,17 @@
84
84
  }
85
85
  },
86
86
  "devDependencies": {
87
- "@babel/cli": "^7.24.8",
88
- "@babel/core": "^7.25.2",
89
- "@babel/eslint-parser": "^7.25.1",
87
+ "@babel/cli": "^7.27.2",
88
+ "@babel/core": "^7.27.4",
89
+ "@babel/eslint-parser": "^7.27.5",
90
90
  "@babel/plugin-proposal-async-generator-functions": "^7.20.7",
91
91
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
92
- "@babel/plugin-transform-modules-commonjs": "^7.24.8",
93
- "@babel/plugin-transform-runtime": "^7.24.7",
92
+ "@babel/plugin-transform-modules-commonjs": "^7.27.1",
93
+ "@babel/plugin-transform-runtime": "^7.27.4",
94
94
  "@babel/polyfill": "^7.12.1",
95
- "@babel/preset-env": "^7.25.3",
96
- "@babel/preset-react": "^7.24.7",
97
- "@babel/register": "^7.24.6",
95
+ "@babel/preset-env": "^7.27.2",
96
+ "@babel/preset-react": "^7.27.1",
97
+ "@babel/register": "^7.27.1",
98
98
  "@rollup/plugin-babel": "^6.0.4",
99
99
  "@rollup/plugin-commonjs": "^26.0.1",
100
100
  "@rollup/plugin-node-resolve": "^15.2.3",
@@ -123,7 +123,7 @@
123
123
  "eslint-plugin-testing-library": "^6.3.0",
124
124
  "happy-dom": "^14.12.3",
125
125
  "husky": "^9.1.4",
126
- "i18next": "^23.12.2",
126
+ "i18next": "^25.2.1",
127
127
  "lint-staged": "^15.2.9",
128
128
  "mkdirp": "^3.0.1",
129
129
  "prettier": "^3.3.3",
package/react-i18next.js CHANGED
@@ -163,8 +163,7 @@
163
163
  });
164
164
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
165
165
  };
166
- const hasLoadedNamespace = function (ns, i18n) {
167
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
166
+ const hasLoadedNamespace = (ns, i18n, options = {}) => {
168
167
  if (!i18n.languages || !i18n.languages.length) {
169
168
  warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
170
169
  languages: i18n.languages
@@ -218,8 +217,7 @@
218
217
  useSuspense: true,
219
218
  unescape
220
219
  };
221
- const setDefaults = function () {
222
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
220
+ const setDefaults = (options = {}) => {
223
221
  defaultOptions = {
224
222
  ...defaultOptions,
225
223
  ...options
@@ -471,23 +469,22 @@
471
469
  });
472
470
  return null;
473
471
  };
474
- function Trans$1(_ref) {
475
- let {
476
- children,
477
- count,
478
- parent,
479
- i18nKey,
480
- context,
481
- tOptions = {},
482
- values,
483
- defaults,
484
- components,
485
- ns,
486
- i18n: i18nFromProps,
487
- t: tFromProps,
488
- shouldUnescape,
489
- ...additionalProps
490
- } = _ref;
472
+ function Trans$1({
473
+ children,
474
+ count,
475
+ parent,
476
+ i18nKey,
477
+ context,
478
+ tOptions = {},
479
+ values,
480
+ defaults,
481
+ components,
482
+ ns,
483
+ i18n: i18nFromProps,
484
+ t: tFromProps,
485
+ shouldUnescape,
486
+ ...additionalProps
487
+ }) {
491
488
  const i18n = i18nFromProps || getI18n();
492
489
  if (!i18n) {
493
490
  warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -585,23 +582,22 @@
585
582
  return ret;
586
583
  };
587
584
 
588
- function Trans(_ref) {
589
- let {
590
- children,
591
- count,
592
- parent,
593
- i18nKey,
594
- context,
595
- tOptions = {},
596
- values,
597
- defaults,
598
- components,
599
- ns,
600
- i18n: i18nFromProps,
601
- t: tFromProps,
602
- shouldUnescape,
603
- ...additionalProps
604
- } = _ref;
585
+ function Trans({
586
+ children,
587
+ count,
588
+ parent,
589
+ i18nKey,
590
+ context,
591
+ tOptions = {},
592
+ values,
593
+ defaults,
594
+ components,
595
+ ns,
596
+ i18n: i18nFromProps,
597
+ t: tFromProps,
598
+ shouldUnescape,
599
+ ...additionalProps
600
+ }) {
605
601
  const {
606
602
  i18n: i18nFromContext,
607
603
  defaultNS: defaultNSFromContext
@@ -635,8 +631,7 @@
635
631
  };
636
632
  const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
637
633
  const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
638
- const useTranslation = function (ns) {
639
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
634
+ const useTranslation = (ns, props = {}) => {
640
635
  const {
641
636
  i18n: i18nFromProps
642
637
  } = props;
@@ -732,46 +727,41 @@
732
727
  });
733
728
  };
734
729
 
735
- const withTranslation = function (ns) {
736
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
737
- return function Extend(WrappedComponent) {
738
- function I18nextWithTranslation(_ref) {
739
- let {
740
- forwardedRef,
741
- ...rest
742
- } = _ref;
743
- const [t, i18n, ready] = useTranslation(ns, {
744
- ...rest,
745
- keyPrefix: options.keyPrefix
746
- });
747
- const passDownProps = {
748
- ...rest,
749
- t,
750
- i18n,
751
- tReady: ready
752
- };
753
- if (options.withRef && forwardedRef) {
754
- passDownProps.ref = forwardedRef;
755
- } else if (!options.withRef && forwardedRef) {
756
- passDownProps.forwardedRef = forwardedRef;
757
- }
758
- return react.createElement(WrappedComponent, passDownProps);
730
+ const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
731
+ function I18nextWithTranslation({
732
+ forwardedRef,
733
+ ...rest
734
+ }) {
735
+ const [t, i18n, ready] = useTranslation(ns, {
736
+ ...rest,
737
+ keyPrefix: options.keyPrefix
738
+ });
739
+ const passDownProps = {
740
+ ...rest,
741
+ t,
742
+ i18n,
743
+ tReady: ready
744
+ };
745
+ if (options.withRef && forwardedRef) {
746
+ passDownProps.ref = forwardedRef;
747
+ } else if (!options.withRef && forwardedRef) {
748
+ passDownProps.forwardedRef = forwardedRef;
759
749
  }
760
- I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
761
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
762
- const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
763
- forwardedRef: ref
764
- }));
765
- return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
766
- };
750
+ return react.createElement(WrappedComponent, passDownProps);
751
+ }
752
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
753
+ I18nextWithTranslation.WrappedComponent = WrappedComponent;
754
+ const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
755
+ forwardedRef: ref
756
+ }));
757
+ return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
767
758
  };
768
759
 
769
- const Translation = _ref => {
770
- let {
771
- ns,
772
- children,
773
- ...options
774
- } = _ref;
760
+ const Translation = ({
761
+ ns,
762
+ children,
763
+ ...options
764
+ }) => {
775
765
  const [t, i18n, ready] = useTranslation(ns, options);
776
766
  return children(t, {
777
767
  i18n,
@@ -779,12 +769,11 @@
779
769
  }, ready);
780
770
  };
781
771
 
782
- function I18nextProvider(_ref) {
783
- let {
784
- i18n,
785
- defaultNS,
786
- children
787
- } = _ref;
772
+ function I18nextProvider({
773
+ i18n,
774
+ defaultNS,
775
+ children
776
+ }) {
788
777
  const value = react.useMemo(() => ({
789
778
  i18n,
790
779
  defaultNS
@@ -794,8 +783,7 @@
794
783
  }, children);
795
784
  }
796
785
 
797
- const useSSR = function (initialI18nStore, initialLanguage) {
798
- let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
786
+ const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
799
787
  const {
800
788
  i18n: i18nFromProps
801
789
  } = props;
@@ -822,12 +810,11 @@
822
810
  };
823
811
 
824
812
  const withSSR = () => function Extend(WrappedComponent) {
825
- function I18nextWithSSR(_ref) {
826
- let {
827
- initialI18nStore,
828
- initialLanguage,
829
- ...rest
830
- } = _ref;
813
+ function I18nextWithSSR({
814
+ initialI18nStore,
815
+ initialLanguage,
816
+ ...rest
817
+ }) {
831
818
  useSSR(initialI18nStore, initialLanguage);
832
819
  return react.createElement(WrappedComponent, {
833
820
  ...rest
@@ -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}),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.props.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)}),{key:r})},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}}}));
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 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!--"),m=l+i.length,g=e.charAt(m);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||!g||"<"===g||t.children.push({type:"text",content:e.slice(m,e.indexOf("<",m))}),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&&"<"!==g&&g)){p=-1===c?s:r[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=(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)}},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,x=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,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},v=e=>b[e];let E={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(N,v)};const O=(e={})=>{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 a="";const i=R(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=A(p,t,s,r);a+=`<${i}>${d}</${i}>`}else if(null!==e)if(x(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=>{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,...a},m=(e,t,s)=>{const r=k(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},g=(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.props.ref??e.ref},a?null:t)})))},h=(t,a,c)=>{const u=R(t);return R(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,b=n.isValidElement(N),v=b&&T(a,!0)&&!a.voidElement,E=l&&x(N)&&N.dummy&&!b,O=x(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(T(N)||v){const e=m(N,a,c);g(N,e,t,p)}else if(E){const e=h(u,a.children,c);g(N,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=m(N,a,c);g(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(x(N)&&!b){const e=a.children[0]?d:null;e&&t.push(e)}else g(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,R(e||[]));return k(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):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({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:f,shouldUnescape:m,...g}){const h=p||$();if(!h)return d(h,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:r}),e;const x=f||h.t.bind(h)||(e=>e),N={...I(),...h.options?.react};let b=u||x.ns||h.options?.defaultNS;b=y(b)?[b]:b||["translation"];const v=A(e,N,h,r),E=l||v||N.transEmptyNodeValue||r,{hashTransKey:O}=N,S=r||(O?O(v||E):v||E);h.options?.interpolation?.defaultVariables&&(o=o&&Object.keys(o).length>0?{...o,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables});const w=o||void 0!==t&&!h.options?.interpolation?.alwaysFormat||!e?i.interpolation:{interpolation:{...i.interpolation,prefix:"#$?",suffix:"?$#"}},T={...i,context:a||i.context,count:t,...o,...w,defaultValue:E,ns:b},k=S?x(S,T):E,R=L(c,k,h,r),C=j(R||e,k,h,N,T,m),P=s??N.defaultTransParent;return P?n.createElement(P,g,C):C}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=(e,t={})=>{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: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}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=>((e,n,t={})=>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),[b,v]=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?g(i,t.lng,u,(()=>{S.current&&v(N)})):m(i,u,(()=>{S.current&&v(N)}))),p&&O&&O!==E&&S.current&&v(N);const s=()=>{S.current&&v(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,E]),n.useEffect((()=>{S.current&&p&&v(h)}),[i,c,p]);const w=[b,i,p];if(w.t=b,w.i18n=i,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?g(i,t.lng,u,(()=>e())):m(i,u,(()=>e()))}))};const B=(e,t,s={})=>{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({i18n:e,defaultNS:t,children:s}){const r=n.useMemo((()=>({i18n:e,defaultNS:t})),[e,t]);return n.createElement(_.Provider,{value:r},s)},e.Trans=function({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:d,shouldUnescape:f,...m}){const{i18n:g,defaultNS:h}=n.useContext(_)||{},y=p||g||$(),x=d||y?.t.bind(y);return P({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i,values:o,defaults:l,components:c,ns:u||x?.ns||h||y?.options?.defaultNS,i18n:y,t:d,shouldUnescape:f,...m})},e.TransWithoutContext=P,e.Translation=({ns:e,children:n,...t})=>{const[s,r,a]=F(e,t);return n(s,{i18n:r,lng:r.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({initialI18nStore:t,initialLanguage:s,...r}){return B(t,s),n.createElement(e,{...r})}return t.getInitialProps=K(e),t.displayName=`withI18nextSSR(${h(e)})`,t.WrappedComponent=e,t},e.withTranslation=(e,t={})=>function(s){function r({forwardedRef:r,...a}){const[i,o,l]=F(e,{...a,keyPrefix:t.keyPrefix}),c={...a,t:i,i18n:o,tReady:l};return t.withRef&&r?c.ref=r:!t.withRef&&r&&(c.forwardedRef=r),n.createElement(s,c)}r.displayName=`withI18nextTranslation(${h(s)})`,r.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(r,Object.assign({},e,{forwardedRef:t})))):r}}));