react-i18next 16.0.0 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/amd/react-i18next.js +3028 -844
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/IcuTrans.js +35 -0
- package/dist/commonjs/IcuTransUtils/TranslationParserError.js +18 -0
- package/dist/commonjs/IcuTransUtils/htmlEntityDecoder.js +218 -0
- package/dist/commonjs/IcuTransUtils/index.js +49 -0
- package/dist/commonjs/IcuTransUtils/renderTranslation.js +114 -0
- package/dist/commonjs/IcuTransUtils/tokenizer.js +58 -0
- package/dist/commonjs/IcuTransWithoutContext.js +56 -0
- package/dist/commonjs/TransWithoutContext.js +2 -1
- package/dist/es/IcuTrans.js +29 -0
- package/dist/es/IcuTransUtils/TranslationParserError.js +11 -0
- package/dist/es/IcuTransUtils/htmlEntityDecoder.js +211 -0
- package/dist/es/IcuTransUtils/index.js +4 -0
- package/dist/es/IcuTransUtils/renderTranslation.js +106 -0
- package/dist/es/IcuTransUtils/tokenizer.js +51 -0
- package/dist/es/IcuTransWithoutContext.js +49 -0
- package/dist/es/TransWithoutContext.js +2 -1
- package/dist/es/package.json +1 -1
- package/dist/umd/react-i18next.js +3031 -847
- package/dist/umd/react-i18next.min.js +1 -1
- package/icu.macro.js +170 -48
- package/package.json +6 -3
- package/react-i18next.js +3031 -847
- package/react-i18next.min.js +1 -1
- package/src/IcuTrans.js +103 -0
- package/src/IcuTransUtils/TranslationParserError.js +24 -0
- package/src/IcuTransUtils/htmlEntityDecoder.js +264 -0
- package/src/IcuTransUtils/index.js +4 -0
- package/src/IcuTransUtils/renderTranslation.js +215 -0
- package/src/IcuTransUtils/tokenizer.js +78 -0
- package/src/IcuTransWithoutContext.js +146 -0
- package/src/TransWithoutContext.js +5 -1
|
@@ -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!--"),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,b={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},v=e=>b[e];let E={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(x,v)};const O=(e={})=>{E={...E,...e}},I=()=>E;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,o)=>{if(""===s)return[];const l=a.transKeepBasicHtmlNodesFor||[],u=s&&new RegExp(l.map((e=>`<${e}`)).join("|")).test(s);if(!(e||t||u||o))return[s];const p=t??{},d=e=>{A(e).forEach((e=>{y(e)||(k(e)?d(T(e)):N(e)&&!n.isValidElement(e)&&Object.assign(p,e))}))};d(e);const f=c(`<0>${s}</0>`),m={...p,...i},g=(e,t,s)=>{const r=T(e),a=x(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===a.length||e.props?.i18nIsDynamicList?r:a},h=(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)})))},x=(e,s,i)=>{const c=A(e);return A(s).reduce(((e,s,p)=>{const d=s.children?.[0]?.content&&r.services.interpolator.interpolate(s.children[0].content,m,r.language);if("tag"===s.type){let o=c[parseInt(s.name,10)];!o&&t&&(o=t[s.name]),1!==i.length||o||(o=i[0][s.name]),o||(o={});const f=0!==Object.keys(s.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:s.attrs},o):o,b=n.isValidElement(f),v=b&&k(s,!0)&&!s.voidElement,E=u&&N(f)&&f.dummy&&!b,O=N(t)&&Object.hasOwnProperty.call(t,s.name);if(y(f)){const n=r.services.interpolator.interpolate(f,m,r.language);e.push(n)}else if(k(f)||v){const n=g(f,s,i);h(f,n,e,p)}else if(E){const n=x(c,s.children,i);h(f,n,e,p)}else if(Number.isNaN(parseFloat(s.name)))if(O){const n=g(f,s,i);h(f,n,e,p,s.voidElement)}else if(a.transSupportBasicHtmlNodes&&l.indexOf(s.name)>-1)if(s.voidElement)e.push(n.createElement(s.name,{key:`${s.name}-${p}`}));else{const t=x(c,s.children,i);e.push(n.createElement(s.name,{key:`${s.name}-${p}`},t))}else if(s.voidElement)e.push(`<${s.name} />`);else{const n=x(c,s.children,i);e.push(`<${s.name}>${n}</${s.name}>`)}else if(N(f)&&!b){const n=s.children[0]?d:null;n&&e.push(n)}else h(f,d,e,p,1!==s.children.length||!d)}else if("text"===s.type){const t=a.transWrapTextNodes,i=o?a.unescape(r.services.interpolator.interpolate(s.content,m,r.language)):r.services.interpolator.interpolate(s.content,m,r.language);t?e.push(n.createElement(t,{key:`${s.name}-${p}`},i)):e.push(i)}return e}),[])},b=x([{dummy:!0,children:e||[]}],f,A(e||[]));return T(b[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,P=e=>!!N(e)&&(!Array.isArray(e)&&Object.keys(e).reduce(((e,n)=>e&&Number.isNaN(Number.parseFloat(n))),!0));function V({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 b=u||N.ns||h.options?.defaultNS;b=y(b)?[b]:b||["translation"];const v=R(e,x,h,r),E=l||v||x.transEmptyNodeValue||r,{hashTransKey:O}=x,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:"?$#"}},k={...i,context:a||i.context,count:t,...o,...w,defaultValue:E,ns:b},T=S?N(S,k):E,A=L(c,T,h,r);let C=A||e,V=null;P(A)&&(V=A,C=e);const _=j(C,V,T,h,x,k,m),D=s??x.defaultTransParent;return D?n.createElement(D,g,_):_}const _={type:"3rdParty",init(e){O(e.options.react),w(e)}},D=n.createContext();class K{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const z=e=>async n=>({...await(e.getInitialProps?.(n))??{},...U()}),U=()=>{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 F=(e,n,t,s)=>e.getFixedT(n,t,s),B=(e,t={})=>{const{i18n:s}=t,{i18n:r,defaultNS:a}=n.useContext(D)||{},i=s||r||$();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new K),!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&&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(F(e,t,s,r),[e,t,s,r]))(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,x=()=>F(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(x)})):m(i,u,(()=>{S.current&&v(x)}))),p&&O&&O!==E&&S.current&&v(x);const s=()=>{S.current&&v(x)};return e&&i?.on(e,s),n&&i?.store.on(n,s),()=>{S.current=!1,i&&e&&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 W=(e,t,s={})=>{const{i18n:r}=s,{i18n:a}=n.useContext(D)||{},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=D,e.I18nextProvider=function({i18n:e,defaultNS:t,children:s}){const r=n.useMemo((()=>({i18n:e,defaultNS:t})),[e,t]);return n.createElement(D.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(D)||{},y=p||g||$(),N=d||y?.t.bind(y);return V({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=V,e.Translation=({ns:e,children:n,...t})=>{const[s,r,a]=B(e,t);return n(s,{i18n:r,lng:r.language},a)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=I,e.getI18n=$,e.getInitialProps=U,e.initReactI18next=_,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=W,e.useTranslation=B,e.withSSR=()=>function(e){function t({initialI18nStore:t,initialLanguage:s,...r}){return W(t,s),n.createElement(e,{...r})}return t.getInitialProps=z(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]=B(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}}));
|
|
1
|
+
define(["exports","react"],(function(e,t){"use strict";const s=e=>"string"==typeof e,n=()=>{let e,t;const s=new Promise(((s,n)=>{e=s,t=n}));return s.resolve=e,s.reject=t,s},i=e=>null==e?"":""+e,o=/###/g,a=e=>e&&e.indexOf("###")>-1?e.replace(o,"."):e,r=e=>!e||s(e),l=(e,t,n)=>{const i=s(t)?t.split("."):t;let o=0;for(;o<i.length-1;){if(r(e))return{};const t=a(i[o]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++o}return r(e)?{}:{obj:e,k:a(i[o])}},c=(e,t,s)=>{const{obj:n,k:i}=l(e,t,Object);if(void 0!==n||1===t.length)return void(n[i]=s);let o=t[t.length-1],a=t.slice(0,t.length-1),r=l(e,a,Object);for(;void 0===r.obj&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),r=l(e,a,Object),r?.obj&&void 0!==r.obj[`${r.k}.${o}`]&&(r.obj=void 0);r.obj[`${r.k}.${o}`]=s},u=(e,t)=>{const{obj:s,k:n}=l(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,n))return s[n]},p=(e,t,n)=>{for(const i in t)"__proto__"!==i&&"constructor"!==i&&(i in e?s(e[i])||e[i]instanceof String||s(t[i])||t[i]instanceof String?n&&(e[i]=t[i]):p(e[i],t[i],n):e[i]=t[i]);return e},h=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var d={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const g=e=>s(e)?e.replace(/[&<>"'\/]/g,(e=>d[e])):e;const f=[" ",",","?","!",";"],m=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}(20),y=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const n=t.split(s);let i=e;for(let e=0;e<n.length;){if(!i||"object"!=typeof i)return;let t,o="";for(let a=e;a<n.length;++a)if(a!==e&&(o+=s),o+=n[a],t=i[o],void 0!==t){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<n.length-1)continue;e+=a-e+1;break}i=t}return i},x=e=>e?.replace("_","-"),v={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class b{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||v,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,n,i){return i&&!this.debug?null:(s(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new b(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new b(this.logger,e)}}var S=new b;class k{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach((e=>{this.observers[e]||(this.observers[e]=new Map);const s=this.observers[e].get(t)||0;this.observers[e].set(t,s+1)})),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach((([e,s])=>{for(let n=0;n<s;n++)e(...t)}))}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach((([s,n])=>{for(let i=0;i<n;i++)s.apply(s,[e,...t])}))}}}class O extends k{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,i={}){const o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;e.indexOf(".")>-1?r=e.split("."):(r=[e,t],n&&(Array.isArray(n)?r.push(...n):s(n)&&o?r.push(...n.split(o)):r.push(n)));const l=u(this.data,r);return!l&&!t&&!n&&e.indexOf(".")>-1&&(e=r[0],t=r[1],n=r.slice(2).join(".")),!l&&a&&s(n)?y(this.data?.[e]?.[t],n,o):l}addResource(e,t,s,n,i={silent:!1}){const o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(o?s.split(o):s)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),c(this.data,a,n),i.silent||this.emit("added",e,t,s,n)}addResources(e,t,n,i={silent:!1}){for(const i in n)(s(n[i])||Array.isArray(n[i]))&&this.addResource(e,t,i,n[i],{silent:!0});i.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,s,n,i,o={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=s,s=t,t=a[1]),this.addNamespaces(t);let r=u(this.data,a)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),n?p(r,s,i):r={...r,...s},c(this.data,a,r),o.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((e=>t[e]&&Object.keys(t[e]).length>0))}toJSON(){return this.data}}var L={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,n,i){return e.forEach((e=>{t=this.processors[e]?.process(t,s,n,i)??t})),t}};const w=Symbol("i18next/PATH_KEY");function N(e,t){const{[w]:s}=e(function(){const e=[],t=Object.create(null);let s;return t.get=(n,i)=>(s?.revoke?.(),i===w?e:(e.push(i),s=Proxy.revocable(n,t),s.proxy)),Proxy.revocable(Object.create(null),t).proxy}());return s.join(t?.keySeparator??".")}const $={},R=e=>!s(e)&&"boolean"!=typeof e&&"number"!=typeof e;class E extends k{constructor(e,t={}){super(),((e,t,s)=>{e.forEach((e=>{t[e]&&(s[e]=t[e])}))})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=S.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const n=this.resolve(e,s);return void 0!==n?.res}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");const i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator;let o=t.ns||this.options.defaultNS||[];const a=n&&e.indexOf(n)>-1,r=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const n=f.filter((e=>t.indexOf(e)<0&&s.indexOf(e)<0));if(0===n.length)return!0;const i=m.getRegExp(`(${n.map((e=>"?"===e?"\\?":e)).join("|")})`);let o=!i.test(e);if(!o){const t=e.indexOf(s);t>0&&!i.test(e.substring(0,t))&&(o=!0)}return o})(e,n,i));if(a&&!r){const t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:s(o)?[o]:o};const a=e.split(n);(n!==i||n===i&&this.options.ns.indexOf(a[0])>-1)&&(o=a.shift()),e=a.join(i)}return{key:e,namespaces:s(o)?[o]:o}}translate(e,t,n){let i="object"==typeof t?{...t}:t;if("object"!=typeof i&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof i&&(i={...i}),i||(i={}),null==e)return"";"function"==typeof e&&(e=N(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const o=void 0!==i.returnDetails?i.returnDetails:this.options.returnDetails,a=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,{key:r,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let u=void 0!==i.nsSeparator?i.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");const p=i.lng||this.language,h=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===p?.toLowerCase())return h?o?{res:`${c}${u}${r}`,usedKey:r,exactUsedKey:r,usedLng:p,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${u}${r}`:o?{res:r,usedKey:r,exactUsedKey:r,usedLng:p,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:r;const d=this.resolve(e,i);let g=d?.res;const f=d?.usedKey||r,m=d?.exactUsedKey||r,y=void 0!==i.joinArrays?i.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==i.count&&!s(i.count),b=E.hasDefaultValue(i),S=v?this.pluralResolver.getSuffix(p,i.count,i):"",k=i.ordinal&&v?this.pluralResolver.getSuffix(p,i.count,{ordinal:!1}):"",O=v&&!i.ordinal&&0===i.count,L=O&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${k}`]||i.defaultValue;let w=g;x&&!g&&b&&(w=L);const $=R(w),C=Object.prototype.toString.apply(w);if(!(x&&w&&$&&["[object Number]","[object Function]","[object RegExp]"].indexOf(C)<0)||s(y)&&Array.isArray(w))if(x&&s(y)&&Array.isArray(g))g=g.join(y),g&&(g=this.extendTranslation(g,e,i,n));else{let t=!1,s=!1;!this.isValidLookup(g)&&b&&(t=!0,g=L),this.isValidLookup(g)||(s=!0,g=r);const o=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:g,l=b&&L!==g&&this.options.updateMissing;if(s||t||l){if(this.logger.log(l?"updateKey":"missingKey",p,c,r,l?L:g),a){const e=this.resolve(r,{...i,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let s=0;s<t.length;s++)e.push(t[s]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);const s=(e,t,s)=>{const n=b&&s!==g?s:o;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,n,l,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,n,l,i),this.emit("missingKey",e,c,t,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach((e=>{const t=this.pluralResolver.getSuffixes(e,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach((t=>{s([e],r+t,i[`defaultValue${t}`]||L)}))})):s(e,r,L))}g=this.extendTranslation(g,e,i,d,n),s&&g===r&&this.options.appendNamespaceToMissingKey&&(g=`${c}${u}${r}`),(s||t)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${u}${r}`:r,t?g:void 0,i))}else{if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,w,{...i,ns:l}):`key '${r} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(i),d):e}if(a){const e=Array.isArray(w),t=e?[]:{},s=e?m:f;for(const e in w)if(Object.prototype.hasOwnProperty.call(w,e)){const n=`${s}${a}${e}`;t[e]=b&&!g?this.translate(n,{...i,defaultValue:R(L)?L[e]:void 0,joinArrays:!1,ns:l}):this.translate(n,{...i,joinArrays:!1,ns:l}),t[e]===n&&(t[e]=w[e])}g=t}}return o?(d.res=g,d.usedParams=this.getUsedParamsDetails(i),d):g}extendTranslation(e,t,n,i,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const a=s(e)&&(void 0!==n?.interpolation?.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(a){const t=e.match(this.interpolator.nestingRegexp);r=t&&t.length}let l=n.replace&&!s(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),e=this.interpolator.interpolate(e,l,n.lng||this.language||i.usedLng,n),a){const t=e.match(this.interpolator.nestingRegexp);r<(t&&t.length)&&(n.nest=!1)}!n.lng&&i&&i.res&&(n.lng=this.language||i.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,((...e)=>o?.[0]!==e[0]||n.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null)),n)),n.interpolation&&this.interpolator.reset()}const a=n.postProcess||this.options.postProcess,r=s(a)?[a]:a;return null!=e&&r?.length&&!1!==n.applyPostProcessor&&(e=L.handle(r,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,i,o,a,r;return s(e)&&(e=[e]),e.forEach((e=>{if(this.isValidLookup(n))return;const l=this.extractFromKey(e,t),c=l.key;i=c;let u=l.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const p=void 0!==t.count&&!s(t.count),h=p&&!t.ordinal&&0===t.count,d=void 0!==t.context&&(s(t.context)||"number"==typeof t.context)&&""!==t.context,g=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach((e=>{this.isValidLookup(n)||(r=e,$[`${g[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||($[`${g[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${g.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach((s=>{if(this.isValidLookup(n))return;a=s;const i=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,c,s,e,t);else{let e;p&&(e=this.pluralResolver.getSuffix(s,t.count,t));const n=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(t.ordinal&&0===e.indexOf(o)&&i.push(c+e.replace(o,this.options.pluralSeparator)),i.push(c+e),h&&i.push(c+n)),d){const s=`${c}${this.options.contextSeparator||"_"}${t.context}`;i.push(s),p&&(t.ordinal&&0===e.indexOf(o)&&i.push(s+e.replace(o,this.options.pluralSeparator)),i.push(s+e),h&&i.push(s+n))}}let r;for(;r=i.pop();)this.isValidLookup(n)||(o=r,n=this.getResource(s,e,r,t))})))}))})),{res:n,usedKey:i,exactUsedKey:o,usedLng:a,usedNS:r}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,n):this.resourceStore.getResource(e,t,s,n)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=e.replace&&!s(e.replace);let i=n?e.replace:e;if(n&&void 0!==e.count&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!n){i={...i};for(const e of t)delete i[e]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,12)&&void 0!==e[s])return!0;return!1}}class C{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=S.create("languageUtils")}getScriptPartFromCode(e){if(!(e=x(e))||e.indexOf("-")<0)return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=x(e))||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(s(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach((e=>{if(t)return;const s=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(s)||(t=s)})),!t&&this.options.supportedLngs&&e.forEach((e=>{if(t)return;const s=this.getScriptPartFromCode(e);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find((e=>e===n?e:e.indexOf("-")<0&&n.indexOf("-")<0?void 0:e.indexOf("-")>0&&n.indexOf("-")<0&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1?e:void 0))})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),s(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){const n=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),i=[],o=e=>{e&&(this.isSupportedCode(e)?i.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return s(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):s(e)&&o(this.formatLanguageCode(e)),n.forEach((e=>{i.indexOf(e)<0&&o(this.formatLanguageCode(e))})),i}}const P={zero:0,one:1,two:2,few:3,many:4,other:5},j={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class I{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=S.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=x("dev"===e?"en":e),n=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:s,type:n});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let o;try{o=new Intl.PluralRules(s,{type:n})}catch(s){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),j;if(!e.match(/-|_/))return j;const n=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(n,t)}return this.pluralRulesCache[i]=o,o}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map((e=>`${t}${e}`))}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort(((e,t)=>P[e]-P[t])).map((e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`)):[]}getSuffix(e,t,s={}){const n=this.getRule(e,s);return n?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const T=(e,t,n,i=".",o=!0)=>{let a=((e,t,s)=>{const n=u(e,s);return void 0!==n?n:u(t,s)})(e,t,n);return!a&&o&&s(n)&&(a=y(e,n,i),void 0===a&&(a=y(t,n,i))),a},V=e=>e.replace(/\$/g,"$$$$");class F{constructor(e={}){this.logger=S.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:n,prefix:i,prefixEscaped:o,suffix:a,suffixEscaped:r,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:x,alwaysFormat:v}=e.interpolation;this.escape=void 0!==t?t:g,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==n&&n,this.prefix=i?h(i):o||"{{",this.suffix=a?h(a):r||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?h(p):d||h("$t("),this.nestingSuffix=f?h(f):m||h(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=x||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,o){let a,r,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(e.indexOf(this.formatSeparator)<0){const s=T(t,c,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(s,void 0,n,{...o,...t,interpolationkey:e}):s}const s=e.split(this.formatSeparator),i=s.shift().trim(),a=s.join(this.formatSeparator).trim();return this.format(T(t,c,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,n,{...o,...t,interpolationkey:i})};this.resetRegExp();const p=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=void 0!==o?.interpolation?.skipOnVariables?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>V(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?V(this.escape(e)):V(e)}].forEach((t=>{for(l=0;a=t.regex.exec(e);){const n=a[1].trim();if(r=u(n),void 0===r)if("function"==typeof p){const t=p(e,a,o);r=s(t)?t:""}else if(o&&Object.prototype.hasOwnProperty.call(o,n))r="";else{if(h){r=a[0];continue}this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),r=""}else s(r)||this.useRawValueToEscape||(r=i(r));const c=t.safeValue(r);if(e=e.replace(a[0],c),h?(t.regex.lastIndex+=r.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,l++,l>=this.maxReplaces)break}})),e}nest(e,t,n={}){let o,a,r;const l=(e,t)=>{const s=this.nestingOptionsSeparator;if(e.indexOf(s)<0)return e;const n=e.split(new RegExp(`${s}[ ]*{`));let i=`{${n[1]}`;e=n[0],i=this.interpolate(i,r);const o=i.match(/'/g),a=i.match(/"/g);((o?.length??0)%2==0&&!a||a.length%2!=0)&&(i=i.replace(/'/g,'"'));try{r=JSON.parse(i),t&&(r={...t,...r})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${i}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let c=[];r={...n},r=r.replace&&!s(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(-1!==u&&(c=o[1].slice(u).split(this.formatSeparator).map((e=>e.trim())).filter(Boolean),o[1]=o[1].slice(0,u)),a=t(l.call(this,o[1].trim(),r),r),a&&o[0]===e&&!s(a))return a;s(a)||(a=i(a)),a||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce(((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:o[1].trim()})),a.trim())),e=e.replace(o[0],a),this.regexp.lastIndex=0}return e}}const A=e=>{const t={};return(s,n,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const a=n+JSON.stringify(o);let r=t[a];return r||(r=e(x(n),i),t[a]=r),r(s)}},D=e=>(t,s,n)=>e(x(s),n)(t);class K{constructor(e={}){this.logger=S.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?A:D;this.formats={number:s(((e,t)=>{const s=new Intl.NumberFormat(e,{...t});return e=>s.format(e)})),currency:s(((e,t)=>{const s=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>s.format(e)})),datetime:s(((e,t)=>{const s=new Intl.DateTimeFormat(e,{...t});return e=>s.format(e)})),relativetime:s(((e,t)=>{const s=new Intl.RelativeTimeFormat(e,{...t});return e=>s.format(e,t.range||"day")})),list:s(((e,t)=>{const s=new Intl.ListFormat(e,{...t});return e=>s.format(e)}))}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=A(t)}format(e,t,s,n={}){const i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find((e=>e.indexOf(")")>-1))){const e=i.findIndex((e=>e.indexOf(")")>-1));i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce(((e,t)=>{const{formatName:i,formatOptions:o}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.indexOf("(")>-1){const n=e.split("(");t=n[0].toLowerCase().trim();const i=n[1].substring(0,n[1].length-1);"currency"===t&&i.indexOf(":")<0?s.currency||(s.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?s.range||(s.range=i.trim()):i.split(";").forEach((e=>{if(e){const[t,...n]=e.split(":"),i=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();s[o]||(s[o]=i),"false"===i&&(s[o]=!1),"true"===i&&(s[o]=!0),isNaN(i)||(s[o]=parseInt(i,10))}}))}return{formatName:t,formatOptions:s}})(t);if(this.formats[i]){let t=e;try{const a=n?.formatParams?.[n.interpolationkey]||{},r=a.locale||a.lng||n.locale||n.lng||s;t=this.formats[i](e,r,{...o,...n,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e}),e)}}class U extends k{constructor(e,t,s,n={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=n,this.logger=S.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,n.backend,n)}queueLoad(e,t,s,n){const i={},o={},a={},r={};return e.forEach((e=>{let n=!0;t.forEach((t=>{const a=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===o[a]&&(o[a]=!0):(this.state[a]=1,n=!1,void 0===o[a]&&(o[a]=!0),void 0===i[a]&&(i[a]=!0),void 0===r[t]&&(r[t]=!0)))})),n||(a[e]=!0)})),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(r)}}loaded(e,t,s){const n=e.split("|"),i=n[0],o=n[1];t&&this.emit("failedLoading",i,o,t),!t&&s&&this.store.addResourceBundle(i,o,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach((s=>{((e,t,s,n)=>{const{obj:i,k:o}=l(e,t,Object);i[o]=i[o]||[],i[o].push(s)})(s.loaded,[i],o),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((e=>{a[e]||(a[e]={});const t=s.loaded[e];t.length&&t.forEach((t=>{void 0===a[e][t]&&(a[e][t]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((e=>!e.done))}read(e,t,s,n=0,i=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:n,wait:i,callback:o});this.readingCalls++;const a=(a,r)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&r&&n<this.maxRetries?setTimeout((()=>{this.read.call(this,e,t,s,n+1,2*i,o)}),i):o(a,r)},r=this.backend[s].bind(this.backend);if(2!==r.length)return r(e,t,a);try{const s=r(e,t);s&&"function"==typeof s.then?s.then((e=>a(null,e))).catch(a):a(null,s)}catch(e){a(e)}}prepareLoading(e,t,n={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();s(e)&&(e=this.languageUtils.toResolveHierarchy(e)),s(t)&&(t=[t]);const o=this.queueLoad(e,t,n,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach((e=>{this.loadOne(e)}))}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}loadOne(e,t=""){const s=e.split("|"),n=s[0],i=s[1];this.read(n,i,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${t}loading namespace ${i} for language ${n} failed`,s),!s&&o&&this.logger.log(`${t}loaded namespace ${i} for language ${n}`,o),this.loaded(e,s,o)}))}saveMissing(e,t,s,n,i,o={},a=(()=>{})){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(t)){if(null!=s&&""!==s){if(this.backend?.create){const r={...o,isUpdate:i},l=this.backend.create.bind(this.backend);if(l.length<6)try{let i;i=5===l.length?l(e,t,s,n,r):l(e,t,s,n),i&&"function"==typeof i.then?i.then((e=>a(null,e))).catch(a):a(null,i)}catch(e){a(e)}else l(e,t,s,n,a,r)}e&&e[0]&&this.store.addResource(e[0],t,s,n)}}else this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const M=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),s(e[1])&&(t.defaultValue=e[1]),s(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){const s=e[3]||e[2];Object.keys(s).forEach((e=>{t[e]=s[e]}))}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),z=e=>(s(e.ns)&&(e.ns=[e.ns]),s(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),s(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),B=()=>{};class H extends k{constructor(e={},t){var s;if(super(),this.options=z(e),this.services={},this.logger=S,this.modules={external:[]},s=this,Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach((e=>{"function"==typeof s[e]&&(s[e]=s[e].bind(s))})),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout((()=>{this.init(e,t)}),0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(s(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const i=M();this.options={...i,...this.options,...z(e)},this.options.interpolation={...i.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);const o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?S.init(o(this.modules.logger),this.options):S.init(null,this.options),e=this.modules.formatter?this.modules.formatter:K;const t=new C(this.options);this.store=new O(this.options.resources,this.options);const s=this.services;s.logger=S,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new I(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix});this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!e||this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format||(s.formatter=o(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new F(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new U(o(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",((e,...t)=>{this.emit(e,...t)})),this.modules.languageDetector&&(s.languageDetector=o(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=o(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new E(this.services,this.options),this.translator.on("*",((e,...t)=>{this.emit(e,...t)})),this.modules.external.forEach((e=>{e.init&&e.init(this)}))}if(this.format=this.options.interpolation.format,t||(t=B),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((e=>{this[e]=(...t)=>this.store[e](...t)}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=(...t)=>(this.store[e](...t),this)}));const a=n(),r=()=>{const e=(e,s)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(s),t(e,s)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?r():setTimeout(r,0),a}loadResources(e,t=B){let n=t;const i=s(e)?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===i?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return n();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach((t=>{"cimode"!==t&&e.indexOf(t)<0&&e.push(t)}))};if(i)t(i);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e=>t(e)))}this.options.preload?.forEach?.((e=>t(e))),this.services.backendConnector.load(e,this.options.ns,(e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),n(e)}))}else n(null)}reloadResources(e,t,s){const i=n();return"function"==typeof e&&(s=e,e=void 0),"function"==typeof t&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=B),this.services.backendConnector.reload(e,t,(e=>{i.resolve(),s(e)})),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&L.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=n();this.emit("languageChanging",e);const o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(s,n)=>{n?this.isLanguageChangingTo===e&&(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve(((...e)=>this.t(...e))),t&&t(s,((...e)=>this.t(...e)))},r=t=>{e||t||!this.services.languageDetector||(t=[]);const n=s(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(s(t)?[t]:t);i&&(this.language||o(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,(e=>{a(e,i)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),i}getFixedT(e,t,n){const i=(e,t,...s)=>{let o;o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},o.lng=o.lng||i.lng,o.lngs=o.lngs||i.lngs,o.ns=o.ns||i.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||n||i.keyPrefix);const a=this.options.keySeparator||".";let r;return o.keyPrefix&&Array.isArray(e)?r=e.map((e=>("function"==typeof e&&(e=N(e,{...this.options,...t})),`${o.keyPrefix}${a}${e}`))):("function"==typeof e&&(e=N(e,{...this.options,...t})),r=o.keyPrefix?`${o.keyPrefix}${a}${e}`:e),this.t(r,o)};return s(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(e,t)=>{const s=this.services.backendConnector.state[`${e}|${t}`];return-1===s||0===s||2===s};if(t.precheck){const e=t.precheck(this,o);if(void 0!==e)return e}return!!this.hasResourceBundle(s,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,e)||n&&!o(i,e)))}loadNamespaces(e,t){const i=n();return this.options.ns?(s(e)&&(e=[e]),e.forEach((e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)})),this.loadResources((e=>{i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=n();s(e)&&(e=[e]);const o=this.options.preload||[],a=e.filter((e=>o.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e)));return a.length?(this.options.preload=o.concat(a),this.loadResources((e=>{i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}const t=this.services?.languageUtils||new C(M());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new H(e,t)}cloneInstance(e={},t=B){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const n={...this.options,...e,isClone:!0},i=new H(n);void 0===e.debug&&void 0===e.prefix||(i.logger=i.logger.clone(e));if(["store","services","language"].forEach((e=>{i[e]=this[e]})),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},s){const e=Object.keys(this.store.data).reduce(((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce(((s,n)=>(s[n]={...e[t][n]},s)),e[t]),e)),{});i.store=new O(e,n),i.services.resourceStore=i.store}return i.translator=new E(i.services,n),i.translator.on("*",((e,...t)=>{i.emit(e,...t)})),i.init(n,t),i.translator.options=n,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _=H.createInstance();function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}_.createInstance=H.createInstance,_.createInstance,_.dir,_.init,_.loadResources,_.reloadResources,_.use,_.changeLanguage,_.getFixedT,_.t,_.exists,_.setDefaultNamespace,_.hasLoadedNamespace,_.loadNamespaces,_.loadLanguages;var q=J({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}),W=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function Y(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},s=e.match(/<\/?([^\s]+?)[/\s>]/);if(s&&(t.name=s[1],(q[s[1]]||"/"===e.charAt(e.length-2))&&(t.voidElement=!0),t.name.startsWith("!--"))){var n=e.indexOf("--\x3e");return{type:"comment",comment:-1!==n?e.slice(4,n):""}}for(var i=new RegExp(W),o=null;null!==(o=i.exec(e));)if(o[0].trim())if(o[1]){var a=o[1].trim(),r=[a,""];a.indexOf("=")>-1&&(r=a.split("=")),t.attrs[r[0]]=r[1],i.lastIndex--}else o[2]&&(t.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return t}var G=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Q=/^\s*$/,X=Object.create(null);var Z=function(e,t){t||(t={}),t.components||(t.components=X);var s,n=[],i=[],o=-1,a=!1;if(0!==e.indexOf("<")){var r=e.indexOf("<");n.push({type:"text",content:-1===r?e:e.substring(0,r)})}return e.replace(G,(function(r,l){if(a){if(r!=="</"+s.name+">")return;a=!1}var c,u="/"!==r.charAt(1),p=r.startsWith("\x3c!--"),h=l+r.length,d=e.charAt(h);if(p){var g=Y(r);return o<0?(n.push(g),n):((c=i[o]).children.push(g),n)}if(u&&(o++,"tag"===(s=Y(r)).type&&t.components[s.name]&&(s.type="component",a=!0),s.voidElement||a||!d||"<"===d||s.children.push({type:"text",content:e.slice(h,e.indexOf("<",h))}),0===o&&n.push(s),(c=i[o-1])&&c.children.push(s),i[o]=s),(!u||s.voidElement)&&(o>-1&&(s.voidElement||s.name===r.slice(2,-1))&&(o--,s=-1===o?n:i[o]),!a&&"<"!==d&&d)){c=-1===o?n:i[o].children;var f=e.indexOf("<",h),m=e.slice(h,-1===f?void 0:f);Q.test(m)&&(m=" "),(f>-1&&o+c.length>=0||" "!==m)&&c.push({type:"text",content:m})}})),n};const ee=(e,t,s,n)=>{const i=[s,{code:t,...n||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,"warn","react-i18next::",!0);re(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},te={},se=(e,t,s,n)=>{re(s)&&te[s]||(re(s)&&(te[s]=new Date),ee(e,t,s,n))},ne=(e,t)=>()=>{if(e.isInitialized)t();else{const s=()=>{setTimeout((()=>{e.off("initialized",s)}),0),t()};e.on("initialized",s)}},ie=(e,t,s)=>{e.loadNamespaces(t,ne(e,s))},oe=(e,t,s,n)=>{if(re(s)&&(s=[s]),e.options.preload&&e.options.preload.indexOf(t)>-1)return ie(e,s,n);s.forEach((t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)})),e.loadLanguages(t,ne(e,n))},ae=e=>e.displayName||e.name||(re(e)&&e.length>0?e:"Unknown"),re=e=>"string"==typeof e,le=e=>"object"==typeof e&&null!==e,ce=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ue={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},pe=e=>ue[e];let he={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(ce,pe)};const de=(e={})=>{he={...he,...e}},ge=()=>he;let fe;const me=e=>{fe=e},ye=()=>fe,xe=(e,t)=>{if(!e)return!1;const s=e.props?.children??e.children;return t?s.length>0:!!s},ve=e=>{if(!e)return[];const t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?be(t):t},be=e=>Array.isArray(e)?e:[e],Se=(e,s,n,i)=>{if(!e)return"";let o="";const a=be(e),r=s?.transSupportBasicHtmlNodes?s.transKeepBasicHtmlNodesFor??[]:[];return a.forEach(((e,a)=>{if(re(e))o+=`${e}`;else if(t.isValidElement(e)){const{props:t,type:l}=e,c=Object.keys(t).length,u=r.indexOf(l)>-1,p=t.children;if(!p&&u&&!c)return void(o+=`<${l}/>`);if(!p&&(!u||c)||t.i18nIsDynamicList)return void(o+=`<${a}></${a}>`);if(u&&1===c&&re(p))return void(o+=`<${l}>${p}</${l}>`);const h=Se(p,s,n,i);o+=`<${a}>${h}</${a}>`}else if(null!==e)if(le(e)){const{format:t,...s}=e,a=Object.keys(s);if(1===a.length){const e=t?`${a[0]}, ${t}`:a[0];return void(o+=`{{${e}}}`)}ee(n,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:i,child:e})}else ee(n,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:i,child:e});else ee(n,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:i})})),o},ke=(e,s,n,i,o,a,r)=>{if(""===n)return[];const l=o.transKeepBasicHtmlNodesFor||[],c=n&&new RegExp(l.map((e=>`<${e}`)).join("|")).test(n);if(!(e||s||c||r))return[n];const u=s??{},p=e=>{be(e).forEach((e=>{re(e)||(xe(e)?p(ve(e)):le(e)&&!t.isValidElement(e)&&Object.assign(u,e))}))};p(e);const h=Z(`<0>${n}</0>`),d={...u,...a},g=(e,s,n)=>{const i=ve(e),o=m(i,s.children,n);return(e=>Array.isArray(e)&&e.every(t.isValidElement))(i)&&0===o.length||e.props?.i18nIsDynamicList?i:o},f=(e,s,n,i,o)=>{e.dummy?(e.children=s,n.push(t.cloneElement(e,{key:i},o?void 0:s))):n.push(...t.Children.map([e],(e=>{const n={...e.props};return delete n.i18nIsDynamicList,t.createElement(e.type,{...n,key:i,ref:e.props.ref??e.ref},o?null:s)})))},m=(e,n,a)=>{const u=be(e);return be(n).reduce(((e,n,p)=>{const h=n.children?.[0]?.content&&i.services.interpolator.interpolate(n.children[0].content,d,i.language);if("tag"===n.type){let r=u[parseInt(n.name,10)];!r&&s&&(r=s[n.name]),1!==a.length||r||(r=a[0][n.name]),r||(r={});const y=0!==Object.keys(n.attrs).length?((e,t)=>{const s={...t};return s.props=Object.assign(e.props,t.props),s})({props:n.attrs},r):r,x=t.isValidElement(y),v=x&&xe(n,!0)&&!n.voidElement,b=c&&le(y)&&y.dummy&&!x,S=le(s)&&Object.hasOwnProperty.call(s,n.name);if(re(y)){const t=i.services.interpolator.interpolate(y,d,i.language);e.push(t)}else if(xe(y)||v){const t=g(y,n,a);f(y,t,e,p)}else if(b){const t=m(u,n.children,a);f(y,t,e,p)}else if(Number.isNaN(parseFloat(n.name)))if(S){const t=g(y,n,a);f(y,t,e,p,n.voidElement)}else if(o.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push(t.createElement(n.name,{key:`${n.name}-${p}`}));else{const s=m(u,n.children,a);e.push(t.createElement(n.name,{key:`${n.name}-${p}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{const t=m(u,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(le(y)&&!x){const t=n.children[0]?h:null;t&&e.push(t)}else f(y,h,e,p,1!==n.children.length||!h)}else if("text"===n.type){const s=o.transWrapTextNodes,a=r?o.unescape(i.services.interpolator.interpolate(n.content,d,i.language)):i.services.interpolator.interpolate(n.content,d,i.language);s?e.push(t.createElement(s,{key:`${n.name}-${p}`},a)):e.push(a)}return e}),[])},y=m([{dummy:!0,children:e||[]}],h,be(e||[]));return ve(y[0])},Oe=(e,s,n)=>{const i=e.key||s,o=t.cloneElement(e,{key:i});if(!o.props||!o.props.children||n.indexOf(`${s}/>`)<0&&n.indexOf(`${s} />`)<0)return o;return t.createElement((function(){return t.createElement(t.Fragment,null,o)}),{key:i})},Le=(e,t,s,n)=>e?Array.isArray(e)?((e,t)=>e.map(((e,s)=>Oe(e,s,t))))(e,t):le(e)?((e,t)=>{const s={};return Object.keys(e).forEach((n=>{Object.assign(s,{[n]:Oe(e[n],n,t)})})),s})(e,t):(se(s,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:n}),null):null,we=e=>!!le(e)&&(!Array.isArray(e)&&Object.keys(e).reduce(((e,t)=>e&&Number.isNaN(Number.parseFloat(t))),!0));function Ne({children:e,count:s,parent:n,i18nKey:i,context:o,tOptions:a={},values:r,defaults:l,components:c,ns:u,i18n:p,t:h,shouldUnescape:d,...g}){const f=p||ye();if(!f)return se(f,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:i}),e;const m=h||f.t.bind(f)||(e=>e),y={...ge(),...f.options?.react};let x=u||m.ns||f.options?.defaultNS;x=re(x)?[x]:x||["translation"];const v=Se(e,y,f,i),b=l||v||y.transEmptyNodeValue||("function"==typeof i?N(i):i),{hashTransKey:S}=y,k=i||(S?S(v||b):v||b);f.options?.interpolation?.defaultVariables&&(r=r&&Object.keys(r).length>0?{...r,...f.options.interpolation.defaultVariables}:{...f.options.interpolation.defaultVariables});const O=r||void 0!==s&&!f.options?.interpolation?.alwaysFormat||!e?a.interpolation:{interpolation:{...a.interpolation,prefix:"#$?",suffix:"?$#"}},L={...a,context:o||a.context,count:s,...r,...O,defaultValue:b,ns:x},w=k?m(k,L):b,$=Le(c,w,f,i);let R=$||e,E=null;we($)&&(E=$,R=e);const C=ke(R,E,w,f,y,L,d),P=n??y.defaultTransParent;return P?t.createElement(P,g,C):C}const $e={type:"3rdParty",init(e){de(e.options.react),me(e)}},Re=t.createContext();class Ee{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const Ce=e=>async t=>({...await(e.getInitialProps?.(t))??{},...Pe()}),Pe=()=>{const e=ye(),t=e.reportNamespaces?.getUsedNamespaces()??[],s={},n={};return e.languages.forEach((s=>{n[s]={},t.forEach((t=>{n[s][t]=e.getResourceBundle(s,t)||{}}))})),s.initialI18nStore=n,s.initialLanguage=e.language,s};const je=(e,t,s,n)=>e.getFixedT(t,s,n),Ie=(e,s={})=>{const{i18n:n}=s,{i18n:i,defaultNS:o}=t.useContext(Re)||{},a=n||i||ye();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new Ee),!a){se(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const e=(e,t)=>re(t)?t:le(t)&&re(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e,t=[e,{},!1];return t.t=e,t.i18n={},t.ready=!1,t}a.options.react?.wait&&se(a,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const r={...ge(),...a.options.react,...s},{useSuspense:l,keyPrefix:c}=r;let u=e||o||a.options?.defaultNS;u=re(u)?[u]:u||["translation"],a.reportNamespaces.addUsedNamespaces?.(u);const p=(a.isInitialized||a.initializedStoreOnce)&&u.every((e=>((e,t,s={})=>t.languages&&t.languages.length?t.hasLoadedNamespace(e,{lng:s.lng,precheck:(t,n)=>{if(s.bindI18n&&s.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!n(t.isLanguageChangingTo,e))return!1}}):(se(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0))(e,a,r))),h=((e,s,n,i)=>t.useCallback(je(e,s,n,i),[e,s,n,i]))(a,s.lng||null,"fallback"===r.nsMode?u:u[0],c),d=()=>h,g=()=>je(a,s.lng||null,"fallback"===r.nsMode?u:u[0],c),[f,m]=t.useState(d);let y=u.join();s.lng&&(y=`${s.lng}${y}`);const x=((e,s)=>{const n=t.useRef();return t.useEffect((()=>{n.current=e}),[e,s]),n.current})(y),v=t.useRef(!0);t.useEffect((()=>{const{bindI18n:e,bindI18nStore:t}=r;v.current=!0,p||l||(s.lng?oe(a,s.lng,u,(()=>{v.current&&m(g)})):ie(a,u,(()=>{v.current&&m(g)}))),p&&x&&x!==y&&v.current&&m(g);const n=()=>{v.current&&m(g)};return e&&a?.on(e,n),t&&a?.store.on(t,n),()=>{v.current=!1,a&&e&&e?.split(" ").forEach((e=>a.off(e,n))),t&&a&&t.split(" ").forEach((e=>a.store.off(e,n)))}}),[a,y]),t.useEffect((()=>{v.current&&p&&m(d)}),[a,c,p]);const b=[f,a,p];if(b.t=f,b.i18n=a,b.ready=p,p)return b;if(!p&&!l)return b;throw new Promise((e=>{s.lng?oe(a,s.lng,u,(()=>e())):ie(a,u,(()=>e()))}))};const Te=(e,s,n={})=>{const{i18n:i}=n,{i18n:o}=t.useContext(Re)||{},a=i||o||ye();a.options?.isClone||(e&&!a.initializedStoreOnce&&(a.services.resourceStore.data=e,a.options.ns=Object.values(e).reduce(((e,t)=>(Object.keys(t).forEach((t=>{e.indexOf(t)<0&&e.push(t)})),e)),a.options.ns),a.initializedStoreOnce=!0,a.isInitialized=!0),s&&!a.initializedLanguageOnce&&(a.changeLanguage(s),a.initializedLanguageOnce=!0))};e.I18nContext=Re,e.I18nextProvider=function({i18n:e,defaultNS:s,children:n}){const i=t.useMemo((()=>({i18n:e,defaultNS:s})),[e,s]);return t.createElement(Re.Provider,{value:i},n)},e.Trans=function({children:e,count:s,parent:n,i18nKey:i,context:o,tOptions:a={},values:r,defaults:l,components:c,ns:u,i18n:p,t:h,shouldUnescape:d,...g}){const{i18n:f,defaultNS:m}=t.useContext(Re)||{},y=p||f||ye(),x=h||y?.t.bind(y);return Ne({children:e,count:s,parent:n,i18nKey:i,context:o,tOptions:a,values:r,defaults:l,components:c,ns:u||x?.ns||m||y?.options?.defaultNS,i18n:y,t:h,shouldUnescape:d,...g})},e.TransWithoutContext=Ne,e.Translation=({ns:e,children:t,...s})=>{const[n,i,o]=Ie(e,s);return t(n,{i18n:i,lng:i.language},o)},e.composeInitialProps=Ce,e.date=()=>"",e.getDefaults=ge,e.getI18n=ye,e.getInitialProps=Pe,e.initReactI18next=$e,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=de,e.setI18n=me,e.time=()=>"",e.useSSR=Te,e.useTranslation=Ie,e.withSSR=()=>function(e){function s({initialI18nStore:s,initialLanguage:n,...i}){return Te(s,n),t.createElement(e,{...i})}return s.getInitialProps=Ce(e),s.displayName=`withI18nextSSR(${ae(e)})`,s.WrappedComponent=e,s},e.withTranslation=(e,s={})=>function(n){function i({forwardedRef:i,...o}){const[a,r,l]=Ie(e,{...o,keyPrefix:s.keyPrefix}),c={...o,t:a,i18n:r,tReady:l};return s.withRef&&i?c.ref=i:!s.withRef&&i&&(c.forwardedRef=i),t.createElement(n,c)}i.displayName=`withI18nextTranslation(${ae(n)})`,i.WrappedComponent=n;return s.withRef?t.forwardRef(((e,s)=>t.createElement(i,Object.assign({},e,{forwardedRef:s})))):i}}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IcuTrans = IcuTrans;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _IcuTransWithoutContext = require("./IcuTransWithoutContext.js");
|
|
9
|
+
var _context = require("./context.js");
|
|
10
|
+
function IcuTrans({
|
|
11
|
+
i18nKey,
|
|
12
|
+
defaultTranslation,
|
|
13
|
+
content,
|
|
14
|
+
ns,
|
|
15
|
+
values = {},
|
|
16
|
+
i18n: i18nFromProps,
|
|
17
|
+
t: tFromProps
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
i18n: i18nFromContext,
|
|
21
|
+
defaultNS: defaultNSFromContext
|
|
22
|
+
} = (0, _react.useContext)(_context.I18nContext) || {};
|
|
23
|
+
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
|
|
24
|
+
const t = tFromProps || i18n?.t.bind(i18n);
|
|
25
|
+
return (0, _IcuTransWithoutContext.IcuTransWithoutContext)({
|
|
26
|
+
i18nKey,
|
|
27
|
+
defaultTranslation,
|
|
28
|
+
content,
|
|
29
|
+
ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
|
|
30
|
+
values,
|
|
31
|
+
i18n,
|
|
32
|
+
t: tFromProps
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
IcuTrans.displayName = 'IcuTrans';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TranslationParserError = void 0;
|
|
7
|
+
class TranslationParserError extends Error {
|
|
8
|
+
constructor(message, position, translationString) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'TranslationParserError';
|
|
11
|
+
this.position = position;
|
|
12
|
+
this.translationString = translationString;
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, TranslationParserError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.TranslationParserError = TranslationParserError;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeHtmlEntities = void 0;
|
|
7
|
+
const commonEntities = {
|
|
8
|
+
' ': '\u00A0',
|
|
9
|
+
'&': '&',
|
|
10
|
+
'<': '<',
|
|
11
|
+
'>': '>',
|
|
12
|
+
'"': '"',
|
|
13
|
+
''': "'",
|
|
14
|
+
'©': '©',
|
|
15
|
+
'®': '®',
|
|
16
|
+
'™': '™',
|
|
17
|
+
'…': '…',
|
|
18
|
+
'–': '–',
|
|
19
|
+
'—': '—',
|
|
20
|
+
'‘': '\u2018',
|
|
21
|
+
'’': '\u2019',
|
|
22
|
+
'‚': '\u201A',
|
|
23
|
+
'“': '\u201C',
|
|
24
|
+
'”': '\u201D',
|
|
25
|
+
'„': '\u201E',
|
|
26
|
+
'†': '†',
|
|
27
|
+
'‡': '‡',
|
|
28
|
+
'•': '•',
|
|
29
|
+
'′': '′',
|
|
30
|
+
'″': '″',
|
|
31
|
+
'‹': '‹',
|
|
32
|
+
'›': '›',
|
|
33
|
+
'§': '§',
|
|
34
|
+
'¶': '¶',
|
|
35
|
+
'·': '·',
|
|
36
|
+
' ': '\u2002',
|
|
37
|
+
' ': '\u2003',
|
|
38
|
+
' ': '\u2009',
|
|
39
|
+
'€': '€',
|
|
40
|
+
'£': '£',
|
|
41
|
+
'¥': '¥',
|
|
42
|
+
'¢': '¢',
|
|
43
|
+
'¤': '¤',
|
|
44
|
+
'×': '×',
|
|
45
|
+
'÷': '÷',
|
|
46
|
+
'−': '−',
|
|
47
|
+
'±': '±',
|
|
48
|
+
'≠': '≠',
|
|
49
|
+
'≤': '≤',
|
|
50
|
+
'≥': '≥',
|
|
51
|
+
'≈': '≈',
|
|
52
|
+
'≡': '≡',
|
|
53
|
+
'∞': '∞',
|
|
54
|
+
'∫': '∫',
|
|
55
|
+
'∑': '∑',
|
|
56
|
+
'∏': '∏',
|
|
57
|
+
'√': '√',
|
|
58
|
+
'∂': '∂',
|
|
59
|
+
'‰': '‰',
|
|
60
|
+
'°': '°',
|
|
61
|
+
'µ': 'µ',
|
|
62
|
+
'←': '←',
|
|
63
|
+
'↑': '↑',
|
|
64
|
+
'→': '→',
|
|
65
|
+
'↓': '↓',
|
|
66
|
+
'↔': '↔',
|
|
67
|
+
'↵': '↵',
|
|
68
|
+
'⇐': '⇐',
|
|
69
|
+
'⇑': '⇑',
|
|
70
|
+
'⇒': '⇒',
|
|
71
|
+
'⇓': '⇓',
|
|
72
|
+
'⇔': '⇔',
|
|
73
|
+
'α': 'α',
|
|
74
|
+
'β': 'β',
|
|
75
|
+
'γ': 'γ',
|
|
76
|
+
'δ': 'δ',
|
|
77
|
+
'ε': 'ε',
|
|
78
|
+
'ζ': 'ζ',
|
|
79
|
+
'η': 'η',
|
|
80
|
+
'θ': 'θ',
|
|
81
|
+
'ι': 'ι',
|
|
82
|
+
'κ': 'κ',
|
|
83
|
+
'λ': 'λ',
|
|
84
|
+
'μ': 'μ',
|
|
85
|
+
'ν': 'ν',
|
|
86
|
+
'ξ': 'ξ',
|
|
87
|
+
'ο': 'ο',
|
|
88
|
+
'π': 'π',
|
|
89
|
+
'ρ': 'ρ',
|
|
90
|
+
'σ': 'σ',
|
|
91
|
+
'τ': 'τ',
|
|
92
|
+
'υ': 'υ',
|
|
93
|
+
'φ': 'φ',
|
|
94
|
+
'χ': 'χ',
|
|
95
|
+
'ψ': 'ψ',
|
|
96
|
+
'ω': 'ω',
|
|
97
|
+
'Α': 'Α',
|
|
98
|
+
'Β': 'Β',
|
|
99
|
+
'Γ': 'Γ',
|
|
100
|
+
'Δ': 'Δ',
|
|
101
|
+
'Ε': 'Ε',
|
|
102
|
+
'Ζ': 'Ζ',
|
|
103
|
+
'Η': 'Η',
|
|
104
|
+
'Θ': 'Θ',
|
|
105
|
+
'Ι': 'Ι',
|
|
106
|
+
'Κ': 'Κ',
|
|
107
|
+
'Λ': 'Λ',
|
|
108
|
+
'Μ': 'Μ',
|
|
109
|
+
'Ν': 'Ν',
|
|
110
|
+
'Ξ': 'Ξ',
|
|
111
|
+
'Ο': 'Ο',
|
|
112
|
+
'Π': 'Π',
|
|
113
|
+
'Ρ': 'Ρ',
|
|
114
|
+
'Σ': 'Σ',
|
|
115
|
+
'Τ': 'Τ',
|
|
116
|
+
'Υ': 'Υ',
|
|
117
|
+
'Φ': 'Φ',
|
|
118
|
+
'Χ': 'Χ',
|
|
119
|
+
'Ψ': 'Ψ',
|
|
120
|
+
'Ω': 'Ω',
|
|
121
|
+
'À': 'À',
|
|
122
|
+
'Á': 'Á',
|
|
123
|
+
'Â': 'Â',
|
|
124
|
+
'Ã': 'Ã',
|
|
125
|
+
'Ä': 'Ä',
|
|
126
|
+
'Å': 'Å',
|
|
127
|
+
'Æ': 'Æ',
|
|
128
|
+
'Ç': 'Ç',
|
|
129
|
+
'È': 'È',
|
|
130
|
+
'É': 'É',
|
|
131
|
+
'Ê': 'Ê',
|
|
132
|
+
'Ë': 'Ë',
|
|
133
|
+
'Ì': 'Ì',
|
|
134
|
+
'Í': 'Í',
|
|
135
|
+
'Î': 'Î',
|
|
136
|
+
'Ï': 'Ï',
|
|
137
|
+
'Ð': 'Ð',
|
|
138
|
+
'Ñ': 'Ñ',
|
|
139
|
+
'Ò': 'Ò',
|
|
140
|
+
'Ó': 'Ó',
|
|
141
|
+
'Ô': 'Ô',
|
|
142
|
+
'Õ': 'Õ',
|
|
143
|
+
'Ö': 'Ö',
|
|
144
|
+
'Ø': 'Ø',
|
|
145
|
+
'Ù': 'Ù',
|
|
146
|
+
'Ú': 'Ú',
|
|
147
|
+
'Û': 'Û',
|
|
148
|
+
'Ü': 'Ü',
|
|
149
|
+
'Ý': 'Ý',
|
|
150
|
+
'Þ': 'Þ',
|
|
151
|
+
'ß': 'ß',
|
|
152
|
+
'à': 'à',
|
|
153
|
+
'á': 'á',
|
|
154
|
+
'â': 'â',
|
|
155
|
+
'ã': 'ã',
|
|
156
|
+
'ä': 'ä',
|
|
157
|
+
'å': 'å',
|
|
158
|
+
'æ': 'æ',
|
|
159
|
+
'ç': 'ç',
|
|
160
|
+
'è': 'è',
|
|
161
|
+
'é': 'é',
|
|
162
|
+
'ê': 'ê',
|
|
163
|
+
'ë': 'ë',
|
|
164
|
+
'ì': 'ì',
|
|
165
|
+
'í': 'í',
|
|
166
|
+
'î': 'î',
|
|
167
|
+
'ï': 'ï',
|
|
168
|
+
'ð': 'ð',
|
|
169
|
+
'ñ': 'ñ',
|
|
170
|
+
'ò': 'ò',
|
|
171
|
+
'ó': 'ó',
|
|
172
|
+
'ô': 'ô',
|
|
173
|
+
'õ': 'õ',
|
|
174
|
+
'ö': 'ö',
|
|
175
|
+
'ø': 'ø',
|
|
176
|
+
'ù': 'ù',
|
|
177
|
+
'ú': 'ú',
|
|
178
|
+
'û': 'û',
|
|
179
|
+
'ü': 'ü',
|
|
180
|
+
'ý': 'ý',
|
|
181
|
+
'þ': 'þ',
|
|
182
|
+
'ÿ': 'ÿ',
|
|
183
|
+
'¡': '¡',
|
|
184
|
+
'¿': '¿',
|
|
185
|
+
'ƒ': 'ƒ',
|
|
186
|
+
'ˆ': 'ˆ',
|
|
187
|
+
'˜': '˜',
|
|
188
|
+
'Œ': 'Œ',
|
|
189
|
+
'œ': 'œ',
|
|
190
|
+
'Š': 'Š',
|
|
191
|
+
'š': 'š',
|
|
192
|
+
'Ÿ': 'Ÿ',
|
|
193
|
+
'ª': 'ª',
|
|
194
|
+
'º': 'º',
|
|
195
|
+
'¯': '¯',
|
|
196
|
+
'´': '´',
|
|
197
|
+
'¸': '¸',
|
|
198
|
+
'¹': '¹',
|
|
199
|
+
'²': '²',
|
|
200
|
+
'³': '³',
|
|
201
|
+
'¼': '¼',
|
|
202
|
+
'½': '½',
|
|
203
|
+
'¾': '¾',
|
|
204
|
+
'♠': '♠',
|
|
205
|
+
'♣': '♣',
|
|
206
|
+
'♥': '♥',
|
|
207
|
+
'♦': '♦',
|
|
208
|
+
'◊': '◊',
|
|
209
|
+
'‾': '‾',
|
|
210
|
+
'⁄': '⁄',
|
|
211
|
+
'℘': '℘',
|
|
212
|
+
'ℑ': 'ℑ',
|
|
213
|
+
'ℜ': 'ℜ',
|
|
214
|
+
'ℵ': 'ℵ'
|
|
215
|
+
};
|
|
216
|
+
const entityPattern = new RegExp(Object.keys(commonEntities).map(entity => entity.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), 'g');
|
|
217
|
+
const decodeHtmlEntities = text => text.replace(entityPattern, match => commonEntities[match]).replace(/&#(\d+);/g, (_, num) => String.fromCharCode(parseInt(num, 10))).replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
218
|
+
exports.decodeHtmlEntities = decodeHtmlEntities;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _TranslationParserError = require("./TranslationParserError");
|
|
7
|
+
Object.keys(_TranslationParserError).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _TranslationParserError[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _TranslationParserError[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _htmlEntityDecoder = require("./htmlEntityDecoder");
|
|
18
|
+
Object.keys(_htmlEntityDecoder).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _htmlEntityDecoder[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _htmlEntityDecoder[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _tokenizer = require("./tokenizer");
|
|
29
|
+
Object.keys(_tokenizer).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _tokenizer[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _tokenizer[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _renderTranslation = require("./renderTranslation");
|
|
40
|
+
Object.keys(_renderTranslation).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _renderTranslation[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _renderTranslation[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.renderTranslation = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _TranslationParserError = require("./TranslationParserError");
|
|
10
|
+
var _tokenizer = require("./tokenizer");
|
|
11
|
+
var _htmlEntityDecoder = require("./htmlEntityDecoder");
|
|
12
|
+
const renderDeclarationNode = (declaration, children, childDeclarations) => {
|
|
13
|
+
const {
|
|
14
|
+
type,
|
|
15
|
+
props = {}
|
|
16
|
+
} = declaration;
|
|
17
|
+
if (props.children && Array.isArray(props.children) && childDeclarations) {
|
|
18
|
+
const {
|
|
19
|
+
children: _childrenToRemove,
|
|
20
|
+
...propsWithoutChildren
|
|
21
|
+
} = props;
|
|
22
|
+
return _react.default.createElement(type, propsWithoutChildren, ...children);
|
|
23
|
+
}
|
|
24
|
+
if (children.length === 0) {
|
|
25
|
+
return _react.default.createElement(type, props);
|
|
26
|
+
}
|
|
27
|
+
if (children.length === 1) {
|
|
28
|
+
return _react.default.createElement(type, props, children[0]);
|
|
29
|
+
}
|
|
30
|
+
return _react.default.createElement(type, props, ...children);
|
|
31
|
+
};
|
|
32
|
+
const renderTranslation = (translation, declarations = []) => {
|
|
33
|
+
if (!translation) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const tokens = (0, _tokenizer.tokenize)(translation);
|
|
37
|
+
const result = [];
|
|
38
|
+
const stack = [];
|
|
39
|
+
const literalTagNumbers = new Set();
|
|
40
|
+
const getCurrentDeclarations = () => {
|
|
41
|
+
if (stack.length === 0) {
|
|
42
|
+
return declarations;
|
|
43
|
+
}
|
|
44
|
+
const parentFrame = stack[stack.length - 1];
|
|
45
|
+
if (parentFrame.declaration.props?.children && Array.isArray(parentFrame.declaration.props.children)) {
|
|
46
|
+
return parentFrame.declaration.props.children;
|
|
47
|
+
}
|
|
48
|
+
return parentFrame.declarations;
|
|
49
|
+
};
|
|
50
|
+
tokens.forEach(token => {
|
|
51
|
+
switch (token.type) {
|
|
52
|
+
case 'Text':
|
|
53
|
+
{
|
|
54
|
+
const decoded = (0, _htmlEntityDecoder.decodeHtmlEntities)(token.value);
|
|
55
|
+
const targetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
|
|
56
|
+
targetArray.push(decoded);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'TagOpen':
|
|
60
|
+
{
|
|
61
|
+
const {
|
|
62
|
+
tagNumber
|
|
63
|
+
} = token;
|
|
64
|
+
const currentDeclarations = getCurrentDeclarations();
|
|
65
|
+
const declaration = currentDeclarations[tagNumber];
|
|
66
|
+
if (!declaration) {
|
|
67
|
+
literalTagNumbers.add(tagNumber);
|
|
68
|
+
const literalText = `<${tagNumber}>`;
|
|
69
|
+
const targetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
|
|
70
|
+
targetArray.push(literalText);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
stack.push({
|
|
74
|
+
tagNumber,
|
|
75
|
+
children: [],
|
|
76
|
+
position: token.position,
|
|
77
|
+
declaration,
|
|
78
|
+
declarations: currentDeclarations
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case 'TagClose':
|
|
83
|
+
{
|
|
84
|
+
const {
|
|
85
|
+
tagNumber
|
|
86
|
+
} = token;
|
|
87
|
+
if (literalTagNumbers.has(tagNumber)) {
|
|
88
|
+
const literalText = `</${tagNumber}>`;
|
|
89
|
+
const literalTargetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
|
|
90
|
+
literalTargetArray.push(literalText);
|
|
91
|
+
literalTagNumbers.delete(tagNumber);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (stack.length === 0) {
|
|
95
|
+
throw new _TranslationParserError.TranslationParserError(`Unexpected closing tag </${tagNumber}> at position ${token.position}`, token.position, translation);
|
|
96
|
+
}
|
|
97
|
+
const frame = stack.pop();
|
|
98
|
+
if (frame.tagNumber !== tagNumber) {
|
|
99
|
+
throw new _TranslationParserError.TranslationParserError(`Mismatched tags: expected </${frame.tagNumber}> but got </${tagNumber}> at position ${token.position}`, token.position, translation);
|
|
100
|
+
}
|
|
101
|
+
const element = renderDeclarationNode(frame.declaration, frame.children, frame.declarations);
|
|
102
|
+
const elementTargetArray = stack.length > 0 ? stack[stack.length - 1].children : result;
|
|
103
|
+
elementTargetArray.push(element);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (stack.length > 0) {
|
|
109
|
+
const unclosed = stack[stack.length - 1];
|
|
110
|
+
throw new _TranslationParserError.TranslationParserError(`Unclosed tag <${unclosed.tagNumber}> at position ${unclosed.position}`, unclosed.position, translation);
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
};
|
|
114
|
+
exports.renderTranslation = renderTranslation;
|