@sv-print/plugin-i18n 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/dist/index.mjs +1448 -0
- package/dist/index.umd.js +1 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Ce=Object.defineProperty,ve=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var re=(o,e,t)=>e in o?Ce(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,p=(o,e)=>{for(var t in e||(e={}))Re.call(e,t)&&re(o,t,e[t]);if(ne)for(var t of ne(e))Pe.call(e,t)&&re(o,t,e[t]);return o},O=(o,e)=>ve(o,$e(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=o=>typeof o=="string",U=()=>{let o,e;const t=new Promise((s,i)=>{o=s,e=i});return t.resolve=o,t.reject=e,t},ae=o=>o==null?"":""+o,ke=(o,e,t)=>{o.forEach(s=>{e[s]&&(t[s]=e[s])})},Ne=/###/g,oe=o=>o&&o.indexOf("###")>-1?o.replace(Ne,"."):o,le=o=>!o||g(o),M=(o,e,t)=>{const s=g(e)?e.split("."):e;let i=0;for(;i<s.length-1;){if(le(o))return{};const n=oe(s[i]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++i}return le(o)?{}:{obj:o,k:oe(s[i])}},ue=(o,e,t)=>{const{obj:s,k:i}=M(o,e,Object);if(s!==void 0||e.length===1){s[i]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=M(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=M(o,r,Object),(a==null?void 0:a.obj)&&typeof a.obj[`${a.k}.${n}`]!="undefined"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Ee=(o,e,t,s)=>{const{obj:i,k:n}=M(o,e,Object);i[n]=i[n]||[],i[n].push(t)},Y=(o,e)=>{const{obj:t,k:s}=M(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,s))return t[s]},Fe=(o,e,t)=>{const s=Y(o,t);return s!==void 0?s:Y(e,t)},be=(o,e,t)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in o?g(o[s])||o[s]instanceof String||g(e[s])||e[s]instanceof String?t&&(o[s]=e[s]):be(o[s],e[s],t):o[s]=e[s]);return o},I=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Te={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const je=o=>g(o)?o.replace(/[&<>"'\/]/g,e=>Te[e]):o;class De{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 Ie=[" ",",","?","!",";"],Ae=new De(20),Ve=(o,e,t)=>{e=e||"",t=t||"";const s=Ie.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(s.length===0)return!0;const i=Ae.getRegExp(`(${s.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!i.test(o);if(!n){const r=o.indexOf(t);r>0&&!i.test(o.substring(0,r))&&(n=!0)}return n},q=(o,e,t=".")=>{if(!o)return;if(o[e])return Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0;const s=e.split(t);let i=o;for(let n=0;n<s.length;){if(!i||typeof i!="object")return;let r,a="";for(let l=n;l<s.length;++l)if(l!==n&&(a+=t),a+=s[l],r=i[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<s.length-1)continue;n+=l-n+1;break}i=r}return i},B=o=>o==null?void 0:o.replace("_","-"),Ke={type:"logger",log(o){this.output("log",o)},warn(o){this.output("warn",o)},error(o){this.output("error",o)},output(o,e){var t,s;(s=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||s.call(t,console,e)}};class Q{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:(g(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Q(this.logger,p({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Q(this.logger,e)}}var N=new Q;class Z{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 r=0;r<n;r++)i(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,n])=>{for(let r=0;r<n;r++)i.apply(i,[e,...t])})}}class fe extends Z{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,h;const n=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,r=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],s&&(Array.isArray(s)?a.push(...s):g(s)&&n?a.push(...s.split(n)):a.push(s)));const l=Y(this.data,a);return!l&&!t&&!s&&e.indexOf(".")>-1&&(e=a[0],t=a[1],s=a.slice(2).join(".")),l||!r||!g(s)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],s,n)}addResource(e,t,s,i,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(r?s.split(r):s)),e.indexOf(".")>-1&&(a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),ue(this.data,a,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,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let l=Y(this.data,a)||{};r.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?be(l,s,n):l=p(p({},l),s),ue(this.data,a,l),r.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(o){this.processors[o.name]=o},handle(o,e,t,s,i){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,s,i))!=null?a:e}),e}};const he={},ce=o=>!g(o)&&typeof o!="boolean"&&typeof o!="number";class G extends Z{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=N.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 r=s&&e.indexOf(s)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ve(e,s,i);if(r&&!a){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,r=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],i),u=l[l.length-1];let h=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return m?n?{res:`${u}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:a;const d=this.resolve(e,i);let c=d==null?void 0:d.res;const x=(d==null?void 0:d.usedKey)||a,S=(d==null?void 0:d.exactUsedKey)||a,$=["[object Number]","[object Function]","[object RegExp]"],v=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,L=i.count!==void 0&&!g(i.count),E=G.hasDefaultValue(i),z=L?this.pluralResolver.getSuffix(f,i.count,i):"",F=i.ordinal&&L?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",A=L&&!i.ordinal&&i.count===0,w=A&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${z}`]||i[`defaultValue${F}`]||i.defaultValue;let b=c;j&&!c&&E&&(b=w);const Oe=ce(b),we=Object.prototype.toString.apply(b);if(j&&b&&Oe&&$.indexOf(we)<0&&!(g(v)&&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 P=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},i),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=P,d.usedParams=this.getUsedParamsDetails(i),d):P}if(r){const P=Array.isArray(b),R=P?[]:{},ee=P?S:x;for(const k in b)if(Object.prototype.hasOwnProperty.call(b,k)){const T=`${ee}${r}${k}`;E&&!c?R[k]=this.translate(T,O(p({},i),{defaultValue:ce(w)?w[k]:void 0,joinArrays:!1,ns:l})):R[k]=this.translate(T,O(p({},i),{joinArrays:!1,ns:l})),R[k]===T&&(R[k]=b[k])}c=R}}else if(j&&g(v)&&Array.isArray(c))c=c.join(v),c&&(c=this.extendTranslation(c,e,i,s));else{let P=!1,R=!1;!this.isValidLookup(c)&&E&&(P=!0,c=w),this.isValidLookup(c)||(R=!0,c=a);const k=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:c,T=E&&w!==c&&this.options.updateMissing;if(R||P||T){if(this.logger.log(T?"updateKey":"missingKey",f,u,a,T?w:c),r){const C=this.resolve(a,O(p({},i),{keySeparator:!1}));C&&C.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 V=[];const J=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&J&&J[0])for(let C=0;C<J.length;C++)V.push(J[C]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(i.lng||this.language):V.push(i.lng||this.language);const te=(C,D,K)=>{var ie;const se=E&&K!==c?K:k;this.options.missingKeyHandler?this.options.missingKeyHandler(C,u,D,se,T,i):(ie=this.backendConnector)!=null&&ie.saveMissing&&this.backendConnector.saveMissing(C,u,D,se,T,i),this.emit("missingKey",C,u,D,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?V.forEach(C=>{const D=this.pluralResolver.getSuffixes(C,i);A&&i[`defaultValue${this.options.pluralSeparator}zero`]&&D.indexOf(`${this.options.pluralSeparator}zero`)<0&&D.push(`${this.options.pluralSeparator}zero`),D.forEach(K=>{te([C],a+K,i[`defaultValue${K}`]||w)})}):te(V,a,w))}c=this.extendTranslation(c,e,i,d,s),R&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(R||P)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,P?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 h=g(e)&&(((u=s==null?void 0:s.interpolation)==null?void 0:u.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const d=e.match(this.interpolator.nestingRegexp);f=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),h){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;f<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 r=s.postProcess||this.options.postProcess,a=g(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&s.applyPostProcessor!==!1&&(e=Le.handle(a,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,r,a;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(l,t),h=u.key;i=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.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);f.forEach(S=>{var $,v;this.isValidLookup(s)||(a=S,!he[`${x[0]}-${S}`]&&(($=this.utils)==null?void 0:$.hasLoadedNamespace)&&!((v=this.utils)!=null&&v.hasLoadedNamespace(a))&&(he[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${i}" for languages "${x.join(", ")}" won't get resolved as namespace "${a}" 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(j=>{var z;if(this.isValidLookup(s))return;r=j;const L=[h];if((z=this.i18nFormat)!=null&&z.addLookupKeys)this.i18nFormat.addLookupKeys(L,h,j,S,t);else{let F;m&&(F=this.pluralResolver.getSuffix(j,t.count,t));const A=`${this.options.pluralSeparator}zero`,w=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(h+F),t.ordinal&&F.indexOf(w)===0&&L.push(h+F.replace(w,this.options.pluralSeparator)),d&&L.push(h+A)),c){const b=`${h}${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+A))}}let E;for(;E=L.pop();)this.isValidLookup(s)||(n=E,s=this.getResource(j,S,E,t))}))})}),{res:s,usedKey:i,exactUsedKey:n,usedLng:r,usedNS:a}}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 de{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=B(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=B(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(r=>{if(r===n)return r;if(!(r.indexOf("-")<0&&n.indexOf("-")<0)&&(r.indexOf("-")>0&&n.indexOf("-")<0&&r.substring(0,r.indexOf("-"))===n||r.indexOf(n)===0&&n.length>1))return r})}),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=r=>{!r||(this.isSupportedCode(r)?i.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};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(r=>{i.indexOf(r)<0&&n(this.formatLanguageCode(r))}),i}}const pe={zero:0,one:1,two:2,few:3,many:4,other:5},ge={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ue{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=N.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=B(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 r;try{r=new Intl.PluralRules(s,{type:i})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ge;if(!e.match(/-|_/))return ge;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}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)=>pe[i]-pe[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 me=(o,e,t,s=".",i=!0)=>{let n=Fe(o,e,t);return!n&&i&&g(t)&&(n=q(o,t,s),n===void 0&&(n=q(e,t,s))),n},X=o=>o.replace(/\$/g,"$$$$");class Me{constructor(e={}){var t;this.logger=N.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:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:d,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:$,alwaysFormat:v}=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?I(n):r||"{{",this.suffix=a?I(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?I(m):d||I("$t("),this.nestingSuffix=c?I(c):x||I(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=$||1e3,this.alwaysFormat=v!==void 0?v:!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,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const v=me(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,s,O(p(p({},i),t),{interpolationkey:c})):v}const x=c.split(this.formatSeparator),S=x.shift().trim(),$=x.join(this.formatSeparator).trim();return this.format(me(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),$,s,O(p(p({},i),t),{interpolationkey:S}))};this.resetRegExp();const h=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((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=>X(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?X(this.escape(c)):X(c)}].forEach(c=>{for(a=0;n=c.regex.exec(e);){const x=n[1].trim();if(r=u(x),r===void 0)if(typeof h=="function"){const $=h(e,n,i);r=g($)?$:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!g(r)&&!this.useRawValueToEscape&&(r=ae(r));const S=c.safeValue(r);if(e=e.replace(n[0],S),f?(c.regex.lastIndex+=r.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,s={}){let i,n,r;const a=(l,u)=>{var x;const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const f=l.split(new RegExp(`${h}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,r);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{r=JSON.parse(m),u&&(r=p(p({},u),r))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${h}${m}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];r=p({},s),r=r.replace&&!g(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.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(h=>h.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),n=t(a.call(this,i[1].trim(),r),r),n&&i[0]===e&&!g(n))return n;g(n)||(n=ae(n)),n||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,s.lng,O(p({},s),{interpolationkey:i[1].trim()})),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}const Be=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const s=o.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(r=>{if(r){const[a,...l]=r.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=u),u==="false"&&(t[h]=!1),u==="true"&&(t[h]=!0),isNaN(u)||(t[h]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},xe=o=>{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 r=s+JSON.stringify(n);let a=e[r];return a||(a=o(B(s),i),e[r]=a),a(t)}},He=o=>(e,t,s)=>o(B(t),s)(e);class ze{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?xe:He;this.formats={number:s((i,n)=>{const r=new Intl.NumberFormat(i,p({},n));return a=>r.format(a)}),currency:s((i,n)=>{const r=new Intl.NumberFormat(i,O(p({},n),{style:"currency"}));return a=>r.format(a)}),datetime:s((i,n)=>{const r=new Intl.DateTimeFormat(i,p({},n));return a=>r.format(a)}),relativetime:s((i,n)=>{const r=new Intl.RelativeTimeFormat(i,p({},n));return a=>r.format(a,n.range||"day")}),list:s((i,n)=>{const r=new Intl.ListFormat(i,p({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=xe(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(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{var f;const{formatName:u,formatOptions:h}=Be(l);if(this.formats[u]){let m=a;try{const d=((f=i==null?void 0:i.formatParams)==null?void 0:f[i.interpolationkey])||{},c=d.locale||d.lng||i.locale||i.lng||s;m=this.formats[u](a,c,p(p(p({},h),i),d))}catch(d){this.logger.warn(d)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const Je=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class We extends Z{constructor(e,t,s,i={}){var n,r;super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=N.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=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,s,i.backend,i)}queueLoad(e,t,s,i){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!s.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?r[m]===void 0&&(r[m]=!0):(this.state[m]=1,h=!1,r[m]===void 0&&(r[m]=!0),n[m]===void 0&&(n[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(a[u]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,s){const i=e.split("|"),n=i[0],r=i[1];t&&this.emit("failedLoading",n,r,t),!t&&s&&this.store.addResourceBundle(n,r,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Ee(l.loaded,[n],r),Je(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const h=l.loaded[u];h.length&&h.forEach(f=>{a[u][f]===void 0&&(a[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,s,i=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:n,callback:r});return}this.readingCalls++;const a=(u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,s,i+1,n*2,r)},n);return}r(u,h)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,t,a)}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(r=>{this.loadOne(r)})}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,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${i} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${i}`,a),this.loaded(e,r,a)})}saveMissing(e,t,s,i,n,r={},a=()=>{}){var l,u,h,f,m;if(((u=(l=this.services)==null?void 0:l.utils)==null?void 0:u.hasLoadedNamespace)&&!((f=(h=this.services)==null?void 0:h.utils)!=null&&f.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({},r),{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=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,s,i,a,d)}!e||!e[0]||this.store.addResource(e[0],t,s,i)}}}const ye=()=>({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:o=>{let e={};if(typeof o[1]=="object"&&(e=o[1]),g(o[1])&&(e.defaultValue=o[1]),g(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(s=>{e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Se=o=>{var e,t;return g(o.ns)&&(o.ns=[o.ns]),g(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),g(o.fallbackNS)&&(o.fallbackNS=[o.fallbackNS]),((t=(e=o.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(o.supportedLngs=o.supportedLngs.concat(["cimode"])),typeof o.initImmediate=="boolean"&&(o.initAsync=o.initImmediate),o},W=()=>{},_e=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class H extends Z{constructor(e={},t){if(super(),this.options=Se(e),this.services={},this.logger=N,this.modules={external:[]},_e(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=ye();this.options=p(p(p({},s),this.options),Se(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?N.init(i(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=ze;const h=new de(this.options);this.store=new fe(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new Ue(h,{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)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Me(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new We(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new G(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=W),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]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});const a=U(),l=()=>{const u=(h,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(f),t(h,f)};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),a}loadResources(e,t=W){var n,r;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 a=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&a.indexOf(f)<0&&a.push(f)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>l(h)),(r=(n=this.options.preload)==null?void 0:n.forEach)==null||r.call(n,u=>l(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(u)})}else s(null)}reloadResources(e,t,s){const i=U();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=W),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=U();this.emit("languageChanging",e);const i=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,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(a,(...u)=>this.t(...u))},r=a=>{var h,f;!e&&!a&&this.services.languageDetector&&(a=[]);const l=g(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(g(a)?[a]:a);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),(f=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||f.call(h,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?r(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e),s}getFixedT(e,t,s){const i=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=p({},r),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 h;return l.keyPrefix&&Array.isArray(n)?h=n.map(f=>`${l.keyPrefix}${u}${f}`):h=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(h,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 r=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const a=t.precheck(this,r);if(a!==void 0)return a}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(s,e)&&(!i||r(n,e)))}loadNamespaces(e,t){const s=U();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=U();g(e)&&(e=[e]);const i=this.options.preload||[],n=e.filter(r=>i.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=i.concat(n),this.loadResources(r=>{s.resolve(),t&&t(r)}),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 r=new Intl.Locale(e);if(r&&r.getTextInfo){const a=r.getTextInfo();if(a&&a.direction)return a.direction}}catch(r){}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 de(ye());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 H(e,t)}cloneInstance(e={},t=W){const s=e.forkResourceStore;s&&delete e.forkResourceStore;const i=O(p(p({},this.options),e),{isClone:!0}),n=new H(i);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services=p({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=p({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=p({},l[u][f]),h),l[u]),l),{});n.store=new fe(a,i),n.services.resourceStore=n.store}return n.translator=new G(n.services,i),n.translator.on("*",(a,...l)=>{n.emit(a,...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=H.createInstance();y.createInstance=H.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=(o,e)=>{for(const t of e){const s=o.find(t);s&&s.each((i,n)=>{const r=globalThis.$(n);if(r.attr("data-i18n"))return;const a=r.text().trim();a&&(r.attr({"data-i18n":a}),r.text(y.t(a)));const l=r.attr("placeholder");l&&(r.attr({"data-i18n":"[placeholder]"+l}),r.attr({placeholder:y.t(l)}))})}},_=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((s,i)=>{const n=globalThis.$(i);if(n.attr("data-i18n"))return;const r=n.text().trim();r&&(n.attr({"data-i18n":r}),n.text(y.t(r)));const a=n.attr("placeholder");a&&(n.attr({"data-i18n":"[placeholder]"+a}),n.attr({placeholder:y.t(a)}))})}},Qe=(o,e)=>{Ye(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},Ge=()=>{document.querySelectorAll("[data-i18n]").forEach(o=>{const e=o.getAttribute("data-i18n");if(!e.includes("[")){o.textContent=y.t(e);return}const t=e.match(/\[([^\]]+)\](.+)/);if(t&&t.length===3){const s=t[1],i=t[2];o.setAttribute(s,y.t(i))}})};function Ze(o,e){y.init(p({},o),(s,i)=>{e&&e(y,i,s)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"\u6DFB\u52A0 i18n \u65B9\u6CD5",priority:1,run:()=>{globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const s=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...s],globalThis.hiprint.changeLanguage=(i,n)=>{y.changeLanguage(i,(r,a)=>{n&&n(r,a),Ge()})}}},{hook:"getOptionItem",name:"i18n options",description:"\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:s=>{if(t.some(n=>n==s.name))return s;t.push(s.name);const i=s.createTarget;return s.createTarget=function(...n){const r=i.call(s,...n);return r.attr({"data-name":s.name}),Qe(s,r),r},s}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:s,designerUtils:i})=>{var a;const n=(a=i.printTemplate)==null?void 0:a.id;n&&globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{_([".printSetting .prop-tab-items .tab-title"])},0)}),_([".svp-header p",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])}},{hook:"onPreview",name:"i18n preview selector",description:"\u7EC4\u4EF6\u5185\u9884\u89C8\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:s=>{setTimeout(()=>{_([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}exports.default=Ze;exports.translateBySelector=_;
|