@sv-print/plugin-i18n 0.1.8 → 0.1.9
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/dist/index.js +1 -1
- package/dist/index.mjs +98 -93
- package/dist/index.umd.js +1 -1
- package/dist/translate-option.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ne=Object.defineProperty,Te=Object.defineProperties;var Fe=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ae=(r,e,t)=>e in r?Ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e)=>{for(var t in e||(e={}))Ee.call(e,t)&&ae(r,t,e[t]);if(re)for(var t of re(e))je.call(e,t)&&ae(r,t,e[t]);return r},O=(r,e)=>Te(r,Fe(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=r=>typeof r=="string",H=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},oe=r=>r==null?"":""+r,Ie=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},De=/###/g,le=r=>r&&r.indexOf("###")>-1?r.replace(De,"."):r,ue=r=>!r||g(r),B=(r,e,t)=>{const s=g(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(ue(r))return{};const n=le(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return ue(r)?{}:{obj:r,k:le(s[i])}},he=(r,e,t)=>{const{obj:s,k:i}=B(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],a=e.slice(0,e.length-1),o=B(r,a,Object);for(;o.obj===void 0&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),o=B(r,a,Object),o!=null&&o.obj&&typeof o.obj[`${o.k}.${n}`]!="undefined"&&(o.obj=void 0);o.obj[`${o.k}.${n}`]=t},Ve=(r,e,t,s)=>{const{obj:i,k:n}=B(r,e,Object);i[n]=i[n]||[],i[n].push(t)},Q=(r,e)=>{const{obj:t,k:s}=B(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},Ae=(r,e,t)=>{const s=Q(r,t);return s!==void 0?s:Q(e,t)},ve=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?g(r[s])||r[s]instanceof String||g(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):ve(r[s],e[s],t):r[s]=e[s]);return r},A=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ke={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Me=r=>g(r)?r.replace(/[&<>"'\/]/g,e=>Ke[e]):r;class Ue{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)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}}const He=[" ",",","?","!",";"],Be=new Ue(20),ze=(r,e,t)=>{e=e||"",t=t||"";const s=He.filter(a=>e.indexOf(a)<0&&t.indexOf(a)<0);if(s.length===0)return!0;const i=Be.getRegExp(`(${s.map(a=>a==="?"?"\\?":a).join("|")})`);let n=!i.test(r);if(!n){const a=r.indexOf(t);a>0&&!i.test(r.substring(0,a))&&(n=!0)}return n},ee=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=n;l<s.length;++l)if(l!==n&&(o+=t),o+=s[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=a}return i},z=r=>r==null?void 0:r.replace("_","-"),Je={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){var t,s;(s=(t=console==null?void 0:console[r])==null?void 0:t.apply)==null||s.call(t,console,e)}};class G{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Je,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,s,i){return i&&!this.debug?null:(g(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new G(this.logger,p({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new G(this.logger,e)}}var T=new G;class X{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i.apply(i,[e,...t])})}}class fe extends X{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(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,s,i={}){var u,f;const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],s&&(Array.isArray(s)?o.push(...s):g(s)&&n?o.push(...s.split(n)):o.push(s)));const l=Q(this.data,o);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=o[0],t=o[1],s=o.slice(2).join(".")),l||!a||!g(s)?l:ee((f=(u=this.data)==null?void 0:u[e])==null?void 0:f[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=[e,t];s&&(o=o.concat(a?s.split(a):s)),e.indexOf(".")>-1&&(o=e.split("."),i=t,t=o[1]),this.addNamespaces(t),he(this.data,o,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(g(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),i=s,s=t,t=o[1]),this.addNamespaces(t);let l=Q(this.data,o)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?ve(l,s,n):l=p(p({},l),s),he(this.data,o,l),a.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 this.getResource(e,t)!==void 0}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(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var Ce={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{var a,o;e=(o=(a=this.processors[n])==null?void 0:a.process(e,t,s,i))!=null?o:e}),e}};const ce={},de=r=>!g(r)&&typeof r!="boolean"&&typeof r!="number";class Z extends X{constructor(e,t={}){super(),Ie(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=T.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s=p({},t);if(e==null)return!1;const i=this.resolve(e,s);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const a=s&&e.indexOf(s)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!ze(e,s,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:g(n)?[n]:n};const u=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(i)}return{key:e,namespaces:g(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?p({},t):t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(i=p({},i)),i||(i={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),u=l[l.length-1];let f=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const h=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((h==null?void 0:h.toLowerCase())==="cimode")return m?n?{res:`${u}${f}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${f}${o}`:n?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const d=this.resolve(e,i);let c=d==null?void 0:d.res;const x=(d==null?void 0:d.usedKey)||o,S=(d==null?void 0:d.exactUsedKey)||o,P=["[object Number]","[object Function]","[object RegExp]"],C=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject,L=i.count!==void 0&&!g(i.count),F=Z.hasDefaultValue(i),_=L?this.pluralResolver.getSuffix(h,i.count,i):"",E=i.ordinal&&L?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",K=L&&!i.ordinal&&i.count===0,w=K&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${_}`]||i[`defaultValue${E}`]||i.defaultValue;let b=c;I&&!c&&F&&(b=w);const Re=de(b),ke=Object.prototype.toString.apply(b);if(I&&b&&Re&&P.indexOf(ke)<0&&!(g(C)&&Array.isArray(b))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const k=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},i),{ns:l})):`key '${o} (${this.language})' returned an object instead of string.`;return n?(d.res=k,d.usedParams=this.getUsedParamsDetails(i),d):k}if(a){const k=Array.isArray(b),R=k?[]:{},te=k?S:x;for(const N in b)if(Object.prototype.hasOwnProperty.call(b,N)){const j=`${te}${a}${N}`;F&&!c?R[N]=this.translate(j,O(p({},i),{defaultValue:de(w)?w[N]:void 0,joinArrays:!1,ns:l})):R[N]=this.translate(j,O(p({},i),{joinArrays:!1,ns:l})),R[N]===j&&(R[N]=b[N])}c=R}}else if(I&&g(C)&&Array.isArray(c))c=c.join(C),c&&(c=this.extendTranslation(c,e,i,s));else{let k=!1,R=!1;!this.isValidLookup(c)&&F&&(k=!0,c=w),this.isValidLookup(c)||(R=!0,c=o);const N=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:c,j=F&&w!==c&&this.options.updateMissing;if(R||k||j){if(this.logger.log(j?"updateKey":"missingKey",h,u,o,j?w:c),a){const v=this.resolve(o,O(p({},i),{keySeparator:!1}));v&&v.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 M=[];const W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let v=0;v<W.length;v++)M.push(W[v]);else this.options.saveMissingTo==="all"?M=this.languageUtils.toResolveHierarchy(i.lng||this.language):M.push(i.lng||this.language);const se=(v,D,U)=>{var ne;const ie=F&&U!==c?U:N;this.options.missingKeyHandler?this.options.missingKeyHandler(v,u,D,ie,j,i):(ne=this.backendConnector)!=null&&ne.saveMissing&&this.backendConnector.saveMissing(v,u,D,ie,j,i),this.emit("missingKey",v,u,D,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?M.forEach(v=>{const D=this.pluralResolver.getSuffixes(v,i);K&&i[`defaultValue${this.options.pluralSeparator}zero`]&&D.indexOf(`${this.options.pluralSeparator}zero`)<0&&D.push(`${this.options.pluralSeparator}zero`),D.forEach(U=>{se([v],o+U,i[`defaultValue${U}`]||w)})}):se(M,o,w))}c=this.extendTranslation(c,e,i,d,s),R&&c===o&&this.options.appendNamespaceToMissingKey&&(c=`${u}${f}${o}`),(R||k)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${f}${o}`:o,k?c:void 0,i))}return n?(d.res=c,d.usedParams=this.getUsedParamsDetails(i),d):c}extendTranslation(e,t,s,i,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,p(p({},this.options.interpolation.defaultVariables),s),s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(O(p({},s),{interpolation:p(p({},this.options.interpolation),s.interpolation)}));const f=g(e)&&(((u=s==null?void 0:s.interpolation)==null?void 0:u.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(f){const d=e.match(this.interpolator.nestingRegexp);h=d&&d.length}let m=s.replace&&!g(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(m=p(p({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,s.lng||this.language||i.usedLng,s),f){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;h<c&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>(n==null?void 0:n[0])===d[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),s)),s.interpolation&&this.interpolator.reset()}const a=s.postProcess||this.options.postProcess,o=g(a)?[a]:a;return e!=null&&(o!=null&&o.length)&&s.applyPostProcessor!==!1&&(e=Ce.handle(o,e,t,this.options&&this.options.postProcessPassResolved?p({i18nResolved:O(p({},i),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),e}resolve(e,t={}){let s,i,n,a,o;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(l,t),f=u.key;i=f;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=t.count!==void 0&&!g(t.count),d=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(g(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);h.forEach(S=>{var P,C;this.isValidLookup(s)||(o=S,!ce[`${x[0]}-${S}`]&&((P=this.utils)!=null&&P.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(o))&&(ce[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${x.join(", ")}" won't get resolved as namespace "${o}" 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!!!")),x.forEach(I=>{var _;if(this.isValidLookup(s))return;a=I;const L=[f];if((_=this.i18nFormat)!=null&&_.addLookupKeys)this.i18nFormat.addLookupKeys(L,f,I,S,t);else{let E;m&&(E=this.pluralResolver.getSuffix(I,t.count,t));const K=`${this.options.pluralSeparator}zero`,w=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(f+E),t.ordinal&&E.indexOf(w)===0&&L.push(f+E.replace(w,this.options.pluralSeparator)),d&&L.push(f+K)),c){const b=`${f}${this.options.contextSeparator}${t.context}`;L.push(b),m&&(L.push(b+E),t.ordinal&&E.indexOf(w)===0&&L.push(b+E.replace(w,this.options.pluralSeparator)),d&&L.push(b+K))}}let F;for(;F=L.pop();)this.isValidLookup(s)||(n=F,s=this.getResource(I,S,F,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!g(e.replace);let i=s?e.replace:e;if(s&&typeof e.count!="undefined"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i=p(p({},this.options.interpolation.defaultVariables),i)),!s){i=p({},i);for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}}class pe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=T.create("languageUtils")}getScriptPartFromCode(e){if(e=z(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=z(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(g(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(s){}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(this.options.load==="languageOnly"||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(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(a=>{if(a===n)return a;if(!(a.indexOf("-")<0&&n.indexOf("-")<0)&&(a.indexOf("-")>0&&n.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===n||a.indexOf(n)===0&&n.length>1))return a})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),g(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return g(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):g(e)&&n(this.formatLanguageCode(e)),s.forEach(a=>{i.indexOf(a)<0&&n(this.formatLanguageCode(a))}),i}}const ge={zero:0,one:1,two:2,few:3,many:4,other:5},me={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class _e{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=T.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=z(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let a;try{a=new Intl.PluralRules(s,{type:i})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),me;if(!e.match(/-|_/))return me;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,t)}return this.pluralRulesCache[n]=a,a}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>ge[i]-ge[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const xe=(r,e,t,s=".",i=!0)=>{let n=Ae(r,e,t);return!n&&i&&g(t)&&(n=ee(r,t,s),n===void 0&&(n=ee(e,t,s))),n},q=r=>r.replace(/\$/g,"$$$$");class We{constructor(e={}){var t;this.logger=T.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(s=>s),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:u,unescapeSuffix:f,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:d,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:P,alwaysFormat:C}=e.interpolation;this.escape=t!==void 0?t:Me,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?A(n):a||"{{",this.suffix=o?A(o):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?A(m):d||A("$t("),this.nestingSuffix=c?A(c):x||A(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=P||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>(t==null?void 0:t.source)===s?(t.lastIndex=0,t):new RegExp(s,"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,s,i){var d;let n,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const C=xe(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,s,O(p(p({},i),t),{interpolationkey:c})):C}const x=c.split(this.formatSeparator),S=x.shift().trim(),P=x.join(this.formatSeparator).trim();return this.format(xe(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),P,s,O(p(p({},i),t),{interpolationkey:S}))};this.resetRegExp();const f=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((d=i==null?void 0:i.interpolation)==null?void 0:d.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>q(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?q(this.escape(c)):q(c)}].forEach(c=>{for(o=0;n=c.regex.exec(e);){const x=n[1].trim();if(a=u(x),a===void 0)if(typeof f=="function"){const P=f(e,n,i);a=g(P)?P:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(h){a=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!g(a)&&!this.useRawValueToEscape&&(a=oe(a));const S=c.safeValue(a);if(e=e.replace(n[0],S),h?(c.regex.lastIndex+=a.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,a;const o=(l,u)=>{var x;const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const h=l.split(new RegExp(`${f}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,a);const d=m.match(/'/g),c=m.match(/"/g);(((x=d==null?void 0:d.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),u&&(a=p(p({},u),a))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${f}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a=p({},s),a=a.replace&&!g(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(l=i[1].slice(u).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),n=t(o.call(this,i[1].trim(),a),a),n&&i[0]===e&&!g(n))return n;g(n)||(n=oe(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((f,h)=>this.format(f,h,s.lng,O(p({},s),{interpolationkey:i[1].trim()})),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const Ye=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),f=o.trim();t[f]||(t[f]=u),u==="false"&&(t[f]=!1),u==="true"&&(t[f]=!0),isNaN(u)||(t[f]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},ye=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n=O(p({},n),{[i.interpolationkey]:void 0}));const a=s+JSON.stringify(n);let o=e[a];return o||(o=r(z(s),i),e[a]=o),o(t)}},Qe=r=>(e,t,s)=>r(z(t),s)(e);class Ge{constructor(e={}){this.logger=T.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?ye:Qe;this.formats={number:s((i,n)=>{const a=new Intl.NumberFormat(i,p({},n));return o=>a.format(o)}),currency:s((i,n)=>{const a=new Intl.NumberFormat(i,O(p({},n),{style:"currency"}));return o=>a.format(o)}),datetime:s((i,n)=>{const a=new Intl.DateTimeFormat(i,p({},n));return o=>a.format(o)}),relativetime:s((i,n)=>{const a=new Intl.RelativeTimeFormat(i,p({},n));return o=>a.format(o,n.range||"day")}),list:s((i,n)=>{const a=new Intl.ListFormat(i,p({},n));return o=>a.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ye(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(o=>o.indexOf(")")>-1)){const o=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,o)].join(this.formatSeparator)}return n.reduce((o,l)=>{var h;const{formatName:u,formatOptions:f}=Ye(l);if(this.formats[u]){let m=o;try{const d=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},c=d.locale||d.lng||i.locale||i.lng||s;m=this.formats[u](o,c,p(p(p({},f),i),d))}catch(d){this.logger.warn(d)}return m}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const Ze=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class Xe extends X{constructor(e,t,s,i={}){var n,a;super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=T.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(n=this.backend)==null?void 0:n.init)==null||a.call(n,s,i.backend,i)}queueLoad(e,t,s,i){const n={},a={},o={},l={};return e.forEach(u=>{let f=!0;t.forEach(h=>{const m=`${u}|${h}`;!s.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,f=!1,a[m]===void 0&&(a[m]=!0),n[m]===void 0&&(n[m]=!0),l[h]===void 0&&(l[h]=!0)))}),f||(o[u]=!0)}),(Object.keys(n).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],a=i[1];t&&this.emit("failedLoading",n,a,t),!t&&s&&this.store.addResourceBundle(n,a,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Ve(l.loaded,[n],a),Ze(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{o[u]||(o[u]={});const f=l.loaded[u];f.length&&f.forEach(h=>{o[u][h]===void 0&&(o[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:a});return}this.readingCalls++;const o=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,a)},n);return}a(u,f)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(f=>o(null,f)).catch(o):o(null,u)}catch(u){o(u)}return}return l(e,t,o)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();g(e)&&(e=this.languageUtils.toResolveHierarchy(e)),g(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(a=>{this.loadOne(a)})}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("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,a),!a&&o&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,t,s,i,n,a={},o=()=>{}){var l,u,f,h,m;if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(f=this.services)==null?void 0:f.utils)!=null&&h.hasLoadedNamespace(t))){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!!!");return}if(!(s==null||s==="")){if((m=this.backend)!=null&&m.create){const d=O(p({},a),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,s,i,d):x=c(e,t,s,i),x&&typeof x.then=="function"?x.then(S=>o(null,S)).catch(o):o(null,x)}catch(x){o(x)}else c(e,t,s,i,o,d)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const Se=()=>({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:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),g(r[1])&&(e.defaultValue=r[1]),g(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),be=r=>{var e,t;return g(r.ns)&&(r.ns=[r.ns]),g(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),g(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),((t=(e=r.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r},Y=()=>{},qe=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})};class J extends X{constructor(e={},t){if(super(),this.options=be(e),this.services={},this.logger=T,this.modules={external:[]},qe(this),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,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(g(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=Se();this.options=p(p(p({},s),this.options),be(e)),this.options.interpolation=p(p({},s.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?T.init(i(this.modules.logger),this.options):T.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Ge;const f=new pe(this.options);this.store=new fe(this.options.resources,this.options);const h=this.services;h.logger=T,h.resourceStore=this.store,h.languageUtils=f,h.pluralResolver=new _e(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new We(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Xe(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new Z(this.services,this.options),this.translator.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Y),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...f)=>this.store[u](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...f)=>(this.store[u](...f),this)});const o=H(),l=()=>{const u=(f,h)=>{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),o.resolve(h),t(f,h)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,t=Y){var n,a;let s=t;const i=g(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const o=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&o.indexOf(h)<0&&o.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>l(f)),(a=(n=this.options.preload)==null?void 0:n.forEach)==null||a.call(n,u=>l(u)),this.services.backendConnector.load(o,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(e,t,s){const i=H();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=Y),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),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 e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Ce.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;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 s=H();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},n=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...u)=>this.t(...u)),t&&t(o,(...u)=>this.t(...u))},a=o=>{var f,h;!e&&!o&&this.services.languageDetector&&(o=[]);const l=g(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(g(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),(h=(f=this.services.languageDetector)==null?void 0:f.cacheUserLanguage)==null||h.call(f,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),s}getFixedT(e,t,s){const i=(n,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([n,a].concat(o)):l=p({},a),l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const u=this.options.keySeparator||".";let f;return l.keyPrefix&&Array.isArray(n)?f=n.map(h=>`${l.keyPrefix}${u}${h}`):f=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(f,l)};return g(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.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],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const a=(o,l)=>{const u=this.services.backendConnector.state[`${o}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const o=t.precheck(this,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(s,e)&&(!i||a(n,e)))}loadNamespaces(e,t){const s=H();return this.options.ns?(g(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=H();g(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return n.length?(this.options.preload=i.concat(n),this.loadResources(a=>{s.resolve(),t&&t(a)}),s):(t&&t(),Promise.resolve())}dir(e){var i,n;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const o=a.getTextInfo();if(o&&o.direction)return o.direction}}catch(a){}const t=["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"],s=((n=this.services)==null?void 0:n.languageUtils)||new pe(Se());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new J(e,t)}cloneInstance(e={},t=Y){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i=O(p(p({},this.options),e),{isClone:!0}),n=new J(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(o=>{n[o]=this[o]}),n.services=p({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const o=Object.keys(this.store.data).reduce((l,u)=>(l[u]=p({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((f,h)=>(f[h]=p({},l[u][h]),f),l[u]),l),{});n.store=new fe(o,i),n.services.resourceStore=n.store}return n.translator=new Z(n.services,i),n.translator.on("*",(o,...l)=>{n.emit(o,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=J.createInstance();y.createInstance=J.createInstance;y.createInstance;y.dir;y.init;y.loadResources;y.reloadResources;y.use;y.changeLanguage;y.getFixedT;y.t;y.exists;y.setDefaultNamespace;y.hasLoadedNamespace;y.loadNamespaces;y.loadLanguages;const et=(r,e)=>{for(const t of e){const s=r.find(t);s&&s.each((i,n)=>{const a=$(n);if(a.attr("data-i18n"))return;const o=a.text().trim();o&&(a.attr({"data-i18n":o}),a.text(y.t(o)));const l=a.attr("placeholder");l&&(a.attr({"data-i18n":"[placeholder]"+l}),a.attr({placeholder:y.t(l)}))})}},V=r=>{for(const e of r){const t=$(e);t&&t.each((s,i)=>{const n=$(i);if(n.attr("data-i18n"))return;const a=n.text().trim();a&&(n.attr({"data-i18n":a}),n.text(y.t(a)));const o=n.attr("placeholder");o&&(n.attr({"data-i18n":"[placeholder]"+o}),n.attr({placeholder:y.t(o)}))})}},Pe=[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc",".hiprint-multiselect-search",".hiprint-multiselect-custom-input",".hiprint-multiselect-trigger .hiprint-multiselect-text",".hiprint-multiselect-item span",".hiprint-multiselect-actions button"],tt=(r,e,t=Pe)=>{et(e,t)},$e=(r="[data-i18n]")=>{document.querySelectorAll(r).forEach(e=>{const t=e.getAttribute("data-i18n");if(!t.includes("[")){e.textContent=y.t(t);return}const s=t.match(/\[([^\]]+)\](.+)/);if(s&&s.length===3){const i=s[1],n=s[2];e.setAttribute(i,y.t(n))}})};let Le=!1;const Oe=r=>{if(Le)return;Le=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(r.resources||{});globalThis.hiprint.languages=["简体中文",...e],globalThis.hiprint.changeLanguage=(t,s)=>{y.changeLanguage(t,(i,n)=>{s&&s(i,n),$e()})}},we=r=>{setTimeout(()=>{$e(".printSetting .hiprint-multiselect [data-i18n]"),$(".printSetting .hiprint-multiselect").length&&$(".printSetting .hiprint-multiselect-trigger").off("click.multiselect-trigger").on("click.multiselect-trigger",()=>{console.log("click multiselect"),setTimeout(()=>{V((r==null?void 0:r.optionsSelectorList)||Pe)},0)})},0)};function st(r,e){y.init(p({},r),(s,i)=>{e&&e(y,i,s)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"添加 i18n 方法",priority:1,run:()=>{Oe(r)}},{hook:"getOptionItem",name:"i18n options",description:"渲染元素属性时做多语言处理",priority:1,run:s=>{if(s){if(!s._translationWrapped){s._translationWrapped=!0;const i=s.createTarget;s.createTarget=function(...n){const a=i.call(s,...n);return t.indexOf(s.name)!==-1&&a.attr("data-name")||(a.attr({"data-name":s.name}),tt(s,a,r==null?void 0:r.optionsSelectorList)),a}}return t.indexOf(s.name)===-1&&t.push(s.name),s}}},{hook:"onDesigned",name:"i18n other selector",description:"其他UI选择器多语言处理",priority:9,run:({hiprint:s,designerUtils:i})=>{Oe(r),setTimeout(()=>{var o;const n=(o=i.printTemplate)==null?void 0:o.id;n&&(r!=null&&r.onDesigned&&(r==null||r.onDesigned(i)),globalThis.hinnn.event.on("BuildCustomOptionSettingEventKey_"+n,l=>{r!=null&&r.onPanelSelected&&(r==null||r.onPanelSelected()),we(r)}),globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{V([".printSetting .prop-tab-items .tab-title"]),we(r),r!=null&&r.onElementSelected&&(r==null||r.onElementSelected(l))},0)}),$(".hiprint-printPaper.design").on("contextmenu",()=>{V([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),V([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onDesignedDelay)||600)}},{hook:"onSettings",name:"i18n settings",description:"设置选择器多语言处理",priority:1,run:s=>{s.type=="show"&&setTimeout(()=>{V([".settings-body .svp-tab"])},0),r!=null&&r.onSettings&&(r==null||r.onSettings(s))}},{hook:"onPreview",name:"i18n preview selector",description:"组件内预览选择器多语言处理",priority:1,run:s=>{setTimeout(()=>{V([".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onPreviewDelay)||0),r!=null&&r.onPreview&&(r==null||r.onPreview(s))}}],leastHiprintVersion:"0.1.28"}}exports.default=st;exports.translateBySelector=V;
|
|
1
|
+
"use strict";var Ee=Object.defineProperty,Fe=Object.defineProperties;var je=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var ae=(r,e,t)=>e in r?Ee(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e)=>{for(var t in e||(e={}))Ie.call(e,t)&&ae(r,t,e[t]);if(re)for(var t of re(e))De.call(e,t)&&ae(r,t,e[t]);return r},O=(r,e)=>Fe(r,je(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=r=>typeof r=="string",H=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},oe=r=>r==null?"":""+r,Ve=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},Ae=/###/g,le=r=>r&&r.indexOf("###")>-1?r.replace(Ae,"."):r,ue=r=>!r||g(r),B=(r,e,t)=>{const s=g(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(ue(r))return{};const n=le(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return ue(r)?{}:{obj:r,k:le(s[i])}},he=(r,e,t)=>{const{obj:s,k:i}=B(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],a=e.slice(0,e.length-1),o=B(r,a,Object);for(;o.obj===void 0&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),o=B(r,a,Object),o!=null&&o.obj&&typeof o.obj[`${o.k}.${n}`]!="undefined"&&(o.obj=void 0);o.obj[`${o.k}.${n}`]=t},Ke=(r,e,t,s)=>{const{obj:i,k:n}=B(r,e,Object);i[n]=i[n]||[],i[n].push(t)},Q=(r,e)=>{const{obj:t,k:s}=B(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},Me=(r,e,t)=>{const s=Q(r,t);return s!==void 0?s:Q(e,t)},ve=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?g(r[s])||r[s]instanceof String||g(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):ve(r[s],e[s],t):r[s]=e[s]);return r},A=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ue={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const He=r=>g(r)?r.replace(/[&<>"'\/]/g,e=>Ue[e]):r;class Be{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)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}}const ze=[" ",",","?","!",";"],Je=new Be(20),_e=(r,e,t)=>{e=e||"",t=t||"";const s=ze.filter(a=>e.indexOf(a)<0&&t.indexOf(a)<0);if(s.length===0)return!0;const i=Je.getRegExp(`(${s.map(a=>a==="?"?"\\?":a).join("|")})`);let n=!i.test(r);if(!n){const a=r.indexOf(t);a>0&&!i.test(r.substring(0,a))&&(n=!0)}return n},ee=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=n;l<s.length;++l)if(l!==n&&(o+=t),o+=s[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=a}return i},z=r=>r==null?void 0:r.replace("_","-"),We={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){var t,s;(s=(t=console==null?void 0:console[r])==null?void 0:t.apply)==null||s.call(t,console,e)}};class G{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||We,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,s,i){return i&&!this.debug?null:(g(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new G(this.logger,p({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new G(this.logger,e)}}var T=new G;class X{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i.apply(i,[e,...t])})}}class fe extends X{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(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,s,i={}){var u,f;const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],s&&(Array.isArray(s)?o.push(...s):g(s)&&n?o.push(...s.split(n)):o.push(s)));const l=Q(this.data,o);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=o[0],t=o[1],s=o.slice(2).join(".")),l||!a||!g(s)?l:ee((f=(u=this.data)==null?void 0:u[e])==null?void 0:f[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=[e,t];s&&(o=o.concat(a?s.split(a):s)),e.indexOf(".")>-1&&(o=e.split("."),i=t,t=o[1]),this.addNamespaces(t),he(this.data,o,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(g(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),i=s,s=t,t=o[1]),this.addNamespaces(t);let l=Q(this.data,o)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?ve(l,s,n):l=p(p({},l),s),he(this.data,o,l),a.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 this.getResource(e,t)!==void 0}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(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var Ce={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{var a,o;e=(o=(a=this.processors[n])==null?void 0:a.process(e,t,s,i))!=null?o:e}),e}};const ce={},de=r=>!g(r)&&typeof r!="boolean"&&typeof r!="number";class Z extends X{constructor(e,t={}){super(),Ve(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=T.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s=p({},t);if(e==null)return!1;const i=this.resolve(e,s);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const a=s&&e.indexOf(s)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!_e(e,s,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:g(n)?[n]:n};const u=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(i)}return{key:e,namespaces:g(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?p({},t):t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(i=p({},i)),i||(i={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),u=l[l.length-1];let f=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const h=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((h==null?void 0:h.toLowerCase())==="cimode")return m?n?{res:`${u}${f}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${f}${o}`:n?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const d=this.resolve(e,i);let c=d==null?void 0:d.res;const x=(d==null?void 0:d.usedKey)||o,S=(d==null?void 0:d.exactUsedKey)||o,P=["[object Number]","[object Function]","[object RegExp]"],C=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject,L=i.count!==void 0&&!g(i.count),E=Z.hasDefaultValue(i),_=L?this.pluralResolver.getSuffix(h,i.count,i):"",F=i.ordinal&&L?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",K=L&&!i.ordinal&&i.count===0,w=K&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${_}`]||i[`defaultValue${F}`]||i.defaultValue;let b=c;I&&!c&&E&&(b=w);const Ne=de(b),Te=Object.prototype.toString.apply(b);if(I&&b&&Ne&&P.indexOf(Te)<0&&!(g(C)&&Array.isArray(b))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const k=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},i),{ns:l})):`key '${o} (${this.language})' returned an object instead of string.`;return n?(d.res=k,d.usedParams=this.getUsedParamsDetails(i),d):k}if(a){const k=Array.isArray(b),R=k?[]:{},te=k?S:x;for(const N in b)if(Object.prototype.hasOwnProperty.call(b,N)){const j=`${te}${a}${N}`;E&&!c?R[N]=this.translate(j,O(p({},i),{defaultValue:de(w)?w[N]:void 0,joinArrays:!1,ns:l})):R[N]=this.translate(j,O(p({},i),{joinArrays:!1,ns:l})),R[N]===j&&(R[N]=b[N])}c=R}}else if(I&&g(C)&&Array.isArray(c))c=c.join(C),c&&(c=this.extendTranslation(c,e,i,s));else{let k=!1,R=!1;!this.isValidLookup(c)&&E&&(k=!0,c=w),this.isValidLookup(c)||(R=!0,c=o);const N=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:c,j=E&&w!==c&&this.options.updateMissing;if(R||k||j){if(this.logger.log(j?"updateKey":"missingKey",h,u,o,j?w:c),a){const v=this.resolve(o,O(p({},i),{keySeparator:!1}));v&&v.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 M=[];const W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let v=0;v<W.length;v++)M.push(W[v]);else this.options.saveMissingTo==="all"?M=this.languageUtils.toResolveHierarchy(i.lng||this.language):M.push(i.lng||this.language);const se=(v,D,U)=>{var ne;const ie=E&&U!==c?U:N;this.options.missingKeyHandler?this.options.missingKeyHandler(v,u,D,ie,j,i):(ne=this.backendConnector)!=null&&ne.saveMissing&&this.backendConnector.saveMissing(v,u,D,ie,j,i),this.emit("missingKey",v,u,D,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?M.forEach(v=>{const D=this.pluralResolver.getSuffixes(v,i);K&&i[`defaultValue${this.options.pluralSeparator}zero`]&&D.indexOf(`${this.options.pluralSeparator}zero`)<0&&D.push(`${this.options.pluralSeparator}zero`),D.forEach(U=>{se([v],o+U,i[`defaultValue${U}`]||w)})}):se(M,o,w))}c=this.extendTranslation(c,e,i,d,s),R&&c===o&&this.options.appendNamespaceToMissingKey&&(c=`${u}${f}${o}`),(R||k)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${f}${o}`:o,k?c:void 0,i))}return n?(d.res=c,d.usedParams=this.getUsedParamsDetails(i),d):c}extendTranslation(e,t,s,i,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,p(p({},this.options.interpolation.defaultVariables),s),s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(O(p({},s),{interpolation:p(p({},this.options.interpolation),s.interpolation)}));const f=g(e)&&(((u=s==null?void 0:s.interpolation)==null?void 0:u.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(f){const d=e.match(this.interpolator.nestingRegexp);h=d&&d.length}let m=s.replace&&!g(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(m=p(p({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,s.lng||this.language||i.usedLng,s),f){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;h<c&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>(n==null?void 0:n[0])===d[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),s)),s.interpolation&&this.interpolator.reset()}const a=s.postProcess||this.options.postProcess,o=g(a)?[a]:a;return e!=null&&(o!=null&&o.length)&&s.applyPostProcessor!==!1&&(e=Ce.handle(o,e,t,this.options&&this.options.postProcessPassResolved?p({i18nResolved:O(p({},i),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),e}resolve(e,t={}){let s,i,n,a,o;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(l,t),f=u.key;i=f;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=t.count!==void 0&&!g(t.count),d=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(g(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);h.forEach(S=>{var P,C;this.isValidLookup(s)||(o=S,!ce[`${x[0]}-${S}`]&&((P=this.utils)!=null&&P.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(o))&&(ce[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${x.join(", ")}" won't get resolved as namespace "${o}" 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!!!")),x.forEach(I=>{var _;if(this.isValidLookup(s))return;a=I;const L=[f];if((_=this.i18nFormat)!=null&&_.addLookupKeys)this.i18nFormat.addLookupKeys(L,f,I,S,t);else{let F;m&&(F=this.pluralResolver.getSuffix(I,t.count,t));const K=`${this.options.pluralSeparator}zero`,w=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(f+F),t.ordinal&&F.indexOf(w)===0&&L.push(f+F.replace(w,this.options.pluralSeparator)),d&&L.push(f+K)),c){const b=`${f}${this.options.contextSeparator}${t.context}`;L.push(b),m&&(L.push(b+F),t.ordinal&&F.indexOf(w)===0&&L.push(b+F.replace(w,this.options.pluralSeparator)),d&&L.push(b+K))}}let E;for(;E=L.pop();)this.isValidLookup(s)||(n=E,s=this.getResource(I,S,E,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!g(e.replace);let i=s?e.replace:e;if(s&&typeof e.count!="undefined"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i=p(p({},this.options.interpolation.defaultVariables),i)),!s){i=p({},i);for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}}class pe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=T.create("languageUtils")}getScriptPartFromCode(e){if(e=z(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=z(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(g(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(s){}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(this.options.load==="languageOnly"||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(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(a=>{if(a===n)return a;if(!(a.indexOf("-")<0&&n.indexOf("-")<0)&&(a.indexOf("-")>0&&n.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===n||a.indexOf(n)===0&&n.length>1))return a})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),g(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return g(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):g(e)&&n(this.formatLanguageCode(e)),s.forEach(a=>{i.indexOf(a)<0&&n(this.formatLanguageCode(a))}),i}}const ge={zero:0,one:1,two:2,few:3,many:4,other:5},me={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ye{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=T.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=z(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let a;try{a=new Intl.PluralRules(s,{type:i})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),me;if(!e.match(/-|_/))return me;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,t)}return this.pluralRulesCache[n]=a,a}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>ge[i]-ge[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const xe=(r,e,t,s=".",i=!0)=>{let n=Me(r,e,t);return!n&&i&&g(t)&&(n=ee(r,t,s),n===void 0&&(n=ee(e,t,s))),n},q=r=>r.replace(/\$/g,"$$$$");class Qe{constructor(e={}){var t;this.logger=T.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(s=>s),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:u,unescapeSuffix:f,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:d,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:P,alwaysFormat:C}=e.interpolation;this.escape=t!==void 0?t:He,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?A(n):a||"{{",this.suffix=o?A(o):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?A(m):d||A("$t("),this.nestingSuffix=c?A(c):x||A(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=P||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>(t==null?void 0:t.source)===s?(t.lastIndex=0,t):new RegExp(s,"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,s,i){var d;let n,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const C=xe(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,s,O(p(p({},i),t),{interpolationkey:c})):C}const x=c.split(this.formatSeparator),S=x.shift().trim(),P=x.join(this.formatSeparator).trim();return this.format(xe(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),P,s,O(p(p({},i),t),{interpolationkey:S}))};this.resetRegExp();const f=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((d=i==null?void 0:i.interpolation)==null?void 0:d.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>q(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?q(this.escape(c)):q(c)}].forEach(c=>{for(o=0;n=c.regex.exec(e);){const x=n[1].trim();if(a=u(x),a===void 0)if(typeof f=="function"){const P=f(e,n,i);a=g(P)?P:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(h){a=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!g(a)&&!this.useRawValueToEscape&&(a=oe(a));const S=c.safeValue(a);if(e=e.replace(n[0],S),h?(c.regex.lastIndex+=a.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,a;const o=(l,u)=>{var x;const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const h=l.split(new RegExp(`${f}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,a);const d=m.match(/'/g),c=m.match(/"/g);(((x=d==null?void 0:d.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),u&&(a=p(p({},u),a))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${f}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a=p({},s),a=a.replace&&!g(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(l=i[1].slice(u).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),n=t(o.call(this,i[1].trim(),a),a),n&&i[0]===e&&!g(n))return n;g(n)||(n=oe(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((f,h)=>this.format(f,h,s.lng,O(p({},s),{interpolationkey:i[1].trim()})),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const Ge=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),f=o.trim();t[f]||(t[f]=u),u==="false"&&(t[f]=!1),u==="true"&&(t[f]=!0),isNaN(u)||(t[f]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},ye=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n=O(p({},n),{[i.interpolationkey]:void 0}));const a=s+JSON.stringify(n);let o=e[a];return o||(o=r(z(s),i),e[a]=o),o(t)}},Ze=r=>(e,t,s)=>r(z(t),s)(e);class Xe{constructor(e={}){this.logger=T.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?ye:Ze;this.formats={number:s((i,n)=>{const a=new Intl.NumberFormat(i,p({},n));return o=>a.format(o)}),currency:s((i,n)=>{const a=new Intl.NumberFormat(i,O(p({},n),{style:"currency"}));return o=>a.format(o)}),datetime:s((i,n)=>{const a=new Intl.DateTimeFormat(i,p({},n));return o=>a.format(o)}),relativetime:s((i,n)=>{const a=new Intl.RelativeTimeFormat(i,p({},n));return o=>a.format(o,n.range||"day")}),list:s((i,n)=>{const a=new Intl.ListFormat(i,p({},n));return o=>a.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ye(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(o=>o.indexOf(")")>-1)){const o=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,o)].join(this.formatSeparator)}return n.reduce((o,l)=>{var h;const{formatName:u,formatOptions:f}=Ge(l);if(this.formats[u]){let m=o;try{const d=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},c=d.locale||d.lng||i.locale||i.lng||s;m=this.formats[u](o,c,p(p(p({},f),i),d))}catch(d){this.logger.warn(d)}return m}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const qe=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class et extends X{constructor(e,t,s,i={}){var n,a;super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=T.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(n=this.backend)==null?void 0:n.init)==null||a.call(n,s,i.backend,i)}queueLoad(e,t,s,i){const n={},a={},o={},l={};return e.forEach(u=>{let f=!0;t.forEach(h=>{const m=`${u}|${h}`;!s.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,f=!1,a[m]===void 0&&(a[m]=!0),n[m]===void 0&&(n[m]=!0),l[h]===void 0&&(l[h]=!0)))}),f||(o[u]=!0)}),(Object.keys(n).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],a=i[1];t&&this.emit("failedLoading",n,a,t),!t&&s&&this.store.addResourceBundle(n,a,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Ke(l.loaded,[n],a),qe(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{o[u]||(o[u]={});const f=l.loaded[u];f.length&&f.forEach(h=>{o[u][h]===void 0&&(o[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:a});return}this.readingCalls++;const o=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,a)},n);return}a(u,f)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(f=>o(null,f)).catch(o):o(null,u)}catch(u){o(u)}return}return l(e,t,o)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();g(e)&&(e=this.languageUtils.toResolveHierarchy(e)),g(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(a=>{this.loadOne(a)})}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("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,a),!a&&o&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,t,s,i,n,a={},o=()=>{}){var l,u,f,h,m;if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(f=this.services)==null?void 0:f.utils)!=null&&h.hasLoadedNamespace(t))){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!!!");return}if(!(s==null||s==="")){if((m=this.backend)!=null&&m.create){const d=O(p({},a),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,s,i,d):x=c(e,t,s,i),x&&typeof x.then=="function"?x.then(S=>o(null,S)).catch(o):o(null,x)}catch(x){o(x)}else c(e,t,s,i,o,d)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const Se=()=>({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:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),g(r[1])&&(e.defaultValue=r[1]),g(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),be=r=>{var e,t;return g(r.ns)&&(r.ns=[r.ns]),g(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),g(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),((t=(e=r.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r},Y=()=>{},tt=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})};class J extends X{constructor(e={},t){if(super(),this.options=be(e),this.services={},this.logger=T,this.modules={external:[]},tt(this),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,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(g(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=Se();this.options=p(p(p({},s),this.options),be(e)),this.options.interpolation=p(p({},s.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?T.init(i(this.modules.logger),this.options):T.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Xe;const f=new pe(this.options);this.store=new fe(this.options.resources,this.options);const h=this.services;h.logger=T,h.resourceStore=this.store,h.languageUtils=f,h.pluralResolver=new Ye(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Qe(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new et(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new Z(this.services,this.options),this.translator.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Y),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...f)=>this.store[u](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...f)=>(this.store[u](...f),this)});const o=H(),l=()=>{const u=(f,h)=>{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),o.resolve(h),t(f,h)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,t=Y){var n,a;let s=t;const i=g(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const o=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&o.indexOf(h)<0&&o.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>l(f)),(a=(n=this.options.preload)==null?void 0:n.forEach)==null||a.call(n,u=>l(u)),this.services.backendConnector.load(o,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(e,t,s){const i=H();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=Y),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),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 e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Ce.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;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 s=H();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},n=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...u)=>this.t(...u)),t&&t(o,(...u)=>this.t(...u))},a=o=>{var f,h;!e&&!o&&this.services.languageDetector&&(o=[]);const l=g(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(g(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),(h=(f=this.services.languageDetector)==null?void 0:f.cacheUserLanguage)==null||h.call(f,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),s}getFixedT(e,t,s){const i=(n,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([n,a].concat(o)):l=p({},a),l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const u=this.options.keySeparator||".";let f;return l.keyPrefix&&Array.isArray(n)?f=n.map(h=>`${l.keyPrefix}${u}${h}`):f=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(f,l)};return g(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.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],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const a=(o,l)=>{const u=this.services.backendConnector.state[`${o}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const o=t.precheck(this,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(s,e)&&(!i||a(n,e)))}loadNamespaces(e,t){const s=H();return this.options.ns?(g(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=H();g(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return n.length?(this.options.preload=i.concat(n),this.loadResources(a=>{s.resolve(),t&&t(a)}),s):(t&&t(),Promise.resolve())}dir(e){var i,n;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const o=a.getTextInfo();if(o&&o.direction)return o.direction}}catch(a){}const t=["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"],s=((n=this.services)==null?void 0:n.languageUtils)||new pe(Se());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new J(e,t)}cloneInstance(e={},t=Y){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i=O(p(p({},this.options),e),{isClone:!0}),n=new J(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(o=>{n[o]=this[o]}),n.services=p({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const o=Object.keys(this.store.data).reduce((l,u)=>(l[u]=p({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((f,h)=>(f[h]=p({},l[u][h]),f),l[u]),l),{});n.store=new fe(o,i),n.services.resourceStore=n.store}return n.translator=new Z(n.services,i),n.translator.on("*",(o,...l)=>{n.emit(o,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=J.createInstance();y.createInstance=J.createInstance;y.createInstance;y.dir;y.init;y.loadResources;y.reloadResources;y.use;y.changeLanguage;y.getFixedT;y.t;y.exists;y.setDefaultNamespace;y.hasLoadedNamespace;y.loadNamespaces;y.loadLanguages;const st=r=>{let e="";return r.childNodes.forEach(t=>{t.nodeType===3&&(e+=t.nodeValue)}),e.trim()},Pe=(r,e)=>{let t=!1;r.childNodes.forEach(s=>{if(s.nodeType!==3)return;const i=(s.nodeValue||"").trim();i&&(s.nodeValue=t?"":s.nodeValue.replace(i,()=>e),t=!0)})},$e=r=>{if(r.attr("data-i18n"))return;const e=r.get(0);if(!e)return;const t=st(e);t&&(r.attr({"data-i18n":t}),Pe(e,y.t(t)));const s=r.attr("placeholder");s&&(r.attr({"data-i18n":"[placeholder]"+s}),r.attr({placeholder:y.t(s)}))},it=(r,e)=>{for(const t of e){const s=r.find(t);s&&s.each((i,n)=>{$e($(n))})}},V=r=>{for(const e of r){const t=$(e);t&&t.each((s,i)=>{$e($(i))})}},Re=[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc",".hiprint-multiselect-search",".hiprint-multiselect-custom-input",".hiprint-multiselect-trigger .hiprint-multiselect-text",".hiprint-multiselect-item span",".hiprint-multiselect-actions button"],nt=(r,e,t=Re)=>{it(e,t)},ke=(r="[data-i18n]")=>{document.querySelectorAll(r).forEach(e=>{const t=e.getAttribute("data-i18n");if(!t.includes("[")){Pe(e,y.t(t));return}const s=t.match(/\[([^\]]+)\](.+)/);if(s&&s.length===3){const i=s[1],n=s[2];e.setAttribute(i,y.t(n))}})};let Le=!1;const Oe=r=>{if(Le)return;Le=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(r.resources||{});globalThis.hiprint.languages=["简体中文",...e],globalThis.hiprint.changeLanguage=(t,s)=>{y.changeLanguage(t,(i,n)=>{s&&s(i,n),ke()})}},we=r=>{setTimeout(()=>{ke(".printSetting .hiprint-multiselect [data-i18n]"),$(".printSetting .hiprint-multiselect").length&&$(".printSetting .hiprint-multiselect-trigger").off("click.multiselect-trigger").on("click.multiselect-trigger",()=>{console.log("click multiselect"),setTimeout(()=>{V((r==null?void 0:r.optionsSelectorList)||Re)},0)})},0)};function rt(r,e){y.init(p({},r),(s,i)=>{e&&e(y,i,s)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"添加 i18n 方法",priority:1,run:()=>{Oe(r)}},{hook:"getOptionItem",name:"i18n options",description:"渲染元素属性时做多语言处理",priority:1,run:s=>{if(s){if(!s._translationWrapped){s._translationWrapped=!0;const i=s.createTarget;s.createTarget=function(...n){const a=i.call(s,...n);return t.indexOf(s.name)!==-1&&a.attr("data-name")||(a.attr({"data-name":s.name}),nt(s,a,r==null?void 0:r.optionsSelectorList)),a}}return t.indexOf(s.name)===-1&&t.push(s.name),s}}},{hook:"onDesigned",name:"i18n other selector",description:"其他UI选择器多语言处理",priority:9,run:({hiprint:s,designerUtils:i})=>{Oe(r),setTimeout(()=>{var o;const n=(o=i.printTemplate)==null?void 0:o.id;n&&(r!=null&&r.onDesigned&&(r==null||r.onDesigned(i)),globalThis.hinnn.event.on("BuildCustomOptionSettingEventKey_"+n,l=>{r!=null&&r.onPanelSelected&&(r==null||r.onPanelSelected()),we(r)}),globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{V([".printSetting .prop-tab-items .tab-title"]),we(r),r!=null&&r.onElementSelected&&(r==null||r.onElementSelected(l))},0)}),$(".hiprint-printPaper.design").on("contextmenu",()=>{V([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),V([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onDesignedDelay)||600)}},{hook:"onSettings",name:"i18n settings",description:"设置选择器多语言处理",priority:1,run:s=>{s.type=="show"&&setTimeout(()=>{V([".settings-body .svp-tab"])},0),r!=null&&r.onSettings&&(r==null||r.onSettings(s))}},{hook:"onPreview",name:"i18n preview selector",description:"组件内预览选择器多语言处理",priority:1,run:s=>{setTimeout(()=>{V([".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onPreviewDelay)||0),r!=null&&r.onPreview&&(r==null||r.onPreview(s))}}],leastHiprintVersion:"0.1.28"}}exports.default=rt;exports.translateBySelector=V;
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Ee = Object.defineProperty, Fe = Object.defineProperties;
|
|
2
|
+
var je = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var re = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var ae = (r, e, t) => e in r ?
|
|
4
|
+
var Ie = Object.prototype.hasOwnProperty, De = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ae = (r, e, t) => e in r ? Ee(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Ie.call(e, t) && ae(r, t, e[t]);
|
|
8
8
|
if (re)
|
|
9
9
|
for (var t of re(e))
|
|
10
|
-
|
|
10
|
+
De.call(e, t) && ae(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
}, O = (r, e) =>
|
|
12
|
+
}, O = (r, e) => Fe(r, je(e));
|
|
13
13
|
const g = (r) => typeof r == "string", H = () => {
|
|
14
14
|
let r, e;
|
|
15
15
|
const t = new Promise((s, i) => {
|
|
16
16
|
r = s, e = i;
|
|
17
17
|
});
|
|
18
18
|
return t.resolve = r, t.reject = e, t;
|
|
19
|
-
}, oe = (r) => r == null ? "" : "" + r,
|
|
19
|
+
}, oe = (r) => r == null ? "" : "" + r, Ve = (r, e, t) => {
|
|
20
20
|
r.forEach((s) => {
|
|
21
21
|
e[s] && (t[s] = e[s]);
|
|
22
22
|
});
|
|
23
|
-
},
|
|
23
|
+
}, Ae = /###/g, le = (r) => r && r.indexOf("###") > -1 ? r.replace(Ae, ".") : r, ue = (r) => !r || g(r), B = (r, e, t) => {
|
|
24
24
|
const s = g(e) ? e.split(".") : e;
|
|
25
25
|
let i = 0;
|
|
26
26
|
for (; i < s.length - 1; ) {
|
|
@@ -45,7 +45,7 @@ const g = (r) => typeof r == "string", H = () => {
|
|
|
45
45
|
for (; o.obj === void 0 && a.length; )
|
|
46
46
|
n = `${a[a.length - 1]}.${n}`, a = a.slice(0, a.length - 1), o = B(r, a, Object), o != null && o.obj && typeof o.obj[`${o.k}.${n}`] != "undefined" && (o.obj = void 0);
|
|
47
47
|
o.obj[`${o.k}.${n}`] = t;
|
|
48
|
-
},
|
|
48
|
+
}, Ke = (r, e, t, s) => {
|
|
49
49
|
const {
|
|
50
50
|
obj: i,
|
|
51
51
|
k: n
|
|
@@ -58,7 +58,7 @@ const g = (r) => typeof r == "string", H = () => {
|
|
|
58
58
|
} = B(r, e);
|
|
59
59
|
if (t && Object.prototype.hasOwnProperty.call(t, s))
|
|
60
60
|
return t[s];
|
|
61
|
-
},
|
|
61
|
+
}, Ue = (r, e, t) => {
|
|
62
62
|
const s = Q(r, t);
|
|
63
63
|
return s !== void 0 ? s : Q(e, t);
|
|
64
64
|
}, ve = (r, e, t) => {
|
|
@@ -66,7 +66,7 @@ const g = (r) => typeof r == "string", H = () => {
|
|
|
66
66
|
s !== "__proto__" && s !== "constructor" && (s in r ? g(r[s]) || r[s] instanceof String || g(e[s]) || e[s] instanceof String ? t && (r[s] = e[s]) : ve(r[s], e[s], t) : r[s] = e[s]);
|
|
67
67
|
return r;
|
|
68
68
|
}, V = (r) => r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
69
|
-
var
|
|
69
|
+
var Me = {
|
|
70
70
|
"&": "&",
|
|
71
71
|
"<": "<",
|
|
72
72
|
">": ">",
|
|
@@ -74,8 +74,8 @@ var Ke = {
|
|
|
74
74
|
"'": "'",
|
|
75
75
|
"/": "/"
|
|
76
76
|
};
|
|
77
|
-
const
|
|
78
|
-
class
|
|
77
|
+
const He = (r) => g(r) ? r.replace(/[&<>"'\/]/g, (e) => Me[e]) : r;
|
|
78
|
+
class Be {
|
|
79
79
|
constructor(e) {
|
|
80
80
|
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
81
81
|
}
|
|
@@ -87,11 +87,11 @@ class Me {
|
|
|
87
87
|
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, s), this.regExpQueue.push(e), s;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const ze = [" ", ",", "?", "!", ";"], Je = new Be(20), _e = (r, e, t) => {
|
|
91
91
|
e = e || "", t = t || "";
|
|
92
|
-
const s =
|
|
92
|
+
const s = ze.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
|
|
93
93
|
if (s.length === 0) return !0;
|
|
94
|
-
const i =
|
|
94
|
+
const i = Je.getRegExp(`(${s.map((a) => a === "?" ? "\\?" : a).join("|")})`);
|
|
95
95
|
let n = !i.test(r);
|
|
96
96
|
if (!n) {
|
|
97
97
|
const a = r.indexOf(t);
|
|
@@ -118,7 +118,7 @@ const He = [" ", ",", "?", "!", ";"], Be = new Me(20), ze = (r, e, t) => {
|
|
|
118
118
|
i = a;
|
|
119
119
|
}
|
|
120
120
|
return i;
|
|
121
|
-
}, z = (r) => r == null ? void 0 : r.replace("_", "-"),
|
|
121
|
+
}, z = (r) => r == null ? void 0 : r.replace("_", "-"), We = {
|
|
122
122
|
type: "logger",
|
|
123
123
|
log(r) {
|
|
124
124
|
this.output("log", r);
|
|
@@ -139,7 +139,7 @@ class G {
|
|
|
139
139
|
this.init(e, t);
|
|
140
140
|
}
|
|
141
141
|
init(e, t = {}) {
|
|
142
|
-
this.prefix = t.prefix || "i18next:", this.logger = e ||
|
|
142
|
+
this.prefix = t.prefix || "i18next:", this.logger = e || We, this.options = t, this.debug = t.debug;
|
|
143
143
|
}
|
|
144
144
|
log(...e) {
|
|
145
145
|
return this.forward(e, "log", "", !0);
|
|
@@ -278,7 +278,7 @@ var Ce = {
|
|
|
278
278
|
const ce = {}, de = (r) => !g(r) && typeof r != "boolean" && typeof r != "number";
|
|
279
279
|
class Z extends X {
|
|
280
280
|
constructor(e, t = {}) {
|
|
281
|
-
super(),
|
|
281
|
+
super(), Ve(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = T.create("translator");
|
|
282
282
|
}
|
|
283
283
|
changeLanguage(e) {
|
|
284
284
|
e && (this.language = e);
|
|
@@ -296,7 +296,7 @@ class Z extends X {
|
|
|
296
296
|
s === void 0 && (s = ":");
|
|
297
297
|
const i = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
298
298
|
let n = t.ns || this.options.defaultNS || [];
|
|
299
|
-
const a = s && e.indexOf(s) > -1, o = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !
|
|
299
|
+
const a = s && e.indexOf(s) > -1, o = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !_e(e, s, i);
|
|
300
300
|
if (a && !o) {
|
|
301
301
|
const l = e.match(this.interpolator.nestingRegexp);
|
|
302
302
|
if (l && l.length > 0)
|
|
@@ -341,13 +341,13 @@ class Z extends X {
|
|
|
341
341
|
} : o;
|
|
342
342
|
const d = this.resolve(e, i);
|
|
343
343
|
let c = d == null ? void 0 : d.res;
|
|
344
|
-
const x = (d == null ? void 0 : d.usedKey) || o, S = (d == null ? void 0 : d.exactUsedKey) || o, P = ["[object Number]", "[object Function]", "[object RegExp]"], C = i.joinArrays !== void 0 ? i.joinArrays : this.options.joinArrays, I = !this.i18nFormat || this.i18nFormat.handleAsObject, L = i.count !== void 0 && !g(i.count),
|
|
344
|
+
const x = (d == null ? void 0 : d.usedKey) || o, S = (d == null ? void 0 : d.exactUsedKey) || o, P = ["[object Number]", "[object Function]", "[object RegExp]"], C = i.joinArrays !== void 0 ? i.joinArrays : this.options.joinArrays, I = !this.i18nFormat || this.i18nFormat.handleAsObject, L = i.count !== void 0 && !g(i.count), E = Z.hasDefaultValue(i), _ = L ? this.pluralResolver.getSuffix(h, i.count, i) : "", F = i.ordinal && L ? this.pluralResolver.getSuffix(h, i.count, {
|
|
345
345
|
ordinal: !1
|
|
346
|
-
}) : "", K = L && !i.ordinal && i.count === 0, w = K && i[`defaultValue${this.options.pluralSeparator}zero`] || i[`defaultValue${_}`] || i[`defaultValue${
|
|
346
|
+
}) : "", K = L && !i.ordinal && i.count === 0, w = K && i[`defaultValue${this.options.pluralSeparator}zero`] || i[`defaultValue${_}`] || i[`defaultValue${F}`] || i.defaultValue;
|
|
347
347
|
let b = c;
|
|
348
|
-
I && !c &&
|
|
349
|
-
const
|
|
350
|
-
if (I && b &&
|
|
348
|
+
I && !c && E && (b = w);
|
|
349
|
+
const Ne = de(b), Te = Object.prototype.toString.apply(b);
|
|
350
|
+
if (I && b && Ne && P.indexOf(Te) < 0 && !(g(C) && Array.isArray(b))) {
|
|
351
351
|
if (!i.returnObjects && !this.options.returnObjects) {
|
|
352
352
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
353
353
|
const k = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({}, i), {
|
|
@@ -360,7 +360,7 @@ class Z extends X {
|
|
|
360
360
|
for (const N in b)
|
|
361
361
|
if (Object.prototype.hasOwnProperty.call(b, N)) {
|
|
362
362
|
const j = `${te}${a}${N}`;
|
|
363
|
-
|
|
363
|
+
E && !c ? R[N] = this.translate(j, O(p({}, i), {
|
|
364
364
|
defaultValue: de(w) ? w[N] : void 0,
|
|
365
365
|
joinArrays: !1,
|
|
366
366
|
ns: l
|
|
@@ -375,8 +375,8 @@ class Z extends X {
|
|
|
375
375
|
c = c.join(C), c && (c = this.extendTranslation(c, e, i, s));
|
|
376
376
|
else {
|
|
377
377
|
let k = !1, R = !1;
|
|
378
|
-
!this.isValidLookup(c) &&
|
|
379
|
-
const N = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : c, j =
|
|
378
|
+
!this.isValidLookup(c) && E && (k = !0, c = w), this.isValidLookup(c) || (R = !0, c = o);
|
|
379
|
+
const N = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : c, j = E && w !== c && this.options.updateMissing;
|
|
380
380
|
if (R || k || j) {
|
|
381
381
|
if (this.logger.log(j ? "updateKey" : "missingKey", h, u, o, j ? w : c), a) {
|
|
382
382
|
const v = this.resolve(o, O(p({}, i), {
|
|
@@ -392,7 +392,7 @@ class Z extends X {
|
|
|
392
392
|
else this.options.saveMissingTo === "all" ? U = this.languageUtils.toResolveHierarchy(i.lng || this.language) : U.push(i.lng || this.language);
|
|
393
393
|
const se = (v, D, M) => {
|
|
394
394
|
var ne;
|
|
395
|
-
const ie =
|
|
395
|
+
const ie = E && M !== c ? M : N;
|
|
396
396
|
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u, D, ie, j, i) : (ne = this.backendConnector) != null && ne.saveMissing && this.backendConnector.saveMissing(v, u, D, ie, j, i), this.emit("missingKey", v, u, D, c);
|
|
397
397
|
};
|
|
398
398
|
this.options.saveMissing && (this.options.saveMissingPlurals && L ? U.forEach((v) => {
|
|
@@ -455,17 +455,17 @@ class Z extends X {
|
|
|
455
455
|
if ((_ = this.i18nFormat) != null && _.addLookupKeys)
|
|
456
456
|
this.i18nFormat.addLookupKeys(L, f, I, S, t);
|
|
457
457
|
else {
|
|
458
|
-
let
|
|
459
|
-
m && (
|
|
458
|
+
let F;
|
|
459
|
+
m && (F = this.pluralResolver.getSuffix(I, t.count, t));
|
|
460
460
|
const K = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
461
|
-
if (m && (L.push(f +
|
|
461
|
+
if (m && (L.push(f + F), t.ordinal && F.indexOf(w) === 0 && L.push(f + F.replace(w, this.options.pluralSeparator)), d && L.push(f + K)), c) {
|
|
462
462
|
const b = `${f}${this.options.contextSeparator}${t.context}`;
|
|
463
|
-
L.push(b), m && (L.push(b +
|
|
463
|
+
L.push(b), m && (L.push(b + F), t.ordinal && F.indexOf(w) === 0 && L.push(b + F.replace(w, this.options.pluralSeparator)), d && L.push(b + K));
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
let
|
|
467
|
-
for (;
|
|
468
|
-
this.isValidLookup(s) || (n =
|
|
466
|
+
let E;
|
|
467
|
+
for (; E = L.pop(); )
|
|
468
|
+
this.isValidLookup(s) || (n = E, s = this.getResource(I, S, E, t));
|
|
469
469
|
}));
|
|
470
470
|
});
|
|
471
471
|
}), {
|
|
@@ -578,7 +578,7 @@ const ge = {
|
|
|
578
578
|
pluralCategories: ["one", "other"]
|
|
579
579
|
})
|
|
580
580
|
};
|
|
581
|
-
class
|
|
581
|
+
class Ye {
|
|
582
582
|
constructor(e, t = {}) {
|
|
583
583
|
this.languageUtils = e, this.options = t, this.logger = T.create("pluralResolver"), this.pluralRulesCache = {};
|
|
584
584
|
}
|
|
@@ -626,10 +626,10 @@ class _e {
|
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
const xe = (r, e, t, s = ".", i = !0) => {
|
|
629
|
-
let n =
|
|
629
|
+
let n = Ue(r, e, t);
|
|
630
630
|
return !n && i && g(t) && (n = ee(r, t, s), n === void 0 && (n = ee(e, t, s))), n;
|
|
631
631
|
}, q = (r) => r.replace(/\$/g, "$$$$");
|
|
632
|
-
class
|
|
632
|
+
class Qe {
|
|
633
633
|
constructor(e = {}) {
|
|
634
634
|
var t;
|
|
635
635
|
this.logger = T.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((s) => s), this.init(e);
|
|
@@ -657,7 +657,7 @@ class We {
|
|
|
657
657
|
maxReplaces: P,
|
|
658
658
|
alwaysFormat: C
|
|
659
659
|
} = e.interpolation;
|
|
660
|
-
this.escape = t !== void 0 ? t :
|
|
660
|
+
this.escape = t !== void 0 ? t : He, this.escapeValue = s !== void 0 ? s : !0, this.useRawValueToEscape = i !== void 0 ? i : !1, this.prefix = n ? V(n) : a || "{{", this.suffix = o ? V(o) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = f ? "" : h || "-", this.unescapeSuffix = this.unescapePrefix ? "" : f || "", this.nestingPrefix = m ? V(m) : d || V("$t("), this.nestingSuffix = c ? V(c) : x || V(")"), this.nestingOptionsSeparator = S || ",", this.maxReplaces = P || 1e3, this.alwaysFormat = C !== void 0 ? C : !1, this.resetRegExp();
|
|
661
661
|
}
|
|
662
662
|
reset() {
|
|
663
663
|
this.options && this.init(this.options);
|
|
@@ -740,7 +740,7 @@ class We {
|
|
|
740
740
|
return e;
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
|
-
const
|
|
743
|
+
const Ge = (r) => {
|
|
744
744
|
let e = r.toLowerCase().trim();
|
|
745
745
|
const t = {};
|
|
746
746
|
if (r.indexOf("(") > -1) {
|
|
@@ -769,8 +769,8 @@ const Ye = (r) => {
|
|
|
769
769
|
let o = e[a];
|
|
770
770
|
return o || (o = r(z(s), i), e[a] = o), o(t);
|
|
771
771
|
};
|
|
772
|
-
},
|
|
773
|
-
class
|
|
772
|
+
}, Ze = (r) => (e, t, s) => r(z(t), s)(e);
|
|
773
|
+
class Xe {
|
|
774
774
|
constructor(e = {}) {
|
|
775
775
|
this.logger = T.create("formatter"), this.options = e, this.init(e);
|
|
776
776
|
}
|
|
@@ -778,7 +778,7 @@ class Ge {
|
|
|
778
778
|
interpolation: {}
|
|
779
779
|
}) {
|
|
780
780
|
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
781
|
-
const s = t.cacheInBuiltFormats ? ye :
|
|
781
|
+
const s = t.cacheInBuiltFormats ? ye : Ze;
|
|
782
782
|
this.formats = {
|
|
783
783
|
number: s((i, n) => {
|
|
784
784
|
const a = new Intl.NumberFormat(i, p({}, n));
|
|
@@ -821,7 +821,7 @@ class Ge {
|
|
|
821
821
|
const {
|
|
822
822
|
formatName: u,
|
|
823
823
|
formatOptions: f
|
|
824
|
-
} =
|
|
824
|
+
} = Ge(l);
|
|
825
825
|
if (this.formats[u]) {
|
|
826
826
|
let m = o;
|
|
827
827
|
try {
|
|
@@ -837,10 +837,10 @@ class Ge {
|
|
|
837
837
|
}, e);
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
const
|
|
840
|
+
const qe = (r, e) => {
|
|
841
841
|
r.pending[e] !== void 0 && (delete r.pending[e], r.pendingCount--);
|
|
842
842
|
};
|
|
843
|
-
class
|
|
843
|
+
class et extends X {
|
|
844
844
|
constructor(e, t, s, i = {}) {
|
|
845
845
|
var n, a;
|
|
846
846
|
super(), this.backend = e, this.store = t, this.services = s, this.languageUtils = s.languageUtils, this.options = i, this.logger = T.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = i.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = i.maxRetries >= 0 ? i.maxRetries : 5, this.retryTimeout = i.retryTimeout >= 1 ? i.retryTimeout : 350, this.state = {}, this.queue = [], (a = (n = this.backend) == null ? void 0 : n.init) == null || a.call(n, s, i.backend, i);
|
|
@@ -873,7 +873,7 @@ class Xe extends X {
|
|
|
873
873
|
}), this.state[e] = t ? -1 : 2, t && s && (this.state[e] = 0);
|
|
874
874
|
const o = {};
|
|
875
875
|
this.queue.forEach((l) => {
|
|
876
|
-
|
|
876
|
+
Ke(l.loaded, [n], a), qe(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
|
|
877
877
|
o[u] || (o[u] = {});
|
|
878
878
|
const f = l.loaded[u];
|
|
879
879
|
f.length && f.forEach((h) => {
|
|
@@ -1032,7 +1032,7 @@ const Se = () => ({
|
|
|
1032
1032
|
var e, t;
|
|
1033
1033
|
return g(r.ns) && (r.ns = [r.ns]), g(r.fallbackLng) && (r.fallbackLng = [r.fallbackLng]), g(r.fallbackNS) && (r.fallbackNS = [r.fallbackNS]), ((t = (e = r.supportedLngs) == null ? void 0 : e.indexOf) == null ? void 0 : t.call(e, "cimode")) < 0 && (r.supportedLngs = r.supportedLngs.concat(["cimode"])), typeof r.initImmediate == "boolean" && (r.initAsync = r.initImmediate), r;
|
|
1034
1034
|
}, Y = () => {
|
|
1035
|
-
},
|
|
1035
|
+
}, tt = (r) => {
|
|
1036
1036
|
Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach((t) => {
|
|
1037
1037
|
typeof r[t] == "function" && (r[t] = r[t].bind(r));
|
|
1038
1038
|
});
|
|
@@ -1041,7 +1041,7 @@ class J extends X {
|
|
|
1041
1041
|
constructor(e = {}, t) {
|
|
1042
1042
|
if (super(), this.options = be(e), this.services = {}, this.logger = T, this.modules = {
|
|
1043
1043
|
external: []
|
|
1044
|
-
},
|
|
1044
|
+
}, tt(this), t && !this.isInitialized && !e.isClone) {
|
|
1045
1045
|
if (!this.options.initAsync)
|
|
1046
1046
|
return this.init(e, t), this;
|
|
1047
1047
|
setTimeout(() => {
|
|
@@ -1057,16 +1057,16 @@ class J extends X {
|
|
|
1057
1057
|
if (!this.options.isClone) {
|
|
1058
1058
|
this.modules.logger ? T.init(i(this.modules.logger), this.options) : T.init(null, this.options);
|
|
1059
1059
|
let u;
|
|
1060
|
-
this.modules.formatter ? u = this.modules.formatter : u =
|
|
1060
|
+
this.modules.formatter ? u = this.modules.formatter : u = Xe;
|
|
1061
1061
|
const f = new pe(this.options);
|
|
1062
1062
|
this.store = new fe(this.options.resources, this.options);
|
|
1063
1063
|
const h = this.services;
|
|
1064
|
-
h.logger = T, h.resourceStore = this.store, h.languageUtils = f, h.pluralResolver = new
|
|
1064
|
+
h.logger = T, h.resourceStore = this.store, h.languageUtils = f, h.pluralResolver = new Ye(f, {
|
|
1065
1065
|
prepend: this.options.pluralSeparator,
|
|
1066
1066
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1067
|
-
}), this.options.interpolation.format && this.options.interpolation.format !== s.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === s.interpolation.format) && (h.formatter = i(u), h.formatter.init && h.formatter.init(h, this.options), this.options.interpolation.format = h.formatter.format.bind(h.formatter)), h.interpolator = new
|
|
1067
|
+
}), this.options.interpolation.format && this.options.interpolation.format !== s.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === s.interpolation.format) && (h.formatter = i(u), h.formatter.init && h.formatter.init(h, this.options), this.options.interpolation.format = h.formatter.format.bind(h.formatter)), h.interpolator = new Qe(this.options), h.utils = {
|
|
1068
1068
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1069
|
-
}, h.backendConnector = new
|
|
1069
|
+
}, h.backendConnector = new et(i(this.modules.backend), h.resourceStore, h, this.options), h.backendConnector.on("*", (d, ...c) => {
|
|
1070
1070
|
this.emit(d, ...c);
|
|
1071
1071
|
}), this.modules.languageDetector && (h.languageDetector = i(this.modules.languageDetector), h.languageDetector.init && h.languageDetector.init(h, this.options.detection, this.options)), this.modules.i18nFormat && (h.i18nFormat = i(this.modules.i18nFormat), h.i18nFormat.init && h.i18nFormat.init(this)), this.translator = new Z(this.services, this.options), this.translator.on("*", (d, ...c) => {
|
|
1072
1072
|
this.emit(d, ...c);
|
|
@@ -1268,45 +1268,50 @@ y.setDefaultNamespace;
|
|
|
1268
1268
|
y.hasLoadedNamespace;
|
|
1269
1269
|
y.loadNamespaces;
|
|
1270
1270
|
y.loadLanguages;
|
|
1271
|
-
const
|
|
1271
|
+
const st = (r) => {
|
|
1272
|
+
let e = "";
|
|
1273
|
+
return r.childNodes.forEach((t) => {
|
|
1274
|
+
t.nodeType === 3 && (e += t.nodeValue);
|
|
1275
|
+
}), e.trim();
|
|
1276
|
+
}, $e = (r, e) => {
|
|
1277
|
+
let t = !1;
|
|
1278
|
+
r.childNodes.forEach((s) => {
|
|
1279
|
+
if (s.nodeType !== 3)
|
|
1280
|
+
return;
|
|
1281
|
+
const i = (s.nodeValue || "").trim();
|
|
1282
|
+
i && (s.nodeValue = t ? "" : s.nodeValue.replace(i, () => e), t = !0);
|
|
1283
|
+
});
|
|
1284
|
+
}, Pe = (r) => {
|
|
1285
|
+
if (r.attr("data-i18n"))
|
|
1286
|
+
return;
|
|
1287
|
+
const e = r.get(0);
|
|
1288
|
+
if (!e)
|
|
1289
|
+
return;
|
|
1290
|
+
const t = st(e);
|
|
1291
|
+
t && (r.attr({
|
|
1292
|
+
"data-i18n": t
|
|
1293
|
+
}), $e(e, y.t(t)));
|
|
1294
|
+
const s = r.attr("placeholder");
|
|
1295
|
+
s && (r.attr({
|
|
1296
|
+
"data-i18n": "[placeholder]" + s
|
|
1297
|
+
}), r.attr({
|
|
1298
|
+
placeholder: y.t(s)
|
|
1299
|
+
}));
|
|
1300
|
+
}, it = (r, e) => {
|
|
1272
1301
|
for (const t of e) {
|
|
1273
1302
|
const s = r.find(t);
|
|
1274
1303
|
s && s.each((i, n) => {
|
|
1275
|
-
|
|
1276
|
-
if (a.attr("data-i18n"))
|
|
1277
|
-
return;
|
|
1278
|
-
const o = a.text().trim();
|
|
1279
|
-
o && (a.attr({
|
|
1280
|
-
"data-i18n": o
|
|
1281
|
-
}), a.text(y.t(o)));
|
|
1282
|
-
const l = a.attr("placeholder");
|
|
1283
|
-
l && (a.attr({
|
|
1284
|
-
"data-i18n": "[placeholder]" + l
|
|
1285
|
-
}), a.attr({
|
|
1286
|
-
placeholder: y.t(l)
|
|
1287
|
-
}));
|
|
1304
|
+
Pe($(n));
|
|
1288
1305
|
});
|
|
1289
1306
|
}
|
|
1290
1307
|
}, A = (r) => {
|
|
1291
1308
|
for (const e of r) {
|
|
1292
1309
|
const t = $(e);
|
|
1293
1310
|
t && t.each((s, i) => {
|
|
1294
|
-
|
|
1295
|
-
if (n.attr("data-i18n"))
|
|
1296
|
-
return;
|
|
1297
|
-
const a = n.text().trim();
|
|
1298
|
-
a && (n.attr({
|
|
1299
|
-
"data-i18n": a
|
|
1300
|
-
}), n.text(y.t(a)));
|
|
1301
|
-
const o = n.attr("placeholder");
|
|
1302
|
-
o && (n.attr({
|
|
1303
|
-
"data-i18n": "[placeholder]" + o
|
|
1304
|
-
}), n.attr({
|
|
1305
|
-
placeholder: y.t(o)
|
|
1306
|
-
}));
|
|
1311
|
+
Pe($(i));
|
|
1307
1312
|
});
|
|
1308
1313
|
}
|
|
1309
|
-
},
|
|
1314
|
+
}, Re = [
|
|
1310
1315
|
".hiprint-option-item-label",
|
|
1311
1316
|
"textarea",
|
|
1312
1317
|
"input",
|
|
@@ -1321,13 +1326,13 @@ const et = (r, e) => {
|
|
|
1321
1326
|
".hiprint-multiselect-trigger .hiprint-multiselect-text",
|
|
1322
1327
|
".hiprint-multiselect-item span",
|
|
1323
1328
|
".hiprint-multiselect-actions button"
|
|
1324
|
-
],
|
|
1325
|
-
|
|
1326
|
-
},
|
|
1329
|
+
], nt = (r, e, t = Re) => {
|
|
1330
|
+
it(e, t);
|
|
1331
|
+
}, ke = (r = "[data-i18n]") => {
|
|
1327
1332
|
document.querySelectorAll(r).forEach((e) => {
|
|
1328
1333
|
const t = e.getAttribute("data-i18n");
|
|
1329
1334
|
if (!t.includes("[")) {
|
|
1330
|
-
e
|
|
1335
|
+
$e(e, y.t(t));
|
|
1331
1336
|
return;
|
|
1332
1337
|
}
|
|
1333
1338
|
const s = t.match(/\[([^\]]+)\](.+)/);
|
|
@@ -1345,19 +1350,19 @@ const Oe = (r) => {
|
|
|
1345
1350
|
const e = Object.keys(r.resources || {});
|
|
1346
1351
|
globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t, s) => {
|
|
1347
1352
|
y.changeLanguage(t, (i, n) => {
|
|
1348
|
-
s && s(i, n),
|
|
1353
|
+
s && s(i, n), ke();
|
|
1349
1354
|
});
|
|
1350
1355
|
};
|
|
1351
1356
|
}, we = (r) => {
|
|
1352
1357
|
setTimeout(() => {
|
|
1353
|
-
|
|
1358
|
+
ke(".printSetting .hiprint-multiselect [data-i18n]"), $(".printSetting .hiprint-multiselect").length && $(".printSetting .hiprint-multiselect-trigger").off("click.multiselect-trigger").on("click.multiselect-trigger", () => {
|
|
1354
1359
|
console.log("click multiselect"), setTimeout(() => {
|
|
1355
|
-
A((r == null ? void 0 : r.optionsSelectorList) ||
|
|
1360
|
+
A((r == null ? void 0 : r.optionsSelectorList) || Re);
|
|
1356
1361
|
}, 0);
|
|
1357
1362
|
});
|
|
1358
1363
|
}, 0);
|
|
1359
1364
|
};
|
|
1360
|
-
function
|
|
1365
|
+
function at(r, e) {
|
|
1361
1366
|
y.init(p({}, r), (s, i) => {
|
|
1362
1367
|
e && e(y, i, s);
|
|
1363
1368
|
});
|
|
@@ -1387,7 +1392,7 @@ function it(r, e) {
|
|
|
1387
1392
|
const i = s.createTarget;
|
|
1388
1393
|
s.createTarget = function(...n) {
|
|
1389
1394
|
const a = i.call(s, ...n);
|
|
1390
|
-
return t.indexOf(s.name) !== -1 && a.attr("data-name") || (a.attr({ "data-name": s.name }),
|
|
1395
|
+
return t.indexOf(s.name) !== -1 && a.attr("data-name") || (a.attr({ "data-name": s.name }), nt(s, a, r == null ? void 0 : r.optionsSelectorList)), a;
|
|
1391
1396
|
};
|
|
1392
1397
|
}
|
|
1393
1398
|
return t.indexOf(s.name) === -1 && t.push(s.name), s;
|
|
@@ -1451,6 +1456,6 @@ function it(r, e) {
|
|
|
1451
1456
|
};
|
|
1452
1457
|
}
|
|
1453
1458
|
export {
|
|
1454
|
-
|
|
1459
|
+
at as default,
|
|
1455
1460
|
A as translateBySelector
|
|
1456
1461
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(b,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(b=typeof globalThis!="undefined"?globalThis:b||self,d(b.pluginI18n={}))})(this,function(b){"use strict";var qe=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var $e=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var Re=(b,d,L)=>d in b?qe(b,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):b[d]=L,g=(b,d)=>{for(var L in d||(d={}))st.call(d,L)&&Re(b,L,d[L]);if($e)for(var L of $e(d))it.call(d,L)&&Re(b,L,d[L]);return b},v=(b,d)=>et(b,tt(d));const d=r=>typeof r=="string",L=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},se=r=>r==null?"":""+r,ke=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},Ne=/###/g,ie=r=>r&&r.indexOf("###")>-1?r.replace(Ne,"."):r,ne=r=>!r||d(r),U=(r,e,t)=>{const s=d(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(ne(r))return{};const n=ie(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return ne(r)?{}:{obj:r,k:ie(s[i])}},re=(r,e,t)=>{const{obj:s,k:i}=U(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],a=e.slice(0,e.length-1),o=U(r,a,Object);for(;o.obj===void 0&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),o=U(r,a,Object),o!=null&&o.obj&&typeof o.obj[`${o.k}.${n}`]!="undefined"&&(o.obj=void 0);o.obj[`${o.k}.${n}`]=t},Te=(r,e,t,s)=>{const{obj:i,k:n}=U(r,e,Object);i[n]=i[n]||[],i[n].push(t)},W=(r,e)=>{const{obj:t,k:s}=U(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},Fe=(r,e,t)=>{const s=W(r,t);return s!==void 0?s:W(e,t)},ae=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?d(r[s])||r[s]instanceof String||d(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):ae(r[s],e[s],t):r[s]=e[s]);return r},M=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ee={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const je=r=>d(r)?r.replace(/[&<>"'\/]/g,e=>Ee[e]):r;class Ie{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)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}}const De=[" ",",","?","!",";"],Ve=new Ie(20),Ae=(r,e,t)=>{e=e||"",t=t||"";const s=De.filter(a=>e.indexOf(a)<0&&t.indexOf(a)<0);if(s.length===0)return!0;const i=Ve.getRegExp(`(${s.map(a=>a==="?"?"\\?":a).join("|")})`);let n=!i.test(r);if(!n){const a=r.indexOf(t);a>0&&!i.test(r.substring(0,a))&&(n=!0)}return n},ee=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=n;l<s.length;++l)if(l!==n&&(o+=t),o+=s[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=a}return i},H=r=>r==null?void 0:r.replace("_","-"),Ke={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){var t,s;(s=(t=console==null?void 0:console[r])==null?void 0:t.apply)==null||s.call(t,console,e)}};class Y{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Ke,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,s,i){return i&&!this.debug?null:(d(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Y(this.logger,g({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Y(this.logger,e)}}var T=new Y;class Q{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i.apply(i,[e,...t])})}}class oe extends Q{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(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,s,i={}){var u,f;const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],s&&(Array.isArray(s)?o.push(...s):d(s)&&n?o.push(...s.split(n)):o.push(s)));const l=W(this.data,o);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=o[0],t=o[1],s=o.slice(2).join(".")),l||!a||!d(s)?l:ee((f=(u=this.data)==null?void 0:u[e])==null?void 0:f[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=[e,t];s&&(o=o.concat(a?s.split(a):s)),e.indexOf(".")>-1&&(o=e.split("."),i=t,t=o[1]),this.addNamespaces(t),re(this.data,o,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(d(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),i=s,s=t,t=o[1]),this.addNamespaces(t);let l=W(this.data,o)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?ae(l,s,n):l=g(g({},l),s),re(this.data,o,l),a.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 this.getResource(e,t)!==void 0}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(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var le={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{var a,o;e=(o=(a=this.processors[n])==null?void 0:a.process(e,t,s,i))!=null?o:e}),e}};const ue={},he=r=>!d(r)&&typeof r!="boolean"&&typeof r!="number";class G extends Q{constructor(e,t={}){super(),ke(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=T.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s=g({},t);if(e==null)return!1;const i=this.resolve(e,s);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const a=s&&e.indexOf(s)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ae(e,s,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:d(n)?[n]:n};const u=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(i)}return{key:e,namespaces:d(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?g({},t):t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(i=g({},i)),i||(i={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),u=l[l.length-1];let f=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const h=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((h==null?void 0:h.toLowerCase())==="cimode")return m?n?{res:`${u}${f}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${f}${o}`:n?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const p=this.resolve(e,i);let c=p==null?void 0:p.res;const x=(p==null?void 0:p.usedKey)||o,S=(p==null?void 0:p.exactUsedKey)||o,k=["[object Number]","[object Function]","[object RegExp]"],R=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,V=!this.i18nFormat||this.i18nFormat.handleAsObject,w=i.count!==void 0&&!d(i.count),j=G.hasDefaultValue(i),X=w?this.pluralResolver.getSuffix(h,i.count,i):"",I=i.ordinal&&w?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",z=w&&!i.ordinal&&i.count===0,C=z&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${X}`]||i[`defaultValue${I}`]||i.defaultValue;let O=c;V&&!c&&j&&(O=C);const Ze=he(O),Xe=Object.prototype.toString.apply(O);if(V&&O&&Ze&&k.indexOf(Xe)<0&&!(d(R)&&Array.isArray(O))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const F=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,O,v(g({},i),{ns:l})):`key '${o} (${this.language})' returned an object instead of string.`;return n?(p.res=F,p.usedParams=this.getUsedParamsDetails(i),p):F}if(a){const F=Array.isArray(O),N=F?[]:{},we=F?S:x;for(const E in O)if(Object.prototype.hasOwnProperty.call(O,E)){const D=`${we}${a}${E}`;j&&!c?N[E]=this.translate(D,v(g({},i),{defaultValue:he(C)?C[E]:void 0,joinArrays:!1,ns:l})):N[E]=this.translate(D,v(g({},i),{joinArrays:!1,ns:l})),N[E]===D&&(N[E]=O[E])}c=N}}else if(V&&d(R)&&Array.isArray(c))c=c.join(R),c&&(c=this.extendTranslation(c,e,i,s));else{let F=!1,N=!1;!this.isValidLookup(c)&&j&&(F=!0,c=C),this.isValidLookup(c)||(N=!0,c=o);const E=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:c,D=j&&C!==c&&this.options.updateMissing;if(N||F||D){if(this.logger.log(D?"updateKey":"missingKey",h,u,o,D?C:c),a){const P=this.resolve(o,v(g({},i),{keySeparator:!1}));P&&P.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 J=[];const q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&q&&q[0])for(let P=0;P<q.length;P++)J.push(q[P]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const ve=(P,K,_)=>{var Pe;const Ce=j&&_!==c?_:E;this.options.missingKeyHandler?this.options.missingKeyHandler(P,u,K,Ce,D,i):(Pe=this.backendConnector)!=null&&Pe.saveMissing&&this.backendConnector.saveMissing(P,u,K,Ce,D,i),this.emit("missingKey",P,u,K,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?J.forEach(P=>{const K=this.pluralResolver.getSuffixes(P,i);z&&i[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(_=>{ve([P],o+_,i[`defaultValue${_}`]||C)})}):ve(J,o,C))}c=this.extendTranslation(c,e,i,p,s),N&&c===o&&this.options.appendNamespaceToMissingKey&&(c=`${u}${f}${o}`),(N||F)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${f}${o}`:o,F?c:void 0,i))}return n?(p.res=c,p.usedParams=this.getUsedParamsDetails(i),p):c}extendTranslation(e,t,s,i,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,g(g({},this.options.interpolation.defaultVariables),s),s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(v(g({},s),{interpolation:g(g({},this.options.interpolation),s.interpolation)}));const f=d(e)&&(((u=s==null?void 0:s.interpolation)==null?void 0:u.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(f){const p=e.match(this.interpolator.nestingRegexp);h=p&&p.length}let m=s.replace&&!d(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(m=g(g({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,s.lng||this.language||i.usedLng,s),f){const p=e.match(this.interpolator.nestingRegexp),c=p&&p.length;h<c&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...p)=>(n==null?void 0:n[0])===p[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`),null):this.translate(...p,t),s)),s.interpolation&&this.interpolator.reset()}const a=s.postProcess||this.options.postProcess,o=d(a)?[a]:a;return e!=null&&(o!=null&&o.length)&&s.applyPostProcessor!==!1&&(e=le.handle(o,e,t,this.options&&this.options.postProcessPassResolved?g({i18nResolved:v(g({},i),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),e}resolve(e,t={}){let s,i,n,a,o;return d(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(l,t),f=u.key;i=f;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=t.count!==void 0&&!d(t.count),p=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(d(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);h.forEach(S=>{var k,R;this.isValidLookup(s)||(o=S,!ue[`${x[0]}-${S}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((R=this.utils)!=null&&R.hasLoadedNamespace(o))&&(ue[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${x.join(", ")}" won't get resolved as namespace "${o}" 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!!!")),x.forEach(V=>{var X;if(this.isValidLookup(s))return;a=V;const w=[f];if((X=this.i18nFormat)!=null&&X.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,V,S,t);else{let I;m&&(I=this.pluralResolver.getSuffix(V,t.count,t));const z=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(w.push(f+I),t.ordinal&&I.indexOf(C)===0&&w.push(f+I.replace(C,this.options.pluralSeparator)),p&&w.push(f+z)),c){const O=`${f}${this.options.contextSeparator}${t.context}`;w.push(O),m&&(w.push(O+I),t.ordinal&&I.indexOf(C)===0&&w.push(O+I.replace(C,this.options.pluralSeparator)),p&&w.push(O+z))}}let j;for(;j=w.pop();)this.isValidLookup(s)||(n=j,s=this.getResource(V,S,j,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!d(e.replace);let i=s?e.replace:e;if(s&&typeof e.count!="undefined"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i=g(g({},this.options.interpolation.defaultVariables),i)),!s){i=g({},i);for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}}class fe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=T.create("languageUtils")}getScriptPartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(d(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(s){}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(this.options.load==="languageOnly"||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(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(a=>{if(a===n)return a;if(!(a.indexOf("-")<0&&n.indexOf("-")<0)&&(a.indexOf("-")>0&&n.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===n||a.indexOf(n)===0&&n.length>1))return a})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),d(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return d(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):d(e)&&n(this.formatLanguageCode(e)),s.forEach(a=>{i.indexOf(a)<0&&n(this.formatLanguageCode(a))}),i}}const ce={zero:0,one:1,two:2,few:3,many:4,other:5},de={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Me{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=T.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=H(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let a;try{a=new Intl.PluralRules(s,{type:i})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),de;if(!e.match(/-|_/))return de;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,t)}return this.pluralRulesCache[n]=a,a}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>ce[i]-ce[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const pe=(r,e,t,s=".",i=!0)=>{let n=Fe(r,e,t);return!n&&i&&d(t)&&(n=ee(r,t,s),n===void 0&&(n=ee(e,t,s))),n},te=r=>r.replace(/\$/g,"$$$$");class Ue{constructor(e={}){var t;this.logger=T.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(s=>s),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:u,unescapeSuffix:f,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:k,alwaysFormat:R}=e.interpolation;this.escape=t!==void 0?t:je,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?M(n):a||"{{",this.suffix=o?M(o):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?M(m):p||M("$t("),this.nestingSuffix=c?M(c):x||M(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=k||1e3,this.alwaysFormat=R!==void 0?R:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>(t==null?void 0:t.source)===s?(t.lastIndex=0,t):new RegExp(s,"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,s,i){var p;let n,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const R=pe(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(R,void 0,s,v(g(g({},i),t),{interpolationkey:c})):R}const x=c.split(this.formatSeparator),S=x.shift().trim(),k=x.join(this.formatSeparator).trim();return this.format(pe(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),k,s,v(g(g({},i),t),{interpolationkey:S}))};this.resetRegExp();const f=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((p=i==null?void 0:i.interpolation)==null?void 0:p.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>te(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?te(this.escape(c)):te(c)}].forEach(c=>{for(o=0;n=c.regex.exec(e);){const x=n[1].trim();if(a=u(x),a===void 0)if(typeof f=="function"){const k=f(e,n,i);a=d(k)?k:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(h){a=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!d(a)&&!this.useRawValueToEscape&&(a=se(a));const S=c.safeValue(a);if(e=e.replace(n[0],S),h?(c.regex.lastIndex+=a.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,a;const o=(l,u)=>{var x;const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const h=l.split(new RegExp(`${f}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,a);const p=m.match(/'/g),c=m.match(/"/g);(((x=p==null?void 0:p.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),u&&(a=g(g({},u),a))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${f}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a=g({},s),a=a.replace&&!d(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(l=i[1].slice(u).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),n=t(o.call(this,i[1].trim(),a),a),n&&i[0]===e&&!d(n))return n;d(n)||(n=se(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((f,h)=>this.format(f,h,s.lng,v(g({},s),{interpolationkey:i[1].trim()})),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const He=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),f=o.trim();t[f]||(t[f]=u),u==="false"&&(t[f]=!1),u==="true"&&(t[f]=!0),isNaN(u)||(t[f]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},ge=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n=v(g({},n),{[i.interpolationkey]:void 0}));const a=s+JSON.stringify(n);let o=e[a];return o||(o=r(H(s),i),e[a]=o),o(t)}},Be=r=>(e,t,s)=>r(H(t),s)(e);class ze{constructor(e={}){this.logger=T.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?ge:Be;this.formats={number:s((i,n)=>{const a=new Intl.NumberFormat(i,g({},n));return o=>a.format(o)}),currency:s((i,n)=>{const a=new Intl.NumberFormat(i,v(g({},n),{style:"currency"}));return o=>a.format(o)}),datetime:s((i,n)=>{const a=new Intl.DateTimeFormat(i,g({},n));return o=>a.format(o)}),relativetime:s((i,n)=>{const a=new Intl.RelativeTimeFormat(i,g({},n));return o=>a.format(o,n.range||"day")}),list:s((i,n)=>{const a=new Intl.ListFormat(i,g({},n));return o=>a.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ge(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(o=>o.indexOf(")")>-1)){const o=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,o)].join(this.formatSeparator)}return n.reduce((o,l)=>{var h;const{formatName:u,formatOptions:f}=He(l);if(this.formats[u]){let m=o;try{const p=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},c=p.locale||p.lng||i.locale||i.lng||s;m=this.formats[u](o,c,g(g(g({},f),i),p))}catch(p){this.logger.warn(p)}return m}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const Je=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class _e extends Q{constructor(e,t,s,i={}){var n,a;super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=T.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(n=this.backend)==null?void 0:n.init)==null||a.call(n,s,i.backend,i)}queueLoad(e,t,s,i){const n={},a={},o={},l={};return e.forEach(u=>{let f=!0;t.forEach(h=>{const m=`${u}|${h}`;!s.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,f=!1,a[m]===void 0&&(a[m]=!0),n[m]===void 0&&(n[m]=!0),l[h]===void 0&&(l[h]=!0)))}),f||(o[u]=!0)}),(Object.keys(n).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],a=i[1];t&&this.emit("failedLoading",n,a,t),!t&&s&&this.store.addResourceBundle(n,a,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Te(l.loaded,[n],a),Je(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{o[u]||(o[u]={});const f=l.loaded[u];f.length&&f.forEach(h=>{o[u][h]===void 0&&(o[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:a});return}this.readingCalls++;const o=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,a)},n);return}a(u,f)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(f=>o(null,f)).catch(o):o(null,u)}catch(u){o(u)}return}return l(e,t,o)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();d(e)&&(e=this.languageUtils.toResolveHierarchy(e)),d(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(a=>{this.loadOne(a)})}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("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,a),!a&&o&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,t,s,i,n,a={},o=()=>{}){var l,u,f,h,m;if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(f=this.services)==null?void 0:f.utils)!=null&&h.hasLoadedNamespace(t))){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!!!");return}if(!(s==null||s==="")){if((m=this.backend)!=null&&m.create){const p=v(g({},a),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,s,i,p):x=c(e,t,s,i),x&&typeof x.then=="function"?x.then(S=>o(null,S)).catch(o):o(null,x)}catch(x){o(x)}else c(e,t,s,i,o,p)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const me=()=>({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:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),d(r[1])&&(e.defaultValue=r[1]),d(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),xe=r=>{var e,t;return d(r.ns)&&(r.ns=[r.ns]),d(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),d(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),((t=(e=r.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r},Z=()=>{},We=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})};class B extends Q{constructor(e={},t){if(super(),this.options=xe(e),this.services={},this.logger=T,this.modules={external:[]},We(this),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,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(d(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=me();this.options=g(g(g({},s),this.options),xe(e)),this.options.interpolation=g(g({},s.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?T.init(i(this.modules.logger),this.options):T.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=ze;const f=new fe(this.options);this.store=new oe(this.options.resources,this.options);const h=this.services;h.logger=T,h.resourceStore=this.store,h.languageUtils=f,h.pluralResolver=new Me(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Ue(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new _e(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new G(this.services,this.options),this.translator.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...f)=>this.store[u](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...f)=>(this.store[u](...f),this)});const o=L(),l=()=>{const u=(f,h)=>{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),o.resolve(h),t(f,h)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,t=Z){var n,a;let s=t;const i=d(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const o=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&o.indexOf(h)<0&&o.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>l(f)),(a=(n=this.options.preload)==null?void 0:n.forEach)==null||a.call(n,u=>l(u)),this.services.backendConnector.load(o,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(e,t,s){const i=L();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=Z),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),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 e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&le.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;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 s=L();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},n=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...u)=>this.t(...u)),t&&t(o,(...u)=>this.t(...u))},a=o=>{var f,h;!e&&!o&&this.services.languageDetector&&(o=[]);const l=d(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(d(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),(h=(f=this.services.languageDetector)==null?void 0:f.cacheUserLanguage)==null||h.call(f,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),s}getFixedT(e,t,s){const i=(n,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([n,a].concat(o)):l=g({},a),l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const u=this.options.keySeparator||".";let f;return l.keyPrefix&&Array.isArray(n)?f=n.map(h=>`${l.keyPrefix}${u}${h}`):f=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(f,l)};return d(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.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],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const a=(o,l)=>{const u=this.services.backendConnector.state[`${o}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const o=t.precheck(this,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(s,e)&&(!i||a(n,e)))}loadNamespaces(e,t){const s=L();return this.options.ns?(d(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=L();d(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return n.length?(this.options.preload=i.concat(n),this.loadResources(a=>{s.resolve(),t&&t(a)}),s):(t&&t(),Promise.resolve())}dir(e){var i,n;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const o=a.getTextInfo();if(o&&o.direction)return o.direction}}catch(a){}const t=["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"],s=((n=this.services)==null?void 0:n.languageUtils)||new fe(me());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new B(e,t)}cloneInstance(e={},t=Z){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i=v(g(g({},this.options),e),{isClone:!0}),n=new B(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(o=>{n[o]=this[o]}),n.services=g({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const o=Object.keys(this.store.data).reduce((l,u)=>(l[u]=g({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((f,h)=>(f[h]=g({},l[u][h]),f),l[u]),l),{});n.store=new oe(o,i),n.services.resourceStore=n.store}return n.translator=new G(n.services,i),n.translator.on("*",(o,...l)=>{n.emit(o,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=B.createInstance();y.createInstance=B.createInstance,y.createInstance,y.dir,y.init,y.loadResources,y.reloadResources,y.use,y.changeLanguage,y.getFixedT,y.t,y.exists,y.setDefaultNamespace,y.hasLoadedNamespace,y.loadNamespaces,y.loadLanguages;const Ye=(r,e)=>{for(const t of e){const s=r.find(t);s&&s.each((i,n)=>{const a=$(n);if(a.attr("data-i18n"))return;const o=a.text().trim();o&&(a.attr({"data-i18n":o}),a.text(y.t(o)));const l=a.attr("placeholder");l&&(a.attr({"data-i18n":"[placeholder]"+l}),a.attr({placeholder:y.t(l)}))})}},A=r=>{for(const e of r){const t=$(e);t&&t.each((s,i)=>{const n=$(i);if(n.attr("data-i18n"))return;const a=n.text().trim();a&&(n.attr({"data-i18n":a}),n.text(y.t(a)));const o=n.attr("placeholder");o&&(n.attr({"data-i18n":"[placeholder]"+o}),n.attr({placeholder:y.t(o)}))})}},ye=[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc",".hiprint-multiselect-search",".hiprint-multiselect-custom-input",".hiprint-multiselect-trigger .hiprint-multiselect-text",".hiprint-multiselect-item span",".hiprint-multiselect-actions button"],Qe=(r,e,t=ye)=>{Ye(e,t)},Se=(r="[data-i18n]")=>{document.querySelectorAll(r).forEach(e=>{const t=e.getAttribute("data-i18n");if(!t.includes("[")){e.textContent=y.t(t);return}const s=t.match(/\[([^\]]+)\](.+)/);if(s&&s.length===3){const i=s[1],n=s[2];e.setAttribute(i,y.t(n))}})};let be=!1;const Le=r=>{if(be)return;be=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(r.resources||{});globalThis.hiprint.languages=["简体中文",...e],globalThis.hiprint.changeLanguage=(t,s)=>{y.changeLanguage(t,(i,n)=>{s&&s(i,n),Se()})}},Oe=r=>{setTimeout(()=>{Se(".printSetting .hiprint-multiselect [data-i18n]"),$(".printSetting .hiprint-multiselect").length&&$(".printSetting .hiprint-multiselect-trigger").off("click.multiselect-trigger").on("click.multiselect-trigger",()=>{console.log("click multiselect"),setTimeout(()=>{A((r==null?void 0:r.optionsSelectorList)||ye)},0)})},0)};function Ge(r,e){y.init(g({},r),(s,i)=>{e&&e(y,i,s)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"添加 i18n 方法",priority:1,run:()=>{Le(r)}},{hook:"getOptionItem",name:"i18n options",description:"渲染元素属性时做多语言处理",priority:1,run:s=>{if(s){if(!s._translationWrapped){s._translationWrapped=!0;const i=s.createTarget;s.createTarget=function(...n){const a=i.call(s,...n);return t.indexOf(s.name)!==-1&&a.attr("data-name")||(a.attr({"data-name":s.name}),Qe(s,a,r==null?void 0:r.optionsSelectorList)),a}}return t.indexOf(s.name)===-1&&t.push(s.name),s}}},{hook:"onDesigned",name:"i18n other selector",description:"其他UI选择器多语言处理",priority:9,run:({hiprint:s,designerUtils:i})=>{Le(r),setTimeout(()=>{var o;const n=(o=i.printTemplate)==null?void 0:o.id;n&&(r!=null&&r.onDesigned&&(r==null||r.onDesigned(i)),globalThis.hinnn.event.on("BuildCustomOptionSettingEventKey_"+n,l=>{r!=null&&r.onPanelSelected&&(r==null||r.onPanelSelected()),Oe(r)}),globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{A([".printSetting .prop-tab-items .tab-title"]),Oe(r),r!=null&&r.onElementSelected&&(r==null||r.onElementSelected(l))},0)}),$(".hiprint-printPaper.design").on("contextmenu",()=>{A([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),A([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onDesignedDelay)||600)}},{hook:"onSettings",name:"i18n settings",description:"设置选择器多语言处理",priority:1,run:s=>{s.type=="show"&&setTimeout(()=>{A([".settings-body .svp-tab"])},0),r!=null&&r.onSettings&&(r==null||r.onSettings(s))}},{hook:"onPreview",name:"i18n preview selector",description:"组件内预览选择器多语言处理",priority:1,run:s=>{setTimeout(()=>{A([".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onPreviewDelay)||0),r!=null&&r.onPreview&&(r==null||r.onPreview(s))}}],leastHiprintVersion:"0.1.28"}}b.default=Ge,b.translateBySelector=A,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(b,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(b=typeof globalThis!="undefined"?globalThis:b||self,d(b.pluginI18n={}))})(this,function(b){"use strict";var st=Object.defineProperty,it=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var rt=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var Ne=(b,d,L)=>d in b?st(b,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):b[d]=L,g=(b,d)=>{for(var L in d||(d={}))rt.call(d,L)&&Ne(b,L,d[L]);if(ke)for(var L of ke(d))at.call(d,L)&&Ne(b,L,d[L]);return b},v=(b,d)=>it(b,nt(d));const d=r=>typeof r=="string",L=()=>{let r,e;const t=new Promise((s,i)=>{r=s,e=i});return t.resolve=r,t.reject=e,t},se=r=>r==null?"":""+r,Te=(r,e,t)=>{r.forEach(s=>{e[s]&&(t[s]=e[s])})},Ee=/###/g,ie=r=>r&&r.indexOf("###")>-1?r.replace(Ee,"."):r,ne=r=>!r||d(r),U=(r,e,t)=>{const s=d(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(ne(r))return{};const n=ie(s[i]);!r[n]&&t&&(r[n]=new t),Object.prototype.hasOwnProperty.call(r,n)?r=r[n]:r={},++i}return ne(r)?{}:{obj:r,k:ie(s[i])}},re=(r,e,t)=>{const{obj:s,k:i}=U(r,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],a=e.slice(0,e.length-1),o=U(r,a,Object);for(;o.obj===void 0&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),o=U(r,a,Object),o!=null&&o.obj&&typeof o.obj[`${o.k}.${n}`]!="undefined"&&(o.obj=void 0);o.obj[`${o.k}.${n}`]=t},Fe=(r,e,t,s)=>{const{obj:i,k:n}=U(r,e,Object);i[n]=i[n]||[],i[n].push(t)},W=(r,e)=>{const{obj:t,k:s}=U(r,e);if(t&&Object.prototype.hasOwnProperty.call(t,s))return t[s]},je=(r,e,t)=>{const s=W(r,t);return s!==void 0?s:W(e,t)},ae=(r,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?d(r[s])||r[s]instanceof String||d(e[s])||e[s]instanceof String?t&&(r[s]=e[s]):ae(r[s],e[s],t):r[s]=e[s]);return r},M=r=>r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ie={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const De=r=>d(r)?r.replace(/[&<>"'\/]/g,e=>Ie[e]):r;class Ve{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)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}}const Ae=[" ",",","?","!",";"],Ke=new Ve(20),Me=(r,e,t)=>{e=e||"",t=t||"";const s=Ae.filter(a=>e.indexOf(a)<0&&t.indexOf(a)<0);if(s.length===0)return!0;const i=Ke.getRegExp(`(${s.map(a=>a==="?"?"\\?":a).join("|")})`);let n=!i.test(r);if(!n){const a=r.indexOf(t);a>0&&!i.test(r.substring(0,a))&&(n=!0)}return n},ee=(r,e,t=".")=>{if(!r)return;if(r[e])return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;const s=e.split(t);let i=r;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=n;l<s.length;++l)if(l!==n&&(o+=t),o+=s[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=a}return i},H=r=>r==null?void 0:r.replace("_","-"),Ue={type:"logger",log(r){this.output("log",r)},warn(r){this.output("warn",r)},error(r){this.output("error",r)},output(r,e){var t,s;(s=(t=console==null?void 0:console[r])==null?void 0:t.apply)==null||s.call(t,console,e)}};class Y{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Ue,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,s,i){return i&&!this.debug?null:(d(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Y(this.logger,g({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Y(this.logger,e)}}var T=new Y;class Q{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const i=this.observers[s].get(t)||0;this.observers[s].set(t,i+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let a=0;a<n;a++)i.apply(i,[e,...t])})}}class oe extends Q{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(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,s,i={}){var u,f;const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],s&&(Array.isArray(s)?o.push(...s):d(s)&&n?o.push(...s.split(n)):o.push(s)));const l=W(this.data,o);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=o[0],t=o[1],s=o.slice(2).join(".")),l||!a||!d(s)?l:ee((f=(u=this.data)==null?void 0:u[e])==null?void 0:f[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=[e,t];s&&(o=o.concat(a?s.split(a):s)),e.indexOf(".")>-1&&(o=e.split("."),i=t,t=o[1]),this.addNamespaces(t),re(this.data,o,i),n.silent||this.emit("added",e,t,s,i)}addResources(e,t,s,i={silent:!1}){for(const n in s)(d(s[n])||Array.isArray(s[n]))&&this.addResource(e,t,n,s[n],{silent:!0});i.silent||this.emit("added",e,t,s)}addResourceBundle(e,t,s,i,n,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(".")>-1&&(o=e.split("."),i=s,s=t,t=o[1]),this.addNamespaces(t);let l=W(this.data,o)||{};a.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?ae(l,s,n):l=g(g({},l),s),re(this.data,o,l),a.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 this.getResource(e,t)!==void 0}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(i=>t[i]&&Object.keys(t[i]).length>0)}toJSON(){return this.data}}var le={processors:{},addPostProcessor(r){this.processors[r.name]=r},handle(r,e,t,s,i){return r.forEach(n=>{var a,o;e=(o=(a=this.processors[n])==null?void 0:a.process(e,t,s,i))!=null?o:e}),e}};const ue={},he=r=>!d(r)&&typeof r!="boolean"&&typeof r!="number";class G extends Q{constructor(e,t={}){super(),Te(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=T.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s=g({},t);if(e==null)return!1;const i=this.resolve(e,s);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,t){let s=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const i=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const a=s&&e.indexOf(s)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Me(e,s,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:d(n)?[n]:n};const u=e.split(s);(s!==i||s===i&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(i)}return{key:e,namespaces:d(n)?[n]:n}}translate(e,t,s){let i=typeof t=="object"?g({},t):t;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(i=g({},i)),i||(i={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),u=l[l.length-1];let f=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const h=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((h==null?void 0:h.toLowerCase())==="cimode")return m?n?{res:`${u}${f}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${f}${o}`:n?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const p=this.resolve(e,i);let c=p==null?void 0:p.res;const x=(p==null?void 0:p.usedKey)||o,S=(p==null?void 0:p.exactUsedKey)||o,k=["[object Number]","[object Function]","[object RegExp]"],R=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,V=!this.i18nFormat||this.i18nFormat.handleAsObject,w=i.count!==void 0&&!d(i.count),j=G.hasDefaultValue(i),X=w?this.pluralResolver.getSuffix(h,i.count,i):"",I=i.ordinal&&w?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",z=w&&!i.ordinal&&i.count===0,C=z&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${X}`]||i[`defaultValue${I}`]||i.defaultValue;let O=c;V&&!c&&j&&(O=C);const et=he(O),tt=Object.prototype.toString.apply(O);if(V&&O&&et&&k.indexOf(tt)<0&&!(d(R)&&Array.isArray(O))){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(x,O,v(g({},i),{ns:l})):`key '${o} (${this.language})' returned an object instead of string.`;return n?(p.res=E,p.usedParams=this.getUsedParamsDetails(i),p):E}if(a){const E=Array.isArray(O),N=E?[]:{},Ce=E?S:x;for(const F in O)if(Object.prototype.hasOwnProperty.call(O,F)){const D=`${Ce}${a}${F}`;j&&!c?N[F]=this.translate(D,v(g({},i),{defaultValue:he(C)?C[F]:void 0,joinArrays:!1,ns:l})):N[F]=this.translate(D,v(g({},i),{joinArrays:!1,ns:l})),N[F]===D&&(N[F]=O[F])}c=N}}else if(V&&d(R)&&Array.isArray(c))c=c.join(R),c&&(c=this.extendTranslation(c,e,i,s));else{let E=!1,N=!1;!this.isValidLookup(c)&&j&&(E=!0,c=C),this.isValidLookup(c)||(N=!0,c=o);const F=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:c,D=j&&C!==c&&this.options.updateMissing;if(N||E||D){if(this.logger.log(D?"updateKey":"missingKey",h,u,o,D?C:c),a){const P=this.resolve(o,v(g({},i),{keySeparator:!1}));P&&P.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 J=[];const q=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&q&&q[0])for(let P=0;P<q.length;P++)J.push(q[P]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const Pe=(P,K,_)=>{var Re;const $e=j&&_!==c?_:F;this.options.missingKeyHandler?this.options.missingKeyHandler(P,u,K,$e,D,i):(Re=this.backendConnector)!=null&&Re.saveMissing&&this.backendConnector.saveMissing(P,u,K,$e,D,i),this.emit("missingKey",P,u,K,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?J.forEach(P=>{const K=this.pluralResolver.getSuffixes(P,i);z&&i[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(_=>{Pe([P],o+_,i[`defaultValue${_}`]||C)})}):Pe(J,o,C))}c=this.extendTranslation(c,e,i,p,s),N&&c===o&&this.options.appendNamespaceToMissingKey&&(c=`${u}${f}${o}`),(N||E)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${f}${o}`:o,E?c:void 0,i))}return n?(p.res=c,p.usedParams=this.getUsedParamsDetails(i),p):c}extendTranslation(e,t,s,i,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,g(g({},this.options.interpolation.defaultVariables),s),s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(v(g({},s),{interpolation:g(g({},this.options.interpolation),s.interpolation)}));const f=d(e)&&(((u=s==null?void 0:s.interpolation)==null?void 0:u.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(f){const p=e.match(this.interpolator.nestingRegexp);h=p&&p.length}let m=s.replace&&!d(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(m=g(g({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,s.lng||this.language||i.usedLng,s),f){const p=e.match(this.interpolator.nestingRegexp),c=p&&p.length;h<c&&(s.nest=!1)}!s.lng&&i&&i.res&&(s.lng=this.language||i.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,(...p)=>(n==null?void 0:n[0])===p[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`),null):this.translate(...p,t),s)),s.interpolation&&this.interpolator.reset()}const a=s.postProcess||this.options.postProcess,o=d(a)?[a]:a;return e!=null&&(o!=null&&o.length)&&s.applyPostProcessor!==!1&&(e=le.handle(o,e,t,this.options&&this.options.postProcessPassResolved?g({i18nResolved:v(g({},i),{usedParams:this.getUsedParamsDetails(s)})},s):s,this)),e}resolve(e,t={}){let s,i,n,a,o;return d(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(l,t),f=u.key;i=f;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=t.count!==void 0&&!d(t.count),p=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(d(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);h.forEach(S=>{var k,R;this.isValidLookup(s)||(o=S,!ue[`${x[0]}-${S}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((R=this.utils)!=null&&R.hasLoadedNamespace(o))&&(ue[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${x.join(", ")}" won't get resolved as namespace "${o}" 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!!!")),x.forEach(V=>{var X;if(this.isValidLookup(s))return;a=V;const w=[f];if((X=this.i18nFormat)!=null&&X.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,V,S,t);else{let I;m&&(I=this.pluralResolver.getSuffix(V,t.count,t));const z=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(w.push(f+I),t.ordinal&&I.indexOf(C)===0&&w.push(f+I.replace(C,this.options.pluralSeparator)),p&&w.push(f+z)),c){const O=`${f}${this.options.contextSeparator}${t.context}`;w.push(O),m&&(w.push(O+I),t.ordinal&&I.indexOf(C)===0&&w.push(O+I.replace(C,this.options.pluralSeparator)),p&&w.push(O+z))}}let j;for(;j=w.pop();)this.isValidLookup(s)||(n=j,s=this.getResource(V,S,j,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,s,i={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!d(e.replace);let i=s?e.replace:e;if(s&&typeof e.count!="undefined"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i=g(g({},this.options.interpolation.defaultVariables),i)),!s){i=g({},i);for(const n of t)delete i[n]}return i}static hasDefaultValue(e){const t="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,t.length)&&e[s]!==void 0)return!0;return!1}}class fe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=T.create("languageUtils")}getScriptPartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(d(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(s){}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(this.options.load==="languageOnly"||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(s=>{if(t)return;const i=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(i))&&(t=i)}),!t&&this.options.supportedLngs&&e.forEach(s=>{if(t)return;const i=this.getScriptPartFromCode(s);if(this.isSupportedCode(i))return t=i;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(a=>{if(a===n)return a;if(!(a.indexOf("-")<0&&n.indexOf("-")<0)&&(a.indexOf("-")>0&&n.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===n||a.indexOf(n)===0&&n.length>1))return a})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),d(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}toResolveHierarchy(e,t){const s=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),i=[],n=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return d(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):d(e)&&n(this.formatLanguageCode(e)),s.forEach(a=>{i.indexOf(a)<0&&n(this.formatLanguageCode(a))}),i}}const ce={zero:0,one:1,two:2,few:3,many:4,other:5},de={select:r=>r===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class He{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=T.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=H(e==="dev"?"en":e),i=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:s,type:i});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let a;try{a=new Intl.PluralRules(s,{type:i})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),de;if(!e.match(/-|_/))return de;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,t)}return this.pluralRulesCache[n]=a,a}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),(s==null?void 0:s.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(i=>`${t}${i}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((i,n)=>ce[i]-ce[n]).map(i=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const pe=(r,e,t,s=".",i=!0)=>{let n=je(r,e,t);return!n&&i&&d(t)&&(n=ee(r,t,s),n===void 0&&(n=ee(e,t,s))),n},te=r=>r.replace(/\$/g,"$$$$");class Be{constructor(e={}){var t;this.logger=T.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(s=>s),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:n,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:u,unescapeSuffix:f,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:k,alwaysFormat:R}=e.interpolation;this.escape=t!==void 0?t:De,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=n?M(n):a||"{{",this.suffix=o?M(o):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?M(m):p||M("$t("),this.nestingSuffix=c?M(c):x||M(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=k||1e3,this.alwaysFormat=R!==void 0?R:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,s)=>(t==null?void 0:t.source)===s?(t.lastIndex=0,t):new RegExp(s,"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,s,i){var p;let n,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const R=pe(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(R,void 0,s,v(g(g({},i),t),{interpolationkey:c})):R}const x=c.split(this.formatSeparator),S=x.shift().trim(),k=x.join(this.formatSeparator).trim();return this.format(pe(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),k,s,v(g(g({},i),t),{interpolationkey:S}))};this.resetRegExp();const f=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((p=i==null?void 0:i.interpolation)==null?void 0:p.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>te(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?te(this.escape(c)):te(c)}].forEach(c=>{for(o=0;n=c.regex.exec(e);){const x=n[1].trim();if(a=u(x),a===void 0)if(typeof f=="function"){const k=f(e,n,i);a=d(k)?k:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(h){a=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!d(a)&&!this.useRawValueToEscape&&(a=se(a));const S=c.safeValue(a);if(e=e.replace(n[0],S),h?(c.regex.lastIndex+=a.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,a;const o=(l,u)=>{var x;const f=this.nestingOptionsSeparator;if(l.indexOf(f)<0)return l;const h=l.split(new RegExp(`${f}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,a);const p=m.match(/'/g),c=m.match(/"/g);(((x=p==null?void 0:p.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),u&&(a=g(g({},u),a))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${f}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a=g({},s),a=a.replace&&!d(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(l=i[1].slice(u).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),n=t(o.call(this,i[1].trim(),a),a),n&&i[0]===e&&!d(n))return n;d(n)||(n=se(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((f,h)=>this.format(f,h,s.lng,v(g({},s),{interpolationkey:i[1].trim()})),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const ze=r=>{let e=r.toLowerCase().trim();const t={};if(r.indexOf("(")>-1){const s=r.split("(");e=s[0].toLowerCase().trim();const i=s[1].substring(0,s[1].length-1);e==="currency"&&i.indexOf(":")<0?t.currency||(t.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?t.range||(t.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),f=o.trim();t[f]||(t[f]=u),u==="false"&&(t[f]=!1),u==="true"&&(t[f]=!0),isNaN(u)||(t[f]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},ge=r=>{const e={};return(t,s,i)=>{let n=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(n=v(g({},n),{[i.interpolationkey]:void 0}));const a=s+JSON.stringify(n);let o=e[a];return o||(o=r(H(s),i),e[a]=o),o(t)}},Je=r=>(e,t,s)=>r(H(t),s)(e);class _e{constructor(e={}){this.logger=T.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?ge:Je;this.formats={number:s((i,n)=>{const a=new Intl.NumberFormat(i,g({},n));return o=>a.format(o)}),currency:s((i,n)=>{const a=new Intl.NumberFormat(i,v(g({},n),{style:"currency"}));return o=>a.format(o)}),datetime:s((i,n)=>{const a=new Intl.DateTimeFormat(i,g({},n));return o=>a.format(o)}),relativetime:s((i,n)=>{const a=new Intl.RelativeTimeFormat(i,g({},n));return o=>a.format(o,n.range||"day")}),list:s((i,n)=>{const a=new Intl.ListFormat(i,g({},n));return o=>a.format(o)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ge(t)}format(e,t,s,i={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(o=>o.indexOf(")")>-1)){const o=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,o)].join(this.formatSeparator)}return n.reduce((o,l)=>{var h;const{formatName:u,formatOptions:f}=ze(l);if(this.formats[u]){let m=o;try{const p=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},c=p.locale||p.lng||i.locale||i.lng||s;m=this.formats[u](o,c,g(g(g({},f),i),p))}catch(p){this.logger.warn(p)}return m}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const We=(r,e)=>{r.pending[e]!==void 0&&(delete r.pending[e],r.pendingCount--)};class Ye extends Q{constructor(e,t,s,i={}){var n,a;super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=T.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(n=this.backend)==null?void 0:n.init)==null||a.call(n,s,i.backend,i)}queueLoad(e,t,s,i){const n={},a={},o={},l={};return e.forEach(u=>{let f=!0;t.forEach(h=>{const m=`${u}|${h}`;!s.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,f=!1,a[m]===void 0&&(a[m]=!0),n[m]===void 0&&(n[m]=!0),l[h]===void 0&&(l[h]=!0)))}),f||(o[u]=!0)}),(Object.keys(n).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],a=i[1];t&&this.emit("failedLoading",n,a,t),!t&&s&&this.store.addResourceBundle(n,a,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Fe(l.loaded,[n],a),We(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{o[u]||(o[u]={});const f=l.loaded[u];f.length&&f.forEach(h=>{o[u][h]===void 0&&(o[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:a});return}this.readingCalls++;const o=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,a)},n);return}a(u,f)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(f=>o(null,f)).catch(o):o(null,u)}catch(u){o(u)}return}return l(e,t,o)}prepareLoading(e,t,s={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();d(e)&&(e=this.languageUtils.toResolveHierarchy(e)),d(t)&&(t=[t]);const n=this.queueLoad(e,t,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach(a=>{this.loadOne(a)})}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("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,a),!a&&o&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,t,s,i,n,a={},o=()=>{}){var l,u,f,h,m;if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(f=this.services)==null?void 0:f.utils)!=null&&h.hasLoadedNamespace(t))){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!!!");return}if(!(s==null||s==="")){if((m=this.backend)!=null&&m.create){const p=v(g({},a),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,s,i,p):x=c(e,t,s,i),x&&typeof x.then=="function"?x.then(S=>o(null,S)).catch(o):o(null,x)}catch(x){o(x)}else c(e,t,s,i,o,p)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const me=()=>({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:r=>{let e={};if(typeof r[1]=="object"&&(e=r[1]),d(r[1])&&(e.defaultValue=r[1]),d(r[2])&&(e.tDescription=r[2]),typeof r[2]=="object"||typeof r[3]=="object"){const t=r[3]||r[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:r=>r,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),xe=r=>{var e,t;return d(r.ns)&&(r.ns=[r.ns]),d(r.fallbackLng)&&(r.fallbackLng=[r.fallbackLng]),d(r.fallbackNS)&&(r.fallbackNS=[r.fallbackNS]),((t=(e=r.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),typeof r.initImmediate=="boolean"&&(r.initAsync=r.initImmediate),r},Z=()=>{},Qe=r=>{Object.getOwnPropertyNames(Object.getPrototypeOf(r)).forEach(t=>{typeof r[t]=="function"&&(r[t]=r[t].bind(r))})};class B extends Q{constructor(e={},t){if(super(),this.options=xe(e),this.services={},this.logger=T,this.modules={external:[]},Qe(this),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,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(d(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const s=me();this.options=g(g(g({},s),this.options),xe(e)),this.options.interpolation=g(g({},s.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?T.init(i(this.modules.logger),this.options):T.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=_e;const f=new fe(this.options);this.store=new oe(this.options.resources,this.options);const h=this.services;h.logger=T,h.resourceStore=this.store,h.languageUtils=f,h.pluralResolver=new He(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new Be(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Ye(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new G(this.services,this.options),this.translator.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...f)=>this.store[u](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...f)=>(this.store[u](...f),this)});const o=L(),l=()=>{const u=(f,h)=>{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),o.resolve(h),t(f,h)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,t=Z){var n,a;let s=t;const i=d(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const o=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&o.indexOf(h)<0&&o.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(f=>l(f)),(a=(n=this.options.preload)==null?void 0:n.forEach)==null||a.call(n,u=>l(u)),this.services.backendConnector.load(o,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(e,t,s){const i=L();return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),s||(s=Z),this.services.backendConnector.reload(e,t,n=>{i.resolve(),s(n)}),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 e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&le.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let t=0;t<this.languages.length;t++){const s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;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 s=L();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},n=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,s.resolve((...u)=>this.t(...u)),t&&t(o,(...u)=>this.t(...u))},a=o=>{var f,h;!e&&!o&&this.services.languageDetector&&(o=[]);const l=d(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(d(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),(h=(f=this.services.languageDetector)==null?void 0:f.cacheUserLanguage)==null||h.call(f,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),s}getFixedT(e,t,s){const i=(n,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([n,a].concat(o)):l=g({},a),l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||i.keyPrefix);const u=this.options.keySeparator||".";let f;return l.keyPrefix&&Array.isArray(n)?f=n.map(h=>`${l.keyPrefix}${u}${h}`):f=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(f,l)};return d(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.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],i=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const a=(o,l)=>{const u=this.services.backendConnector.state[`${o}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const o=t.precheck(this,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(s,e)&&(!i||a(n,e)))}loadNamespaces(e,t){const s=L();return this.options.ns?(d(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{s.resolve(),t&&t(i)}),s):(t&&t(),Promise.resolve())}loadLanguages(e,t){const s=L();d(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return n.length?(this.options.preload=i.concat(n),this.loadResources(a=>{s.resolve(),t&&t(a)}),s):(t&&t(),Promise.resolve())}dir(e){var i,n;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const a=new Intl.Locale(e);if(a&&a.getTextInfo){const o=a.getTextInfo();if(o&&o.direction)return o.direction}}catch(a){}const t=["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"],s=((n=this.services)==null?void 0:n.languageUtils)||new fe(me());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new B(e,t)}cloneInstance(e={},t=Z){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i=v(g(g({},this.options),e),{isClone:!0}),n=new B(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(o=>{n[o]=this[o]}),n.services=g({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const o=Object.keys(this.store.data).reduce((l,u)=>(l[u]=g({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((f,h)=>(f[h]=g({},l[u][h]),f),l[u]),l),{});n.store=new oe(o,i),n.services.resourceStore=n.store}return n.translator=new G(n.services,i),n.translator.on("*",(o,...l)=>{n.emit(o,...l)}),n.init(i,t),n.translator.options=i,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=B.createInstance();y.createInstance=B.createInstance,y.createInstance,y.dir,y.init,y.loadResources,y.reloadResources,y.use,y.changeLanguage,y.getFixedT,y.t,y.exists,y.setDefaultNamespace,y.hasLoadedNamespace,y.loadNamespaces,y.loadLanguages;const Ge=r=>{let e="";return r.childNodes.forEach(t=>{t.nodeType===3&&(e+=t.nodeValue)}),e.trim()},ye=(r,e)=>{let t=!1;r.childNodes.forEach(s=>{if(s.nodeType!==3)return;const i=(s.nodeValue||"").trim();i&&(s.nodeValue=t?"":s.nodeValue.replace(i,()=>e),t=!0)})},Se=r=>{if(r.attr("data-i18n"))return;const e=r.get(0);if(!e)return;const t=Ge(e);t&&(r.attr({"data-i18n":t}),ye(e,y.t(t)));const s=r.attr("placeholder");s&&(r.attr({"data-i18n":"[placeholder]"+s}),r.attr({placeholder:y.t(s)}))},Ze=(r,e)=>{for(const t of e){const s=r.find(t);s&&s.each((i,n)=>{Se($(n))})}},A=r=>{for(const e of r){const t=$(e);t&&t.each((s,i)=>{Se($(i))})}},be=[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc",".hiprint-multiselect-search",".hiprint-multiselect-custom-input",".hiprint-multiselect-trigger .hiprint-multiselect-text",".hiprint-multiselect-item span",".hiprint-multiselect-actions button"],Xe=(r,e,t=be)=>{Ze(e,t)},Le=(r="[data-i18n]")=>{document.querySelectorAll(r).forEach(e=>{const t=e.getAttribute("data-i18n");if(!t.includes("[")){ye(e,y.t(t));return}const s=t.match(/\[([^\]]+)\](.+)/);if(s&&s.length===3){const i=s[1],n=s[2];e.setAttribute(i,y.t(n))}})};let Oe=!1;const we=r=>{if(Oe)return;Oe=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(r.resources||{});globalThis.hiprint.languages=["简体中文",...e],globalThis.hiprint.changeLanguage=(t,s)=>{y.changeLanguage(t,(i,n)=>{s&&s(i,n),Le()})}},ve=r=>{setTimeout(()=>{Le(".printSetting .hiprint-multiselect [data-i18n]"),$(".printSetting .hiprint-multiselect").length&&$(".printSetting .hiprint-multiselect-trigger").off("click.multiselect-trigger").on("click.multiselect-trigger",()=>{console.log("click multiselect"),setTimeout(()=>{A((r==null?void 0:r.optionsSelectorList)||be)},0)})},0)};function qe(r,e){y.init(g({},r),(s,i)=>{e&&e(y,i,s)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"添加 i18n 方法",priority:1,run:()=>{we(r)}},{hook:"getOptionItem",name:"i18n options",description:"渲染元素属性时做多语言处理",priority:1,run:s=>{if(s){if(!s._translationWrapped){s._translationWrapped=!0;const i=s.createTarget;s.createTarget=function(...n){const a=i.call(s,...n);return t.indexOf(s.name)!==-1&&a.attr("data-name")||(a.attr({"data-name":s.name}),Xe(s,a,r==null?void 0:r.optionsSelectorList)),a}}return t.indexOf(s.name)===-1&&t.push(s.name),s}}},{hook:"onDesigned",name:"i18n other selector",description:"其他UI选择器多语言处理",priority:9,run:({hiprint:s,designerUtils:i})=>{we(r),setTimeout(()=>{var o;const n=(o=i.printTemplate)==null?void 0:o.id;n&&(r!=null&&r.onDesigned&&(r==null||r.onDesigned(i)),globalThis.hinnn.event.on("BuildCustomOptionSettingEventKey_"+n,l=>{r!=null&&r.onPanelSelected&&(r==null||r.onPanelSelected()),ve(r)}),globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{A([".printSetting .prop-tab-items .tab-title"]),ve(r),r!=null&&r.onElementSelected&&(r==null||r.onElementSelected(l))},0)}),$(".hiprint-printPaper.design").on("contextmenu",()=>{A([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),A([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onDesignedDelay)||600)}},{hook:"onSettings",name:"i18n settings",description:"设置选择器多语言处理",priority:1,run:s=>{s.type=="show"&&setTimeout(()=>{A([".settings-body .svp-tab"])},0),r!=null&&r.onSettings&&(r==null||r.onSettings(s))}},{hook:"onPreview",name:"i18n preview selector",description:"组件内预览选择器多语言处理",priority:1,run:s=>{setTimeout(()=>{A([".preview-bar button span",".printer-list-txt"])},(r==null?void 0:r.onPreviewDelay)||0),r!=null&&r.onPreview&&(r==null||r.onPreview(s))}}],leastHiprintVersion:"0.1.28"}}b.default=qe,b.translateBySelector=A,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const translateOwnTextNodes: (element: Element, value: string) => void;
|
|
1
2
|
export declare const translateBySelector: (selectorList: string[]) => void;
|
|
2
3
|
export declare const DEFAULT_OPTIONS_SELECTOR_LIST: string[];
|
|
3
4
|
export declare const translateOptions: (item: any, target: any, optionsSelectorList?: string[]) => void;
|