@sv-print/plugin-i18n 0.1.3 → 0.1.4
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/README.md +52 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +68 -61
- package/dist/index.umd.js +1 -1
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @sv-print/plugin-i18n
|
|
2
|
+
|
|
3
|
+
## 安装
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @sv-print/plugin-i18n
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
|
|
11
|
+
sv-print 插件引入的两种方式见:[sv-print 插件引入的两种方式:https://www.ibujian.cn/svp/plugin/a02.html](https://www.ibujian.cn/svp/plugin/a02.html)
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import pluginI18n, { translateBySelector } from "@sv-print/plugin-i18n";
|
|
15
|
+
import en from "./i18n/en.json"; // 语言文件: json数据
|
|
16
|
+
const plugins = [
|
|
17
|
+
pluginI18n(
|
|
18
|
+
{
|
|
19
|
+
// lng: "英文", // 默认: "简体中文"
|
|
20
|
+
// debug: true, // 调试: 可查看对应语言 缺少的翻译
|
|
21
|
+
resources: {
|
|
22
|
+
// 自定义 key: "英文", 则列表 显示对应的名称
|
|
23
|
+
英文: {
|
|
24
|
+
translation: en,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
(i18next, t, err) => {
|
|
29
|
+
// 回调,干点儿其他的
|
|
30
|
+
console.log("测试翻译", t("文本"));
|
|
31
|
+
// 插件提供的一个 API, 根据 选择器 翻译
|
|
32
|
+
// translateBySelector([".sv-print"]);
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
];
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
LGPL
|
|
41
|
+
|
|
42
|
+
### 开源使用须知
|
|
43
|
+
|
|
44
|
+
1.请自觉遵守 LGPL 协议,其他用途可联系作者;
|
|
45
|
+
|
|
46
|
+
2.允许用于个人学习、毕业设计、教学案例、公益事业、商业使用;
|
|
47
|
+
|
|
48
|
+
3.如果商用必须保留版权信息,请自觉遵守;
|
|
49
|
+
|
|
50
|
+
4.禁止将本开源的代码和资源进行任何形式任何名义的出售,否则产生的一切任何后果责任由侵权者自负;
|
|
51
|
+
|
|
52
|
+
5.商用请仔细审查代码和漏洞,不得用于任一国家许可范围之外的商业应用,产生的一切任何后果责任自负;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ce=Object.defineProperty,ve=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Re=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={}))Pe.call(e,t)&&re(o,t,e[t]);if(ne)for(var t of ne(e))Re.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((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},ae=o=>o==null?"":""+o,ke=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},Ne=/###/g,oe=o=>o&&o.indexOf("###")>-1?o.replace(Ne,"."):o,le=o=>!o||g(o),B=(o,e,t)=>{const i=g(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(le(o))return{};const n=oe(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return le(o)?{}:{obj:o,k:oe(i[s])}},ue=(o,e,t)=>{const{obj:i,k:s}=B(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=B(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=B(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,i)=>{const{obj:s,k:n}=B(o,e,Object);s[n]=s[n]||[],s[n].push(t)},Y=(o,e)=>{const{obj:t,k:i}=B(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,i))return t[i]},Fe=(o,e,t)=>{const i=Y(o,t);return i!==void 0?i:Y(e,t)},be=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?g(o[i])||o[i]instanceof String||g(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):be(o[i],e[i],t):o[i]=e[i]);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 i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Ie=[" ",",","?","!",";"],Ae=new De(20),Ve=(o,e,t)=>{e=e||"",t=t||"";const i=Ie.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Ae.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.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 i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},H=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,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.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,i,s){return s&&!this.debug?null:(g(e[0])&&(e[0]=`${i}${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(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+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(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[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,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):g(i)&&n?a.push(...i.split(n)):a.push(i)));const l=Y(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!g(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ue(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(g(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=Y(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?be(l,i,n):l=p(p({},l),i),ue(this.data,a,l),r.silent||this.emit("added",e,t,i)}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(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var Le={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=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 i=p({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ve(e,i,s);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(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:g(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?p({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=p({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.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(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const d=this.resolve(e,s);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=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,L=s.count!==void 0&&!g(s.count),E=G.hasDefaultValue(s),J=L?this.pluralResolver.getSuffix(f,s.count,s):"",F=s.ordinal&&L?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",A=L&&!s.ordinal&&s.count===0,w=A&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${J}`]||s[`defaultValue${F}`]||s.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(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=R,d.usedParams=this.getUsedParamsDetails(s),d):R}if(r){const R=Array.isArray(b),P=R?[]:{},ee=R?S:x;for(const k in b)if(Object.prototype.hasOwnProperty.call(b,k)){const T=`${ee}${r}${k}`;E&&!c?P[k]=this.translate(T,O(p({},s),{defaultValue:ce(w)?w[k]:void 0,joinArrays:!1,ns:l})):P[k]=this.translate(T,O(p({},s),{joinArrays:!1,ns:l})),P[k]===T&&(P[k]=b[k])}c=P}}else if(j&&g(v)&&Array.isArray(c))c=c.join(v),c&&(c=this.extendTranslation(c,e,s,i));else{let R=!1,P=!1;!this.isValidLookup(c)&&E&&(R=!0,c=w),this.isValidLookup(c)||(P=!0,c=a);const k=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:c,T=E&&w!==c&&this.options.updateMissing;if(P||R||T){if(this.logger.log(T?"updateKey":"missingKey",f,u,a,T?w:c),r){const C=this.resolve(a,O(p({},s),{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 W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let C=0;C<W.length;C++)V.push(W[C]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(s.lng||this.language):V.push(s.lng||this.language);const te=(C,D,K)=>{var se;const ie=E&&K!==c?K:k;this.options.missingKeyHandler?this.options.missingKeyHandler(C,u,D,ie,T,s):(se=this.backendConnector)!=null&&se.saveMissing&&this.backendConnector.saveMissing(C,u,D,ie,T,s),this.emit("missingKey",C,u,D,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?V.forEach(C=>{const D=this.pluralResolver.getSuffixes(C,s);A&&s[`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,s[`defaultValue${K}`]||w)})}):te(V,a,w))}c=this.extendTranslation(c,e,s,d,i),P&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(P||R)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,R?c:void 0,s))}return n?(d.res=c,d.usedParams=this.getUsedParamsDetails(s),d):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,p(p({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(O(p({},i),{interpolation:p(p({},this.options.interpolation),i.interpolation)}));const h=g(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const d=e.match(this.interpolator.nestingRegexp);f=d&&d.length}let m=i.replace&&!g(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=p(p({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>(n==null?void 0:n[0])===d[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=g(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&i.applyPostProcessor!==!1&&(e=Le.handle(a,e,t,this.options&&this.options.postProcessPassResolved?p({i18nResolved:O(p({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=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(i)||(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 "${s}" 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 J;if(this.isValidLookup(i))return;r=j;const L=[h];if((J=this.i18nFormat)!=null&&J.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(i)||(n=E,i=this.getResource(j,S,E,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!g(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=p(p({},this.options.interpolation.defaultVariables),s)),!i){s=p({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==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=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(g(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(i){}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(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);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 i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{!r||(this.isSupportedCode(r)?s.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)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}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 i=H(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}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 i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>pe[s]-pe[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const me=(o,e,t,i=".",s=!0)=>{let n=Fe(o,e,t);return!n&&s&&g(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),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)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,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=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!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,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,i,s){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,i,O(p(p({},s),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),$,i,O(p(p({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((d=s==null?void 0:s.interpolation)==null?void 0:d.skipOnVariables)!==void 0?s.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,s);r=g($)?$:""}else if(s&&Object.prototype.hasOwnProperty.call(s,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,i={}){let s,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(;s=this.nestingRegexp.exec(e);){let l=[];r=p({},i),r=r.replace&&!g(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!g(n))return n;g(n)||(n=ae(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,O(p({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const Be=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.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,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=O(p({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(H(i),s),e[r]=a),a(t)}},He=o=>(e,t,i)=>o(H(t),i)(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 i=t.cacheInBuiltFormats?xe:He;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,p({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,O(p({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,p({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,p({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,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,i,s={}){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=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=d.locale||d.lng||s.locale||s.lng||i;m=this.formats[u](a,c,p(p(p({},h),s),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,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.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:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(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,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,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&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].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,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();g(e)&&(e=this.languageUtils.toResolveHierarchy(e)),g(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,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 "${i}" 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(!(i==null||i==="")){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,i,s,d):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,d)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}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(i=>{e[i]=t[i]})}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},_=()=>{},_e=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class z 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 i=ye();this.options=p(p(p({},i),this.options),Se(e)),this.options.interpolation=p(p({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(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!==i.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===i.interpolation.format)&&(f.formatter=s(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(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(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=_),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=_){var n,r;let i=t;const s=g(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();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)})};s?l(s):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),i(u)})}else i(null)}reloadResources(e,t,i){const s=U();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=_),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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 i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=U();this.emit("languageChanging",e);const s=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&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.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||s(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),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=p({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.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)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.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(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=U();return this.options.ns?(g(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=U();g(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.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"],i=((n=this.services)==null?void 0:n.languageUtils)||new de(ye());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new z(e,t)}cloneInstance(e={},t=_){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=O(p(p({},this.options),e),{isClone:!0}),n=new z(s);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)},i){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,s),n.services.resourceStore=n.store}return n.translator=new G(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,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=z.createInstance();y.createInstance=z.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 i=o.find(t);i&&i.each((s,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)}))})}},M=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);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 i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};function Ze(o,e){y.init(p({},o),(i,s)=>{e&&e(y,s,i)});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 i=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...i],globalThis.hiprint.changeLanguage=(s,n)=>{y.changeLanguage(s,(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:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Qe(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{M([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{M([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),M([".svp-header p",".svp-tools .tool-name",".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:i=>{setTimeout(()=>{M([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}exports.default=Ze;exports.translateBySelector=M;
|
|
1
|
+
"use strict";var $e=Object.defineProperty,Pe=Object.defineProperties;var Re=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var ke=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var re=(o,e,t)=>e in o?$e(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,p=(o,e)=>{for(var t in e||(e={}))ke.call(e,t)&&re(o,t,e[t]);if(ne)for(var t of ne(e))Ne.call(e,t)&&re(o,t,e[t]);return o},O=(o,e)=>Pe(o,Re(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((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},ae=o=>o==null?"":""+o,Ee=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},Fe=/###/g,oe=o=>o&&o.indexOf("###")>-1?o.replace(Fe,"."):o,le=o=>!o||g(o),B=(o,e,t)=>{const i=g(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(le(o))return{};const n=oe(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return le(o)?{}:{obj:o,k:oe(i[s])}},ue=(o,e,t)=>{const{obj:i,k:s}=B(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=B(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=B(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},Te=(o,e,t,i)=>{const{obj:s,k:n}=B(o,e,Object);s[n]=s[n]||[],s[n].push(t)},Y=(o,e)=>{const{obj:t,k:i}=B(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,i))return t[i]},je=(o,e,t)=>{const i=Y(o,t);return i!==void 0?i:Y(e,t)},Oe=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?g(o[i])||o[i]instanceof String||g(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):Oe(o[i],e[i],t):o[i]=e[i]);return o},I=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var De={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Ie=o=>g(o)?o.replace(/[&<>"'\/]/g,e=>De[e]):o;class Ae{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 i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Ve=[" ",",","?","!",";"],Ke=new Ae(20),Ue=(o,e,t)=>{e=e||"",t=t||"";const i=Ve.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Ke.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.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 i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},H=o=>o==null?void 0:o.replace("_","-"),Me={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,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class Q{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Me,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,i,s){return s&&!this.debug?null:(g(e[0])&&(e[0]=`${i}${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(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+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(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[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,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):g(i)&&n?a.push(...i.split(n)):a.push(i)));const l=Y(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!g(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ue(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(g(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=Y(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?Oe(l,i,n):l=p(p({},l),i),ue(this.data,a,l),r.silent||this.emit("added",e,t,i)}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(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var we={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const he={},ce=o=>!g(o)&&typeof o!="boolean"&&typeof o!="number";class G extends Z{constructor(e,t={}){super(),Ee(["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 i=p({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ue(e,i,s);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(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:g(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?p({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=p({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.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(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const d=this.resolve(e,s);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=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,L=s.count!==void 0&&!g(s.count),E=G.hasDefaultValue(s),J=L?this.pluralResolver.getSuffix(f,s.count,s):"",F=s.ordinal&&L?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",A=L&&!s.ordinal&&s.count===0,w=A&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${J}`]||s[`defaultValue${F}`]||s.defaultValue;let b=c;j&&!c&&E&&(b=w);const Ce=ce(b),ve=Object.prototype.toString.apply(b);if(j&&b&&Ce&&$.indexOf(ve)<0&&!(g(v)&&Array.isArray(b))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=R,d.usedParams=this.getUsedParamsDetails(s),d):R}if(r){const R=Array.isArray(b),P=R?[]:{},ee=R?S:x;for(const k in b)if(Object.prototype.hasOwnProperty.call(b,k)){const T=`${ee}${r}${k}`;E&&!c?P[k]=this.translate(T,O(p({},s),{defaultValue:ce(w)?w[k]:void 0,joinArrays:!1,ns:l})):P[k]=this.translate(T,O(p({},s),{joinArrays:!1,ns:l})),P[k]===T&&(P[k]=b[k])}c=P}}else if(j&&g(v)&&Array.isArray(c))c=c.join(v),c&&(c=this.extendTranslation(c,e,s,i));else{let R=!1,P=!1;!this.isValidLookup(c)&&E&&(R=!0,c=w),this.isValidLookup(c)||(P=!0,c=a);const k=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:c,T=E&&w!==c&&this.options.updateMissing;if(P||R||T){if(this.logger.log(T?"updateKey":"missingKey",f,u,a,T?w:c),r){const C=this.resolve(a,O(p({},s),{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 W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let C=0;C<W.length;C++)V.push(W[C]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(s.lng||this.language):V.push(s.lng||this.language);const te=(C,D,K)=>{var se;const ie=E&&K!==c?K:k;this.options.missingKeyHandler?this.options.missingKeyHandler(C,u,D,ie,T,s):(se=this.backendConnector)!=null&&se.saveMissing&&this.backendConnector.saveMissing(C,u,D,ie,T,s),this.emit("missingKey",C,u,D,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?V.forEach(C=>{const D=this.pluralResolver.getSuffixes(C,s);A&&s[`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,s[`defaultValue${K}`]||w)})}):te(V,a,w))}c=this.extendTranslation(c,e,s,d,i),P&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(P||R)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,R?c:void 0,s))}return n?(d.res=c,d.usedParams=this.getUsedParamsDetails(s),d):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,p(p({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(O(p({},i),{interpolation:p(p({},this.options.interpolation),i.interpolation)}));const h=g(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const d=e.match(this.interpolator.nestingRegexp);f=d&&d.length}let m=i.replace&&!g(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=p(p({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>(n==null?void 0:n[0])===d[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=g(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&i.applyPostProcessor!==!1&&(e=we.handle(a,e,t,this.options&&this.options.postProcessPassResolved?p({i18nResolved:O(p({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=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(i)||(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 "${s}" 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 J;if(this.isValidLookup(i))return;r=j;const L=[h];if((J=this.i18nFormat)!=null&&J.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(i)||(n=E,i=this.getResource(j,S,E,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!g(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=p(p({},this.options.interpolation.defaultVariables),s)),!i){s=p({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==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=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(g(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(i){}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(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);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 i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{!r||(this.isSupportedCode(r)?s.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)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}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 Be{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 i=H(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}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 i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>pe[s]-pe[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const me=(o,e,t,i=".",s=!0)=>{let n=je(o,e,t);return!n&&s&&g(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},X=o=>o.replace(/\$/g,"$$$$");class He{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)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,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:Ie,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!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,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,i,s){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,i,O(p(p({},s),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),$,i,O(p(p({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((d=s==null?void 0:s.interpolation)==null?void 0:d.skipOnVariables)!==void 0?s.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,s);r=g($)?$:""}else if(s&&Object.prototype.hasOwnProperty.call(s,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,i={}){let s,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(;s=this.nestingRegexp.exec(e);){let l=[];r=p({},i),r=r.replace&&!g(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!g(n))return n;g(n)||(n=ae(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,O(p({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const ze=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.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,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=O(p({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(H(i),s),e[r]=a),a(t)}},Je=o=>(e,t,i)=>o(H(t),i)(e);class We{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?xe:Je;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,p({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,O(p({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,p({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,p({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,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,i,s={}){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}=ze(l);if(this.formats[u]){let m=a;try{const d=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=d.locale||d.lng||s.locale||s.lng||i;m=this.formats[u](a,c,p(p(p({},h),s),d))}catch(d){this.logger.warn(d)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const _e=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class Ye extends Z{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.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:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Te(l.loaded,[n],r),_e(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,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,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&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].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,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();g(e)&&(e=this.languageUtils.toResolveHierarchy(e)),g(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,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 "${i}" 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(!(i==null||i==="")){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,i,s,d):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,d)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}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(i=>{e[i]=t[i]})}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},_=()=>{},Qe=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class z extends Z{constructor(e={},t){if(super(),this.options=Se(e),this.services={},this.logger=N,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 i=ye();this.options=p(p(p({},i),this.options),Se(e)),this.options.interpolation=p(p({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=We;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 Be(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.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===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new He(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Ye(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(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=_),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=_){var n,r;let i=t;const s=g(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();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)})};s?l(s):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),i(u)})}else i(null)}reloadResources(e,t,i){const s=U();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=_),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&we.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 i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=U();this.emit("languageChanging",e);const s=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&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.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||s(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),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=p({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.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)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.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(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=U();return this.options.ns?(g(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=U();g(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.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"],i=((n=this.services)==null?void 0:n.languageUtils)||new de(ye());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new z(e,t)}cloneInstance(e={},t=_){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=O(p(p({},this.options),e),{isClone:!0}),n=new z(s);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)},i){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,s),n.services.resourceStore=n.store}return n.translator=new G(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,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=z.createInstance();y.createInstance=z.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=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,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)}))})}},M=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);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)}))})}},Ze=(o,e)=>{Ge(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},Xe=()=>{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 i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};let be=!1;const Le=o=>{if(be)return;be=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...e],globalThis.hiprint.changeLanguage=(t,i)=>{y.changeLanguage(t,(s,n)=>{i&&i(s,n),Xe()})}};function qe(o,e){y.init(p({},o),(i,s)=>{e&&e(y,s,i)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"\u6DFB\u52A0 i18n \u65B9\u6CD5",priority:1,run:()=>{Le(o)}},{hook:"getOptionItem",name:"i18n options",description:"\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Ze(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;Le(o);const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{M([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{M([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),M([".svp-header p",".svp-tools .tool-name",".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:i=>{setTimeout(()=>{M([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}exports.default=qe;exports.translateBySelector=M;
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var $e = Object.defineProperty, Re = Object.defineProperties;
|
|
2
|
+
var Pe = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var ne = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var re = (o, e, t) => e in o ?
|
|
4
|
+
var ke = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var re = (o, e, t) => e in o ? $e(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, p = (o, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
ke.call(e, t) && re(o, t, e[t]);
|
|
8
8
|
if (ne)
|
|
9
9
|
for (var t of ne(e))
|
|
10
|
-
|
|
10
|
+
Ne.call(e, t) && re(o, t, e[t]);
|
|
11
11
|
return o;
|
|
12
|
-
}, O = (o, e) =>
|
|
12
|
+
}, O = (o, e) => Re(o, Pe(e));
|
|
13
13
|
const g = (o) => typeof o == "string", U = () => {
|
|
14
14
|
let o, e;
|
|
15
15
|
const t = new Promise((i, s) => {
|
|
16
16
|
o = i, e = s;
|
|
17
17
|
});
|
|
18
18
|
return t.resolve = o, t.reject = e, t;
|
|
19
|
-
}, ae = (o) => o == null ? "" : "" + o,
|
|
19
|
+
}, ae = (o) => o == null ? "" : "" + o, Ee = (o, e, t) => {
|
|
20
20
|
o.forEach((i) => {
|
|
21
21
|
e[i] && (t[i] = e[i]);
|
|
22
22
|
});
|
|
23
|
-
},
|
|
23
|
+
}, Fe = /###/g, oe = (o) => o && o.indexOf("###") > -1 ? o.replace(Fe, ".") : o, le = (o) => !o || g(o), M = (o, e, t) => {
|
|
24
24
|
const i = g(e) ? e.split(".") : e;
|
|
25
25
|
let s = 0;
|
|
26
26
|
for (; s < i.length - 1; ) {
|
|
@@ -46,7 +46,7 @@ const g = (o) => typeof o == "string", U = () => {
|
|
|
46
46
|
for (; a.obj === void 0 && r.length; )
|
|
47
47
|
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);
|
|
48
48
|
a.obj[`${a.k}.${n}`] = t;
|
|
49
|
-
},
|
|
49
|
+
}, Te = (o, e, t, i) => {
|
|
50
50
|
const {
|
|
51
51
|
obj: s,
|
|
52
52
|
k: n
|
|
@@ -59,15 +59,15 @@ const g = (o) => typeof o == "string", U = () => {
|
|
|
59
59
|
} = M(o, e);
|
|
60
60
|
if (!!t && !!Object.prototype.hasOwnProperty.call(t, i))
|
|
61
61
|
return t[i];
|
|
62
|
-
},
|
|
62
|
+
}, je = (o, e, t) => {
|
|
63
63
|
const i = Y(o, t);
|
|
64
64
|
return i !== void 0 ? i : Y(e, t);
|
|
65
|
-
},
|
|
65
|
+
}, Oe = (o, e, t) => {
|
|
66
66
|
for (const i in e)
|
|
67
|
-
i !== "__proto__" && i !== "constructor" && (i in o ? g(o[i]) || o[i] instanceof String || g(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) :
|
|
67
|
+
i !== "__proto__" && i !== "constructor" && (i in o ? g(o[i]) || o[i] instanceof String || g(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) : Oe(o[i], e[i], t) : o[i] = e[i]);
|
|
68
68
|
return o;
|
|
69
69
|
}, I = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
70
|
-
var
|
|
70
|
+
var De = {
|
|
71
71
|
"&": "&",
|
|
72
72
|
"<": "<",
|
|
73
73
|
">": ">",
|
|
@@ -75,8 +75,8 @@ var Te = {
|
|
|
75
75
|
"'": "'",
|
|
76
76
|
"/": "/"
|
|
77
77
|
};
|
|
78
|
-
const
|
|
79
|
-
class
|
|
78
|
+
const Ie = (o) => g(o) ? o.replace(/[&<>"'\/]/g, (e) => De[e]) : o;
|
|
79
|
+
class Ae {
|
|
80
80
|
constructor(e) {
|
|
81
81
|
this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
|
|
82
82
|
}
|
|
@@ -88,12 +88,12 @@ class De {
|
|
|
88
88
|
return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const Ve = [" ", ",", "?", "!", ";"], Ke = new Ae(20), Ue = (o, e, t) => {
|
|
92
92
|
e = e || "", t = t || "";
|
|
93
|
-
const i =
|
|
93
|
+
const i = Ve.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
|
|
94
94
|
if (i.length === 0)
|
|
95
95
|
return !0;
|
|
96
|
-
const s =
|
|
96
|
+
const s = Ke.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
|
|
97
97
|
let n = !s.test(o);
|
|
98
98
|
if (!n) {
|
|
99
99
|
const r = o.indexOf(t);
|
|
@@ -121,7 +121,7 @@ const Ie = [" ", ",", "?", "!", ";"], Ae = new De(20), Ve = (o, e, t) => {
|
|
|
121
121
|
s = r;
|
|
122
122
|
}
|
|
123
123
|
return s;
|
|
124
|
-
}, B = (o) => o == null ? void 0 : o.replace("_", "-"),
|
|
124
|
+
}, B = (o) => o == null ? void 0 : o.replace("_", "-"), Me = {
|
|
125
125
|
type: "logger",
|
|
126
126
|
log(o) {
|
|
127
127
|
this.output("log", o);
|
|
@@ -142,7 +142,7 @@ class Q {
|
|
|
142
142
|
this.init(e, t);
|
|
143
143
|
}
|
|
144
144
|
init(e, t = {}) {
|
|
145
|
-
this.prefix = t.prefix || "i18next:", this.logger = e ||
|
|
145
|
+
this.prefix = t.prefix || "i18next:", this.logger = e || Me, this.options = t, this.debug = t.debug;
|
|
146
146
|
}
|
|
147
147
|
log(...e) {
|
|
148
148
|
return this.forward(e, "log", "", !0);
|
|
@@ -244,7 +244,7 @@ class fe extends Z {
|
|
|
244
244
|
let a = [e, t];
|
|
245
245
|
e.indexOf(".") > -1 && (a = e.split("."), s = i, i = t, t = a[1]), this.addNamespaces(t);
|
|
246
246
|
let l = Y(this.data, a) || {};
|
|
247
|
-
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ?
|
|
247
|
+
r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ? Oe(l, i, n) : l = p(p({}, l), i), ue(this.data, a, l), r.silent || this.emit("added", e, t, i);
|
|
248
248
|
}
|
|
249
249
|
removeResourceBundle(e, t) {
|
|
250
250
|
this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
|
|
@@ -266,7 +266,7 @@ class fe extends Z {
|
|
|
266
266
|
return this.data;
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
var
|
|
269
|
+
var we = {
|
|
270
270
|
processors: {},
|
|
271
271
|
addPostProcessor(o) {
|
|
272
272
|
this.processors[o.name] = o;
|
|
@@ -281,7 +281,7 @@ var Le = {
|
|
|
281
281
|
const he = {}, ce = (o) => !g(o) && typeof o != "boolean" && typeof o != "number";
|
|
282
282
|
class G extends Z {
|
|
283
283
|
constructor(e, t = {}) {
|
|
284
|
-
super(),
|
|
284
|
+
super(), Ee(["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");
|
|
285
285
|
}
|
|
286
286
|
changeLanguage(e) {
|
|
287
287
|
e && (this.language = e);
|
|
@@ -300,7 +300,7 @@ class G extends Z {
|
|
|
300
300
|
i === void 0 && (i = ":");
|
|
301
301
|
const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
|
|
302
302
|
let n = t.ns || this.options.defaultNS || [];
|
|
303
|
-
const r = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !
|
|
303
|
+
const r = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !Ue(e, i, s);
|
|
304
304
|
if (r && !a) {
|
|
305
305
|
const l = e.match(this.interpolator.nestingRegexp);
|
|
306
306
|
if (l && l.length > 0)
|
|
@@ -351,8 +351,8 @@ class G extends Z {
|
|
|
351
351
|
}) : "", A = L && !s.ordinal && s.count === 0, w = A && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${z}`] || s[`defaultValue${F}`] || s.defaultValue;
|
|
352
352
|
let b = c;
|
|
353
353
|
j && !c && E && (b = w);
|
|
354
|
-
const
|
|
355
|
-
if (j && b &&
|
|
354
|
+
const Ce = ce(b), ve = Object.prototype.toString.apply(b);
|
|
355
|
+
if (j && b && Ce && $.indexOf(ve) < 0 && !(g(v) && Array.isArray(b))) {
|
|
356
356
|
if (!s.returnObjects && !this.options.returnObjects) {
|
|
357
357
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
358
358
|
const P = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({}, s), {
|
|
@@ -436,7 +436,7 @@ class G extends Z {
|
|
|
436
436
|
!i.lng && s && s.res && (i.lng = this.language || s.usedLng), i.nest !== !1 && (e = this.interpolator.nest(e, (...d) => (n == null ? void 0 : n[0]) === d[0] && !i.context ? (this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`), null) : this.translate(...d, t), i)), i.interpolation && this.interpolator.reset();
|
|
437
437
|
}
|
|
438
438
|
const r = i.postProcess || this.options.postProcess, a = g(r) ? [r] : r;
|
|
439
|
-
return e != null && (a == null ? void 0 : a.length) && i.applyPostProcessor !== !1 && (e =
|
|
439
|
+
return e != null && (a == null ? void 0 : a.length) && i.applyPostProcessor !== !1 && (e = we.handle(a, e, t, this.options && this.options.postProcessPassResolved ? p({
|
|
440
440
|
i18nResolved: O(p({}, s), {
|
|
441
441
|
usedParams: this.getUsedParamsDetails(i)
|
|
442
442
|
})
|
|
@@ -597,7 +597,7 @@ const pe = {
|
|
|
597
597
|
pluralCategories: ["one", "other"]
|
|
598
598
|
})
|
|
599
599
|
};
|
|
600
|
-
class
|
|
600
|
+
class Be {
|
|
601
601
|
constructor(e, t = {}) {
|
|
602
602
|
this.languageUtils = e, this.options = t, this.logger = N.create("pluralResolver"), this.pluralRulesCache = {};
|
|
603
603
|
}
|
|
@@ -646,10 +646,10 @@ class Ue {
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
const me = (o, e, t, i = ".", s = !0) => {
|
|
649
|
-
let n =
|
|
649
|
+
let n = je(o, e, t);
|
|
650
650
|
return !n && s && g(t) && (n = q(o, t, i), n === void 0 && (n = q(e, t, i))), n;
|
|
651
651
|
}, X = (o) => o.replace(/\$/g, "$$$$");
|
|
652
|
-
class
|
|
652
|
+
class He {
|
|
653
653
|
constructor(e = {}) {
|
|
654
654
|
var t;
|
|
655
655
|
this.logger = N.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((i) => i), this.init(e);
|
|
@@ -677,7 +677,7 @@ class Me {
|
|
|
677
677
|
maxReplaces: $,
|
|
678
678
|
alwaysFormat: v
|
|
679
679
|
} = e.interpolation;
|
|
680
|
-
this.escape = t !== void 0 ? t :
|
|
680
|
+
this.escape = t !== void 0 ? t : Ie, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !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();
|
|
681
681
|
}
|
|
682
682
|
reset() {
|
|
683
683
|
this.options && this.init(this.options);
|
|
@@ -763,7 +763,7 @@ class Me {
|
|
|
763
763
|
return e;
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
|
-
const
|
|
766
|
+
const ze = (o) => {
|
|
767
767
|
let e = o.toLowerCase().trim();
|
|
768
768
|
const t = {};
|
|
769
769
|
if (o.indexOf("(") > -1) {
|
|
@@ -792,8 +792,8 @@ const Be = (o) => {
|
|
|
792
792
|
let a = e[r];
|
|
793
793
|
return a || (a = o(B(i), s), e[r] = a), a(t);
|
|
794
794
|
};
|
|
795
|
-
},
|
|
796
|
-
class
|
|
795
|
+
}, Je = (o) => (e, t, i) => o(B(t), i)(e);
|
|
796
|
+
class We {
|
|
797
797
|
constructor(e = {}) {
|
|
798
798
|
this.logger = N.create("formatter"), this.options = e, this.init(e);
|
|
799
799
|
}
|
|
@@ -801,7 +801,7 @@ class ze {
|
|
|
801
801
|
interpolation: {}
|
|
802
802
|
}) {
|
|
803
803
|
this.formatSeparator = t.interpolation.formatSeparator || ",";
|
|
804
|
-
const i = t.cacheInBuiltFormats ? xe :
|
|
804
|
+
const i = t.cacheInBuiltFormats ? xe : Je;
|
|
805
805
|
this.formats = {
|
|
806
806
|
number: i((s, n) => {
|
|
807
807
|
const r = new Intl.NumberFormat(s, p({}, n));
|
|
@@ -844,7 +844,7 @@ class ze {
|
|
|
844
844
|
const {
|
|
845
845
|
formatName: u,
|
|
846
846
|
formatOptions: h
|
|
847
|
-
} =
|
|
847
|
+
} = ze(l);
|
|
848
848
|
if (this.formats[u]) {
|
|
849
849
|
let m = a;
|
|
850
850
|
try {
|
|
@@ -860,10 +860,10 @@ class ze {
|
|
|
860
860
|
}, e);
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
|
-
const
|
|
863
|
+
const _e = (o, e) => {
|
|
864
864
|
o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
|
|
865
865
|
};
|
|
866
|
-
class
|
|
866
|
+
class Ye extends Z {
|
|
867
867
|
constructor(e, t, i, s = {}) {
|
|
868
868
|
var n, r;
|
|
869
869
|
super(), this.backend = e, this.store = t, this.services = i, this.languageUtils = i.languageUtils, this.options = s, this.logger = N.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = s.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = s.maxRetries >= 0 ? s.maxRetries : 5, this.retryTimeout = s.retryTimeout >= 1 ? s.retryTimeout : 350, this.state = {}, this.queue = [], (r = (n = this.backend) == null ? void 0 : n.init) == null || r.call(n, i, s.backend, s);
|
|
@@ -896,7 +896,7 @@ class We extends Z {
|
|
|
896
896
|
}), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
|
|
897
897
|
const a = {};
|
|
898
898
|
this.queue.forEach((l) => {
|
|
899
|
-
|
|
899
|
+
Te(l.loaded, [n], r), _e(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
|
|
900
900
|
a[u] || (a[u] = {});
|
|
901
901
|
const h = l.loaded[u];
|
|
902
902
|
h.length && h.forEach((f) => {
|
|
@@ -1056,7 +1056,7 @@ const ye = () => ({
|
|
|
1056
1056
|
var e, t;
|
|
1057
1057
|
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;
|
|
1058
1058
|
}, W = () => {
|
|
1059
|
-
},
|
|
1059
|
+
}, Qe = (o) => {
|
|
1060
1060
|
Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
|
|
1061
1061
|
typeof o[t] == "function" && (o[t] = o[t].bind(o));
|
|
1062
1062
|
});
|
|
@@ -1065,7 +1065,7 @@ class H extends Z {
|
|
|
1065
1065
|
constructor(e = {}, t) {
|
|
1066
1066
|
if (super(), this.options = Se(e), this.services = {}, this.logger = N, this.modules = {
|
|
1067
1067
|
external: []
|
|
1068
|
-
},
|
|
1068
|
+
}, Qe(this), t && !this.isInitialized && !e.isClone) {
|
|
1069
1069
|
if (!this.options.initAsync)
|
|
1070
1070
|
return this.init(e, t), this;
|
|
1071
1071
|
setTimeout(() => {
|
|
@@ -1081,16 +1081,16 @@ class H extends Z {
|
|
|
1081
1081
|
if (!this.options.isClone) {
|
|
1082
1082
|
this.modules.logger ? N.init(s(this.modules.logger), this.options) : N.init(null, this.options);
|
|
1083
1083
|
let u;
|
|
1084
|
-
this.modules.formatter ? u = this.modules.formatter : u =
|
|
1084
|
+
this.modules.formatter ? u = this.modules.formatter : u = We;
|
|
1085
1085
|
const h = new de(this.options);
|
|
1086
1086
|
this.store = new fe(this.options.resources, this.options);
|
|
1087
1087
|
const f = this.services;
|
|
1088
|
-
f.logger = N, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new
|
|
1088
|
+
f.logger = N, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
|
|
1089
1089
|
prepend: this.options.pluralSeparator,
|
|
1090
1090
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1091
|
-
}), this.options.interpolation.format && this.options.interpolation.format !== i.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 === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new
|
|
1091
|
+
}), this.options.interpolation.format && this.options.interpolation.format !== i.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 === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new He(this.options), f.utils = {
|
|
1092
1092
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1093
|
-
}, f.backendConnector = new
|
|
1093
|
+
}, f.backendConnector = new Ye(s(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (d, ...c) => {
|
|
1094
1094
|
this.emit(d, ...c);
|
|
1095
1095
|
}), this.modules.languageDetector && (f.languageDetector = s(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = s(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new G(this.services, this.options), this.translator.on("*", (d, ...c) => {
|
|
1096
1096
|
this.emit(d, ...c);
|
|
@@ -1148,7 +1148,7 @@ class H extends Z {
|
|
|
1148
1148
|
throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1149
1149
|
if (!e.type)
|
|
1150
1150
|
throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1151
|
-
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" &&
|
|
1151
|
+
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" && we.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1152
1152
|
}
|
|
1153
1153
|
setResolvedLanguage(e) {
|
|
1154
1154
|
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
|
|
@@ -1301,7 +1301,7 @@ y.setDefaultNamespace;
|
|
|
1301
1301
|
y.hasLoadedNamespace;
|
|
1302
1302
|
y.loadNamespaces;
|
|
1303
1303
|
y.loadLanguages;
|
|
1304
|
-
const
|
|
1304
|
+
const Ge = (o, e) => {
|
|
1305
1305
|
for (const t of e) {
|
|
1306
1306
|
const i = o.find(t);
|
|
1307
1307
|
i && i.each((s, n) => {
|
|
@@ -1339,8 +1339,8 @@ const Ye = (o, e) => {
|
|
|
1339
1339
|
}));
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
1342
|
-
},
|
|
1343
|
-
|
|
1342
|
+
}, Ze = (o, e) => {
|
|
1343
|
+
Ge(e, [
|
|
1344
1344
|
".hiprint-option-item-label",
|
|
1345
1345
|
"textarea",
|
|
1346
1346
|
"input",
|
|
@@ -1351,7 +1351,7 @@ const Ye = (o, e) => {
|
|
|
1351
1351
|
".hiprint-option-title",
|
|
1352
1352
|
".hiprint-option-item-desc"
|
|
1353
1353
|
]);
|
|
1354
|
-
},
|
|
1354
|
+
}, Xe = () => {
|
|
1355
1355
|
document.querySelectorAll("[data-i18n]").forEach((o) => {
|
|
1356
1356
|
const e = o.getAttribute("data-i18n");
|
|
1357
1357
|
if (!e.includes("[")) {
|
|
@@ -1365,7 +1365,19 @@ const Ye = (o, e) => {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
});
|
|
1367
1367
|
};
|
|
1368
|
-
|
|
1368
|
+
let be = !1;
|
|
1369
|
+
const Le = (o) => {
|
|
1370
|
+
if (be)
|
|
1371
|
+
return;
|
|
1372
|
+
be = !0, globalThis.hiprint.i18next = y, globalThis.hiprint.t = y.t;
|
|
1373
|
+
const e = Object.keys(o.resources || {});
|
|
1374
|
+
globalThis.hiprint.languages = ["\u7B80\u4F53\u4E2D\u6587", ...e], globalThis.hiprint.changeLanguage = (t, i) => {
|
|
1375
|
+
y.changeLanguage(t, (s, n) => {
|
|
1376
|
+
i && i(s, n), Xe();
|
|
1377
|
+
});
|
|
1378
|
+
};
|
|
1379
|
+
};
|
|
1380
|
+
function et(o, e) {
|
|
1369
1381
|
y.init(p({}, o), (i, s) => {
|
|
1370
1382
|
e && e(y, s, i);
|
|
1371
1383
|
});
|
|
@@ -1380,13 +1392,7 @@ function Xe(o, e) {
|
|
|
1380
1392
|
description: "\u6DFB\u52A0 i18n \u65B9\u6CD5",
|
|
1381
1393
|
priority: 1,
|
|
1382
1394
|
run: () => {
|
|
1383
|
-
|
|
1384
|
-
const i = Object.keys(o.resources || {});
|
|
1385
|
-
globalThis.hiprint.languages = ["\u7B80\u4F53\u4E2D\u6587", ...i], globalThis.hiprint.changeLanguage = (s, n) => {
|
|
1386
|
-
y.changeLanguage(s, (r, a) => {
|
|
1387
|
-
n && n(r, a), Ge();
|
|
1388
|
-
});
|
|
1389
|
-
};
|
|
1395
|
+
Le(o);
|
|
1390
1396
|
}
|
|
1391
1397
|
},
|
|
1392
1398
|
{
|
|
@@ -1402,7 +1408,7 @@ function Xe(o, e) {
|
|
|
1402
1408
|
const r = s.call(i, ...n);
|
|
1403
1409
|
return t.some((a) => a == i.name) && r.attr("data-name") || (r.attr({
|
|
1404
1410
|
"data-name": i.name
|
|
1405
|
-
}),
|
|
1411
|
+
}), Ze(i, r)), r;
|
|
1406
1412
|
}, i;
|
|
1407
1413
|
}
|
|
1408
1414
|
}
|
|
@@ -1414,6 +1420,7 @@ function Xe(o, e) {
|
|
|
1414
1420
|
priority: 1,
|
|
1415
1421
|
run: ({ hiprint: i, designerUtils: s }) => {
|
|
1416
1422
|
var a;
|
|
1423
|
+
Le(o);
|
|
1417
1424
|
const n = (a = s.printTemplate) == null ? void 0 : a.id;
|
|
1418
1425
|
n && (globalThis.hinnn.event.on("PrintElementSelectEventKey_" + n, (l) => {
|
|
1419
1426
|
setTimeout(() => {
|
|
@@ -1449,6 +1456,6 @@ function Xe(o, e) {
|
|
|
1449
1456
|
};
|
|
1450
1457
|
}
|
|
1451
1458
|
export {
|
|
1452
|
-
|
|
1459
|
+
et as default,
|
|
1453
1460
|
_ as translateBySelector
|
|
1454
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.index={}))})(this,function(b){"use strict";var Ye=Object.defineProperty,Qe=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var Ze=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable;var Oe=(b,d,L)=>d in b?Ye(b,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):b[d]=L,g=(b,d)=>{for(var L in d||(d={}))Ze.call(d,L)&&Oe(b,L,d[L]);if(Le)for(var L of Le(d))Xe.call(d,L)&&Oe(b,L,d[L]);return b},C=(b,d)=>Qe(b,Ge(d));const d=o=>typeof o=="string",L=()=>{let o,e;const t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},te=o=>o==null?"":""+o,we=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},Ce=/###/g,ie=o=>o&&o.indexOf("###")>-1?o.replace(Ce,"."):o,se=o=>!o||d(o),K=(o,e,t)=>{const i=d(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(se(o))return{};const n=ie(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return se(o)?{}:{obj:o,k:ie(i[s])}},ne=(o,e,t)=>{const{obj:i,k:s}=K(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=K(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=K(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},ve=(o,e,t,i)=>{const{obj:s,k:n}=K(o,e,Object);s[n]=s[n]||[],s[n].push(t)},W=(o,e)=>{const{obj:t,k:i}=K(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,i))return t[i]},$e=(o,e,t)=>{const i=W(o,t);return i!==void 0?i:W(e,t)},re=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?d(o[i])||o[i]instanceof String||d(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):re(o[i],e[i],t):o[i]=e[i]);return o},V=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Pe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Re=o=>d(o)?o.replace(/[&<>"'\/]/g,e=>Pe[e]):o;class ke{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 i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Ne=[" ",",","?","!",";"],Ee=new ke(20),Fe=(o,e,t)=>{e=e||"",t=t||"";const i=Ne.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Ee.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.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 i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},U=o=>o==null?void 0:o.replace("_","-"),Te={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,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class _{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Te,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,i,s){return s&&!this.debug?null:(d(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new _(this.logger,g({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new _(this.logger,e)}}var N=new _;class Y{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+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(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}}class ae extends Y{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,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):d(i)&&n?a.push(...i.split(n)):a.push(i)));const l=W(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!d(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ne(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(d(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=W(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?re(l,i,n):l=g(g({},l),i),ne(this.data,a,l),r.silent||this.emit("added",e,t,i)}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(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var oe={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const le={},ue=o=>!d(o)&&typeof o!="boolean"&&typeof o!="number";class Q extends Y{constructor(e,t={}){super(),we(["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 i=g({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Fe(e,i,s);if(r&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:d(n)?[n]:n};const u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:d(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?g({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=g({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.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(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const p=this.resolve(e,s);let c=p==null?void 0:p.res;const x=(p==null?void 0:p.usedKey)||a,S=(p==null?void 0:p.exactUsedKey)||a,R=["[object Number]","[object Function]","[object RegExp]"],P=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject,w=s.count!==void 0&&!d(s.count),T=Q.hasDefaultValue(s),Z=w?this.pluralResolver.getSuffix(f,s.count,s):"",j=s.ordinal&&w?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",H=w&&!s.ordinal&&s.count===0,v=H&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${Z}`]||s[`defaultValue${j}`]||s.defaultValue;let O=c;I&&!c&&T&&(O=v);const We=ue(O),_e=Object.prototype.toString.apply(O);if(I&&O&&We&&R.indexOf(_e)<0&&!(d(P)&&Array.isArray(O))){if(!s.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,C(g({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(p.res=E,p.usedParams=this.getUsedParamsDetails(s),p):E}if(r){const E=Array.isArray(O),k=E?[]:{},xe=E?S:x;for(const F in O)if(Object.prototype.hasOwnProperty.call(O,F)){const D=`${xe}${r}${F}`;T&&!c?k[F]=this.translate(D,C(g({},s),{defaultValue:ue(v)?v[F]:void 0,joinArrays:!1,ns:l})):k[F]=this.translate(D,C(g({},s),{joinArrays:!1,ns:l})),k[F]===D&&(k[F]=O[F])}c=k}}else if(I&&d(P)&&Array.isArray(c))c=c.join(P),c&&(c=this.extendTranslation(c,e,s,i));else{let E=!1,k=!1;!this.isValidLookup(c)&&T&&(E=!0,c=v),this.isValidLookup(c)||(k=!0,c=a);const F=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&k?void 0:c,D=T&&v!==c&&this.options.updateMissing;if(k||E||D){if(this.logger.log(D?"updateKey":"missingKey",f,u,a,D?v:c),r){const $=this.resolve(a,C(g({},s),{keySeparator:!1}));$&&$.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 z=[];const X=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&X&&X[0])for(let $=0;$<X.length;$++)z.push(X[$]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(s.lng||this.language):z.push(s.lng||this.language);const ye=($,A,J)=>{var be;const Se=T&&J!==c?J:F;this.options.missingKeyHandler?this.options.missingKeyHandler($,u,A,Se,D,s):(be=this.backendConnector)!=null&&be.saveMissing&&this.backendConnector.saveMissing($,u,A,Se,D,s),this.emit("missingKey",$,u,A,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?z.forEach($=>{const A=this.pluralResolver.getSuffixes($,s);H&&s[`defaultValue${this.options.pluralSeparator}zero`]&&A.indexOf(`${this.options.pluralSeparator}zero`)<0&&A.push(`${this.options.pluralSeparator}zero`),A.forEach(J=>{ye([$],a+J,s[`defaultValue${J}`]||v)})}):ye(z,a,v))}c=this.extendTranslation(c,e,s,p,i),k&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(k||E)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,E?c:void 0,s))}return n?(p.res=c,p.usedParams=this.getUsedParamsDetails(s),p):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,g(g({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(C(g({},i),{interpolation:g(g({},this.options.interpolation),i.interpolation)}));const h=d(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const p=e.match(this.interpolator.nestingRegexp);f=p&&p.length}let m=i.replace&&!d(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=g(g({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const p=e.match(this.interpolator.nestingRegexp),c=p&&p.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...p)=>(n==null?void 0:n[0])===p[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`),null):this.translate(...p,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=d(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&i.applyPostProcessor!==!1&&(e=oe.handle(a,e,t,this.options&&this.options.postProcessPassResolved?g({i18nResolved:C(g({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return d(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.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);f.forEach(S=>{var R,P;this.isValidLookup(i)||(a=S,!le[`${x[0]}-${S}`]&&((R=this.utils)==null?void 0:R.hasLoadedNamespace)&&!((P=this.utils)!=null&&P.hasLoadedNamespace(a))&&(le[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" 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(I=>{var Z;if(this.isValidLookup(i))return;r=I;const w=[h];if((Z=this.i18nFormat)!=null&&Z.addLookupKeys)this.i18nFormat.addLookupKeys(w,h,I,S,t);else{let j;m&&(j=this.pluralResolver.getSuffix(I,t.count,t));const H=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(w.push(h+j),t.ordinal&&j.indexOf(v)===0&&w.push(h+j.replace(v,this.options.pluralSeparator)),p&&w.push(h+H)),c){const O=`${h}${this.options.contextSeparator}${t.context}`;w.push(O),m&&(w.push(O+j),t.ordinal&&j.indexOf(v)===0&&w.push(O+j.replace(v,this.options.pluralSeparator)),p&&w.push(O+H))}}let T;for(;T=w.pop();)this.isValidLookup(i)||(n=T,i=this.getResource(I,S,T,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!d(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=g(g({},this.options.interpolation.defaultVariables),s)),!i){s=g({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class fe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=U(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=U(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(i){}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(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);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)),d(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{!r||(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};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)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}const he={zero:0,one:1,two:2,few:3,many:4,other:5},ce={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class je{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 i=U(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ce;if(!e.match(/-|_/))return ce;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>he[s]-he[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const de=(o,e,t,i=".",s=!0)=>{let n=$e(o,e,t);return!n&&s&&d(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},ee=o=>o.replace(/\$/g,"$$$$");class De{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)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:R,alwaysFormat:P}=e.interpolation;this.escape=t!==void 0?t:Re,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?V(n):r||"{{",this.suffix=a?V(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?V(m):p||V("$t("),this.nestingSuffix=c?V(c):x||V(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=R||1e3,this.alwaysFormat=P!==void 0?P:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,i,s){var p;let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const P=de(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(P,void 0,i,C(g(g({},s),t),{interpolationkey:c})):P}const x=c.split(this.formatSeparator),S=x.shift().trim(),R=x.join(this.formatSeparator).trim();return this.format(de(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),R,i,C(g(g({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((p=s==null?void 0:s.interpolation)==null?void 0:p.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>ee(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?ee(this.escape(c)):ee(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 R=h(e,n,s);r=d(R)?R:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!d(r)&&!this.useRawValueToEscape&&(r=te(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,i={}){let s,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 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{r=JSON.parse(m),u&&(r=g(g({},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(;s=this.nestingRegexp.exec(e);){let l=[];r=g({},i),r=r.replace&&!d(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!d(n))return n;d(n)||(n=te(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,C(g({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const Ie=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.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}},pe=o=>{const e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=C(g({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(U(i),s),e[r]=a),a(t)}},Ae=o=>(e,t,i)=>o(U(t),i)(e);class Ve{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?pe:Ae;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,g({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,C(g({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,g({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,g({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,g({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=pe(t)}format(e,t,i,s={}){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}=Ie(l);if(this.formats[u]){let m=a;try{const p=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=p.locale||p.lng||s.locale||s.lng||i;m=this.formats[u](a,c,g(g(g({},h),s),p))}catch(p){this.logger.warn(p)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const Ke=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class Ue extends Y{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.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:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{ve(l.loaded,[n],r),Ke(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,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,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&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].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,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();d(e)&&(e=this.languageUtils.toResolveHierarchy(e)),d(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,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 "${i}" 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(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const p=C(g({},r),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,i,s,p):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,p)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}const ge=()=>({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]),d(o[1])&&(e.defaultValue=o[1]),d(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),me=o=>{var e,t;return d(o.ns)&&(o.ns=[o.ns]),d(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),d(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},G=()=>{},Me=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class M extends Y{constructor(e={},t){if(super(),this.options=me(e),this.services={},this.logger=N,this.modules={external:[]},Me(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 i=ge();this.options=g(g(g({},i),this.options),me(e)),this.options.interpolation=g(g({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Ve;const h=new fe(this.options);this.store=new ae(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new je(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.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===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new De(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Ue(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Q(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=G),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=L(),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=G){var n,r;let i=t;const s=d(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();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)})};s?l(s):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),i(u)})}else i(null)}reloadResources(e,t,i){const s=L();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=G),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&oe.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 i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=L();this.emit("languageChanging",e);const s=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&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.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=d(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(d(a)?[a]:a);u&&(this.language||s(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),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=g({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.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 d(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.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(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=L();return this.options.ns?(d(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=L();d(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.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"],i=((n=this.services)==null?void 0:n.languageUtils)||new fe(ge());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new M(e,t)}cloneInstance(e={},t=G){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=C(g(g({},this.options),e),{isClone:!0}),n=new M(s);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=g({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=g({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=g({},l[u][f]),h),l[u]),l),{});n.store=new ae(a,s),n.services.resourceStore=n.store}return n.translator=new Q(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,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=M.createInstance();y.createInstance=M.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 Be=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,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)}))})}},B=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);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)}))})}},He=(o,e)=>{Be(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},ze=()=>{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 i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};function Je(o,e){y.init(g({},o),(i,s)=>{e&&e(y,s,i)});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 i=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...i],globalThis.hiprint.changeLanguage=(s,n)=>{y.changeLanguage(s,(r,a)=>{n&&n(r,a),ze()})}}},{hook:"getOptionItem",name:"i18n options",description:"\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),He(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{B([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{B([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),B([".svp-header p",".svp-tools .tool-name",".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:i=>{setTimeout(()=>{B([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}b.default=Je,b.translateBySelector=B,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 Ge=Object.defineProperty,Ze=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var we=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var Ce=(b,d,L)=>d in b?Ge(b,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):b[d]=L,g=(b,d)=>{for(var L in d||(d={}))qe.call(d,L)&&Ce(b,L,d[L]);if(we)for(var L of we(d))et.call(d,L)&&Ce(b,L,d[L]);return b},C=(b,d)=>Ze(b,Xe(d));const d=o=>typeof o=="string",L=()=>{let o,e;const t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},te=o=>o==null?"":""+o,ve=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},$e=/###/g,ie=o=>o&&o.indexOf("###")>-1?o.replace($e,"."):o,se=o=>!o||d(o),K=(o,e,t)=>{const i=d(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(se(o))return{};const n=ie(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return se(o)?{}:{obj:o,k:ie(i[s])}},ne=(o,e,t)=>{const{obj:i,k:s}=K(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=K(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=K(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},Pe=(o,e,t,i)=>{const{obj:s,k:n}=K(o,e,Object);s[n]=s[n]||[],s[n].push(t)},W=(o,e)=>{const{obj:t,k:i}=K(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,i))return t[i]},Re=(o,e,t)=>{const i=W(o,t);return i!==void 0?i:W(e,t)},re=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?d(o[i])||o[i]instanceof String||d(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):re(o[i],e[i],t):o[i]=e[i]);return o},V=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ke={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Ne=o=>d(o)?o.replace(/[&<>"'\/]/g,e=>ke[e]):o;class Ee{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 i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Fe=[" ",",","?","!",";"],Te=new Ee(20),je=(o,e,t)=>{e=e||"",t=t||"";const i=Fe.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Te.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.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 i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},U=o=>o==null?void 0:o.replace("_","-"),Ie={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,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class _{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Ie,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,i,s){return s&&!this.debug?null:(d(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new _(this.logger,g({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new _(this.logger,e)}}var N=new _;class Y{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+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(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}}class ae extends Y{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,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):d(i)&&n?a.push(...i.split(n)):a.push(i)));const l=W(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!d(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ne(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(d(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=W(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?re(l,i,n):l=g(g({},l),i),ne(this.data,a,l),r.silent||this.emit("added",e,t,i)}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(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var oe={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const le={},ue=o=>!d(o)&&typeof o!="boolean"&&typeof o!="number";class Q extends Y{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=N.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const i=g({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!je(e,i,s);if(r&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:d(n)?[n]:n};const u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:d(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?g({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=g({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.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(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const p=this.resolve(e,s);let c=p==null?void 0:p.res;const x=(p==null?void 0:p.usedKey)||a,S=(p==null?void 0:p.exactUsedKey)||a,R=["[object Number]","[object Function]","[object RegExp]"],P=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,D=!this.i18nFormat||this.i18nFormat.handleAsObject,w=s.count!==void 0&&!d(s.count),T=Q.hasDefaultValue(s),Z=w?this.pluralResolver.getSuffix(f,s.count,s):"",j=s.ordinal&&w?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",H=w&&!s.ordinal&&s.count===0,v=H&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${Z}`]||s[`defaultValue${j}`]||s.defaultValue;let O=c;D&&!c&&T&&(O=v);const Ye=ue(O),Qe=Object.prototype.toString.apply(O);if(D&&O&&Ye&&R.indexOf(Qe)<0&&!(d(P)&&Array.isArray(O))){if(!s.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,C(g({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(p.res=E,p.usedParams=this.getUsedParamsDetails(s),p):E}if(r){const E=Array.isArray(O),k=E?[]:{},Se=E?S:x;for(const F in O)if(Object.prototype.hasOwnProperty.call(O,F)){const I=`${Se}${r}${F}`;T&&!c?k[F]=this.translate(I,C(g({},s),{defaultValue:ue(v)?v[F]:void 0,joinArrays:!1,ns:l})):k[F]=this.translate(I,C(g({},s),{joinArrays:!1,ns:l})),k[F]===I&&(k[F]=O[F])}c=k}}else if(D&&d(P)&&Array.isArray(c))c=c.join(P),c&&(c=this.extendTranslation(c,e,s,i));else{let E=!1,k=!1;!this.isValidLookup(c)&&T&&(E=!0,c=v),this.isValidLookup(c)||(k=!0,c=a);const F=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&k?void 0:c,I=T&&v!==c&&this.options.updateMissing;if(k||E||I){if(this.logger.log(I?"updateKey":"missingKey",f,u,a,I?v:c),r){const $=this.resolve(a,C(g({},s),{keySeparator:!1}));$&&$.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 z=[];const X=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&X&&X[0])for(let $=0;$<X.length;$++)z.push(X[$]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(s.lng||this.language):z.push(s.lng||this.language);const be=($,A,J)=>{var Oe;const Le=T&&J!==c?J:F;this.options.missingKeyHandler?this.options.missingKeyHandler($,u,A,Le,I,s):(Oe=this.backendConnector)!=null&&Oe.saveMissing&&this.backendConnector.saveMissing($,u,A,Le,I,s),this.emit("missingKey",$,u,A,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?z.forEach($=>{const A=this.pluralResolver.getSuffixes($,s);H&&s[`defaultValue${this.options.pluralSeparator}zero`]&&A.indexOf(`${this.options.pluralSeparator}zero`)<0&&A.push(`${this.options.pluralSeparator}zero`),A.forEach(J=>{be([$],a+J,s[`defaultValue${J}`]||v)})}):be(z,a,v))}c=this.extendTranslation(c,e,s,p,i),k&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(k||E)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,E?c:void 0,s))}return n?(p.res=c,p.usedParams=this.getUsedParamsDetails(s),p):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,g(g({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(C(g({},i),{interpolation:g(g({},this.options.interpolation),i.interpolation)}));const h=d(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const p=e.match(this.interpolator.nestingRegexp);f=p&&p.length}let m=i.replace&&!d(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=g(g({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const p=e.match(this.interpolator.nestingRegexp),c=p&&p.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...p)=>(n==null?void 0:n[0])===p[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`),null):this.translate(...p,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=d(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&i.applyPostProcessor!==!1&&(e=oe.handle(a,e,t,this.options&&this.options.postProcessPassResolved?g({i18nResolved:C(g({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return d(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.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);f.forEach(S=>{var R,P;this.isValidLookup(i)||(a=S,!le[`${x[0]}-${S}`]&&((R=this.utils)==null?void 0:R.hasLoadedNamespace)&&!((P=this.utils)!=null&&P.hasLoadedNamespace(a))&&(le[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" 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(D=>{var Z;if(this.isValidLookup(i))return;r=D;const w=[h];if((Z=this.i18nFormat)!=null&&Z.addLookupKeys)this.i18nFormat.addLookupKeys(w,h,D,S,t);else{let j;m&&(j=this.pluralResolver.getSuffix(D,t.count,t));const H=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(w.push(h+j),t.ordinal&&j.indexOf(v)===0&&w.push(h+j.replace(v,this.options.pluralSeparator)),p&&w.push(h+H)),c){const O=`${h}${this.options.contextSeparator}${t.context}`;w.push(O),m&&(w.push(O+j),t.ordinal&&j.indexOf(v)===0&&w.push(O+j.replace(v,this.options.pluralSeparator)),p&&w.push(O+H))}}let T;for(;T=w.pop();)this.isValidLookup(i)||(n=T,i=this.getResource(D,S,T,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!d(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=g(g({},this.options.interpolation.defaultVariables),s)),!i){s=g({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class fe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=U(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=U(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(i){}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(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);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)),d(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{!r||(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};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)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}const he={zero:0,one:1,two:2,few:3,many:4,other:5},ce={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class De{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 i=U(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ce;if(!e.match(/-|_/))return ce;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>he[s]-he[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const de=(o,e,t,i=".",s=!0)=>{let n=Re(o,e,t);return!n&&s&&d(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},ee=o=>o.replace(/\$/g,"$$$$");class Ae{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)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:R,alwaysFormat:P}=e.interpolation;this.escape=t!==void 0?t:Ne,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?V(n):r||"{{",this.suffix=a?V(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?V(m):p||V("$t("),this.nestingSuffix=c?V(c):x||V(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=R||1e3,this.alwaysFormat=P!==void 0?P:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,i,s){var p;let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const P=de(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(P,void 0,i,C(g(g({},s),t),{interpolationkey:c})):P}const x=c.split(this.formatSeparator),S=x.shift().trim(),R=x.join(this.formatSeparator).trim();return this.format(de(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),R,i,C(g(g({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((p=s==null?void 0:s.interpolation)==null?void 0:p.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>ee(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?ee(this.escape(c)):ee(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 R=h(e,n,s);r=d(R)?R:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!d(r)&&!this.useRawValueToEscape&&(r=te(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,i={}){let s,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 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{r=JSON.parse(m),u&&(r=g(g({},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(;s=this.nestingRegexp.exec(e);){let l=[];r=g({},i),r=r.replace&&!d(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!d(n))return n;d(n)||(n=te(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,C(g({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const Ve=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.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}},pe=o=>{const e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=C(g({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(U(i),s),e[r]=a),a(t)}},Ke=o=>(e,t,i)=>o(U(t),i)(e);class Ue{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?pe:Ke;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,g({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,C(g({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,g({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,g({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,g({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=pe(t)}format(e,t,i,s={}){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}=Ve(l);if(this.formats[u]){let m=a;try{const p=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=p.locale||p.lng||s.locale||s.lng||i;m=this.formats[u](a,c,g(g(g({},h),s),p))}catch(p){this.logger.warn(p)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const Me=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class Be extends Y{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.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:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Pe(l.loaded,[n],r),Me(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,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,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&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].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,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();d(e)&&(e=this.languageUtils.toResolveHierarchy(e)),d(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,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 "${i}" 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(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const p=C(g({},r),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,i,s,p):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,p)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}const ge=()=>({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]),d(o[1])&&(e.defaultValue=o[1]),d(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),me=o=>{var e,t;return d(o.ns)&&(o.ns=[o.ns]),d(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),d(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},G=()=>{},He=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class M extends Y{constructor(e={},t){if(super(),this.options=me(e),this.services={},this.logger=N,this.modules={external:[]},He(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 i=ge();this.options=g(g(g({},i),this.options),me(e)),this.options.interpolation=g(g({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Ue;const h=new fe(this.options);this.store=new ae(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new De(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.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===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Ae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Be(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Q(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=G),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=L(),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=G){var n,r;let i=t;const s=d(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();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)})};s?l(s):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),i(u)})}else i(null)}reloadResources(e,t,i){const s=L();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=G),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&oe.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 i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=L();this.emit("languageChanging",e);const s=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&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.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=d(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(d(a)?[a]:a);u&&(this.language||s(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),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=g({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.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 d(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.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(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=L();return this.options.ns?(d(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=L();d(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.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"],i=((n=this.services)==null?void 0:n.languageUtils)||new fe(ge());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new M(e,t)}cloneInstance(e={},t=G){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=C(g(g({},this.options),e),{isClone:!0}),n=new M(s);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=g({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=g({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=g({},l[u][f]),h),l[u]),l),{});n.store=new ae(a,s),n.services.resourceStore=n.store}return n.translator=new Q(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,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=M.createInstance();y.createInstance=M.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 ze=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,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)}))})}},B=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);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)}))})}},Je=(o,e)=>{ze(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},We=()=>{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 i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};let xe=!1;const ye=o=>{if(xe)return;xe=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...e],globalThis.hiprint.changeLanguage=(t,i)=>{y.changeLanguage(t,(s,n)=>{i&&i(s,n),We()})}};function _e(o,e){y.init(g({},o),(i,s)=>{e&&e(y,s,i)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"\u6DFB\u52A0 i18n \u65B9\u6CD5",priority:1,run:()=>{ye(o)}},{hook:"getOptionItem",name:"i18n options",description:"\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Je(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;ye(o);const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{B([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{B([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),B([".svp-header p",".svp-tools .tool-name",".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:i=>{setTimeout(()=>{B([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}b.default=_e,b.translateBySelector=B,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sv-print/plugin-i18n",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "sv-print 多语言插件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"svelte": "./dist/index.mjs",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "vite build",
|
|
24
|
+
"build-browserify": "vite build --mode=browserify",
|
|
24
25
|
"pub": "pnpm build && npm --registry https://registry.npmjs.org/ publish --access public",
|
|
25
26
|
"pub-beta": "pnpm build && npm --registry https://registry.npmjs.org/ publish --access public --tag beta"
|
|
26
27
|
},
|
|
@@ -30,11 +31,10 @@
|
|
|
30
31
|
],
|
|
31
32
|
"author": "",
|
|
32
33
|
"license": "MIT",
|
|
33
|
-
"
|
|
34
|
-
"i18next": "^25.3.2",
|
|
34
|
+
"devDependencies": {
|
|
35
35
|
"sv-print": "^0.1.28"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"i18next": "^25.3.2"
|
|
39
39
|
}
|
|
40
40
|
}
|