i18next 26.7.0 → 26.7.2
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 +0 -2
- package/dist/cjs/i18next.js +9 -5
- package/dist/esm/i18next.js +9 -5
- package/dist/esm/package.json +1 -1
- package/dist/umd/i18next.js +9 -5
- package/dist/umd/i18next.min.js +1 -1
- package/i18next.js +9 -5
- package/i18next.min.js +1 -1
- package/index.d.ts +2 -0
- package/package.json +21 -24
package/README.md
CHANGED
|
@@ -62,8 +62,6 @@ A translation management system built around the i18next ecosystem - [Locize](ht
|
|
|
62
62
|
|
|
63
63
|
**Now with a [Free plan](https://www.locize.com/pricing?utm_source=i18next_readme&utm_medium=github&utm_campaign=readme) for small projects!** Perfect for hobbyists or getting started.
|
|
64
64
|
|
|
65
|
-

|
|
66
|
-
|
|
67
65
|
With using [Locize](https://www.locize.com/?utm_source=i18next_readme&utm_medium=github&utm_campaign=readme) you directly support the future of i18next.
|
|
68
66
|
|
|
69
67
|
---
|
package/dist/cjs/i18next.js
CHANGED
|
@@ -993,15 +993,16 @@ class LanguageUtil {
|
|
|
993
993
|
return formatted;
|
|
994
994
|
}
|
|
995
995
|
deprecateBareCode(code, formatted) {
|
|
996
|
-
let
|
|
996
|
+
let canonical;
|
|
997
997
|
try {
|
|
998
|
-
|
|
998
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
999
999
|
} catch (e) {
|
|
1000
1000
|
return;
|
|
1001
1001
|
}
|
|
1002
|
+
let v27 = canonical.toLowerCase() === code.toLowerCase() ? canonical : code.toLowerCase();
|
|
1002
1003
|
if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
|
|
1003
1004
|
if (v27 === formatted) return;
|
|
1004
|
-
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27
|
|
1005
|
+
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27 gives it the canonical casing '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
|
|
1005
1006
|
}
|
|
1006
1007
|
isSupportedCode(code) {
|
|
1007
1008
|
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
@@ -1597,7 +1598,7 @@ class Connector extends EventEmitter {
|
|
|
1597
1598
|
const name = `${lng}|${ns}`;
|
|
1598
1599
|
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
1599
1600
|
this.state[name] = 2;
|
|
1600
|
-
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1601
|
+
} else if (!options.reload && this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1601
1602
|
if (pending[name] === undefined) pending[name] = true;
|
|
1602
1603
|
} else {
|
|
1603
1604
|
this.state[name] = 1;
|
|
@@ -2067,7 +2068,10 @@ class I18n extends EventEmitter {
|
|
|
2067
2068
|
callback = ns;
|
|
2068
2069
|
ns = undefined;
|
|
2069
2070
|
}
|
|
2070
|
-
if (!lngs)
|
|
2071
|
+
if (!lngs) {
|
|
2072
|
+
const requested = Object.keys(this.services.backendConnector.state).map(name => name.split('|')[0]);
|
|
2073
|
+
lngs = [...new Set([...(this.languages || []), ...requested])].filter(l => l !== 'cimode');
|
|
2074
|
+
}
|
|
2071
2075
|
if (!ns) ns = this.options.ns;
|
|
2072
2076
|
if (!callback) callback = noop;
|
|
2073
2077
|
this.services.backendConnector.reload(lngs, ns, err => {
|
package/dist/esm/i18next.js
CHANGED
|
@@ -991,15 +991,16 @@ class LanguageUtil {
|
|
|
991
991
|
return formatted;
|
|
992
992
|
}
|
|
993
993
|
deprecateBareCode(code, formatted) {
|
|
994
|
-
let
|
|
994
|
+
let canonical;
|
|
995
995
|
try {
|
|
996
|
-
|
|
996
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
997
997
|
} catch (e) {
|
|
998
998
|
return;
|
|
999
999
|
}
|
|
1000
|
+
let v27 = canonical.toLowerCase() === code.toLowerCase() ? canonical : code.toLowerCase();
|
|
1000
1001
|
if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
|
|
1001
1002
|
if (v27 === formatted) return;
|
|
1002
|
-
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27
|
|
1003
|
+
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27 gives it the canonical casing '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
|
|
1003
1004
|
}
|
|
1004
1005
|
isSupportedCode(code) {
|
|
1005
1006
|
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
@@ -1595,7 +1596,7 @@ class Connector extends EventEmitter {
|
|
|
1595
1596
|
const name = `${lng}|${ns}`;
|
|
1596
1597
|
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
1597
1598
|
this.state[name] = 2;
|
|
1598
|
-
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1599
|
+
} else if (!options.reload && this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1599
1600
|
if (pending[name] === undefined) pending[name] = true;
|
|
1600
1601
|
} else {
|
|
1601
1602
|
this.state[name] = 1;
|
|
@@ -2065,7 +2066,10 @@ class I18n extends EventEmitter {
|
|
|
2065
2066
|
callback = ns;
|
|
2066
2067
|
ns = undefined;
|
|
2067
2068
|
}
|
|
2068
|
-
if (!lngs)
|
|
2069
|
+
if (!lngs) {
|
|
2070
|
+
const requested = Object.keys(this.services.backendConnector.state).map(name => name.split('|')[0]);
|
|
2071
|
+
lngs = [...new Set([...(this.languages || []), ...requested])].filter(l => l !== 'cimode');
|
|
2072
|
+
}
|
|
2069
2073
|
if (!ns) ns = this.options.ns;
|
|
2070
2074
|
if (!callback) callback = noop;
|
|
2071
2075
|
this.services.backendConnector.reload(lngs, ns, err => {
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"26.7.
|
|
1
|
+
{"type":"module","version":"26.7.2"}
|
package/dist/umd/i18next.js
CHANGED
|
@@ -997,15 +997,16 @@
|
|
|
997
997
|
return formatted;
|
|
998
998
|
}
|
|
999
999
|
deprecateBareCode(code, formatted) {
|
|
1000
|
-
let
|
|
1000
|
+
let canonical;
|
|
1001
1001
|
try {
|
|
1002
|
-
|
|
1002
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
1003
1003
|
} catch (e) {
|
|
1004
1004
|
return;
|
|
1005
1005
|
}
|
|
1006
|
+
let v27 = canonical.toLowerCase() === code.toLowerCase() ? canonical : code.toLowerCase();
|
|
1006
1007
|
if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
|
|
1007
1008
|
if (v27 === formatted) return;
|
|
1008
|
-
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27
|
|
1009
|
+
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27 gives it the canonical casing '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
|
|
1009
1010
|
}
|
|
1010
1011
|
isSupportedCode(code) {
|
|
1011
1012
|
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
@@ -1601,7 +1602,7 @@
|
|
|
1601
1602
|
const name = `${lng}|${ns}`;
|
|
1602
1603
|
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
1603
1604
|
this.state[name] = 2;
|
|
1604
|
-
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1605
|
+
} else if (!options.reload && this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1605
1606
|
if (pending[name] === undefined) pending[name] = true;
|
|
1606
1607
|
} else {
|
|
1607
1608
|
this.state[name] = 1;
|
|
@@ -2071,7 +2072,10 @@
|
|
|
2071
2072
|
callback = ns;
|
|
2072
2073
|
ns = undefined;
|
|
2073
2074
|
}
|
|
2074
|
-
if (!lngs)
|
|
2075
|
+
if (!lngs) {
|
|
2076
|
+
const requested = Object.keys(this.services.backendConnector.state).map(name => name.split('|')[0]);
|
|
2077
|
+
lngs = [...new Set([...(this.languages || []), ...requested])].filter(l => l !== 'cimode');
|
|
2078
|
+
}
|
|
2075
2079
|
if (!ns) ns = this.options.ns;
|
|
2076
2080
|
if (!callback) callback = noop;
|
|
2077
2081
|
this.services.backendConnector.reload(lngs, ns, err => {
|
package/dist/umd/i18next.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).i18next=t()}(this,function(){"use strict";const e=e=>"string"==typeof e,t=()=>{let e,t;const s=new Promise((s,i)=>{e=s,t=i});return s.resolve=e,s.reject=t,s},s=e=>null==e?"":String(e),i=t=>e(t)&&/^[A-Za-z0-9_@.-]{1,128}$/.test(t)&&!t.includes("..")&&!["__proto__","constructor","prototype"].includes(t),o=e=>e?.callbackApi??e?.constructor?.callbackApi,n=/###/g,a=e=>e&&e.includes("###")?e.replace(n,"."):e,r=t=>!t||e(t),l=(t,s,i)=>{const o=e(s)?s.split("."):s;let n=0;for(;n<o.length-1;){if(r(t))return{};const e=a(o[n]);!t[e]&&i&&(t[e]=new i),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++n}return r(t)?{}:{obj:t,k:a(o[n])}},c=(e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);if(void 0!==i||1===t.length)return void(i[o]=s);let n=t[t.length-1],a=t.slice(0,t.length-1),r=l(e,a,Object);for(;void 0===r.obj&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),r=l(e,a,Object),r?.obj&&void 0!==r.obj[`${r.k}.${n}`]&&(r.obj=void 0);r.obj[`${r.k}.${n}`]=s},h=(e,t)=>{const{obj:s,k:i}=l(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,i))return s[i]},u=(t,s,i)=>{for(const o in s)"__proto__"!==o&&"constructor"!==o&&(Object.prototype.hasOwnProperty.call(t,o)?e(t[o])||t[o]instanceof String||e(s[o])||s[o]instanceof String?i&&(t[o]=s[o]):u(t[o],s[o],i):t[o]=s[o]);return t},p=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},d=t=>e(t)?t.replace(/[&<>"'\/]/g,e=>g[e]):t;const f=[" ",",","?","!",";"],m=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}(20),y=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const i=t.split(s);let o=e;for(let e=0;e<i.length;){if(!o||"object"!=typeof o)return;let t,n="";for(let a=e;a<i.length;++a)if(a!==e&&(n+=s),n+=i[a],t=o[n],"function"!=typeof t&&"__proto__"!==n||Object.prototype.hasOwnProperty.call(o,n)||(t=void 0),void 0!==t){if(["string","number","boolean"].includes(typeof t)&&a<i.length-1)continue;e+=a-e+1;break}o=t}return o},b=e=>e?.replace(/_/g,"-"),v={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class k{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||v,this.options=t,this.debug=t.debug,this.seen=new Set}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)}once(e,t,...s){return!this.debug||this.seen.has(e)||this.seen.size>=1e3?null:(this.seen.add(e),this[t](...s))}forward(t,s,i,o){return o&&!this.debug?null:(t=t.map(t=>e(t)?t.replace(/[\r\n\x00-\x1F\x7F]/g," "):t),e(t[0])&&(t[0]=`${i}${this.prefix} ${t[0]}`),this.logger[s](t))}create(e){return new k(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new k(this.logger,e)}}var x=new k;class S{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);const s=this.observers[e].get(t)||0;this.observers[e].set(t,s+1)}),this}off(e,t){("string"==typeof e?e.split(" "):[e]).forEach(e=>{this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])})}once(e,t){const s=(...i)=>{t(...i),this.off(e,s)};return this.on(e,s),this}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach(([e,s])=>{for(let i=0;i<s;i++)e(...t)})}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach(([s,i])=>{for(let o=0;o<i;o++)s(e,...t)})}}}const L=new WeakSet;class w extends S{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.logger=x.create("resourceStore"),void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}deprecateDottedLng(e){this.logger.once(e,"deprecate",`${e}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`)}getResource(t,s,i,o={}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.includes(".")?(this.deprecateDottedLng("getResource"),r=t.split(".")):(r=[t,s],i&&(Array.isArray(i)?r.push(...i):e(i)&&n?r.push(...i.split(n)):r.push(i)));const l=h(this.data,r);return null!=l||s||i||!t.includes(".")||(t=r[0],s=r[1],i=r.slice(2).join(".")),null==l&&a&&e(i)?y(this.data?.[t]?.[s],i,n):l}addResource(e,t,s,i,o={silent:!1}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(n?s.split(n):s)),e.includes(".")&&(this.deprecateDottedLng("addResource"),a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),c(this.data,a,i),o.silent||this.emit("added",e,t,s,i)}addResources(t,s,i,o={silent:!1}){for(const o in i)(e(i[o])||Array.isArray(i[o]))&&this.addResource(t,s,o,i[o],{silent:!0});o.silent||this.emit("added",t,s,i)}addResourceBundle(e,t,s,i,o,n={silent:!1,skipCopy:!1}){let a=[e,t];e.includes(".")&&(this.deprecateDottedLng("addResourceBundle"),a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let r=h(this.data,a)||{};n.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?u(r,s,o):r={...r,...s},c(this.data,a,r),n.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{const s=t[e];return!!L.has(s)||!(!s||0===Object.keys(s).length)&&("object"==typeof s&&L.add(s),!0)})}toJSON(){return this.data}}var $={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,i,o){return e.forEach(e=>{t=this.processors[e]?.process(t,s,i,o)??t}),t}};const O=Symbol("i18next/PATH_KEY");function C(e,t){const{[O]:s}=e(function(){const e=[],t=Object.create(null);let s;return t.get=(i,o)=>(s?.revoke?.(),o===O?e:(e.push(o),s=Proxy.revocable(i,t),s.proxy)),Proxy.revocable(Object.create(null),t).proxy}()),i=t?.keySeparator??".",o=t?.nsSeparator??":",n="strict"===t?.enableSelector;if(s.length>1&&o){const e=t?.ns,a=n?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(a){if((n?a:a.length>1?a.slice(1):[]).includes(s[0]))return`${s[0]}${o}${s.slice(1).join(i)}`}}return s.join(i)}const R=t=>!e(t)&&"boolean"!=typeof t&&"number"!=typeof t;class P extends S{constructor(e,t={}){var s,i;super(),s=e,i=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils","ownPostProcessors"].forEach(e=>{s[e]&&(i[e]=s[e])}),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=x.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const i=this.resolve(e,s);if(void 0===i?.res)return!1;const o=R(i.res);return!1!==s.returnObjects||!o}extractFromKey(t,s){let i=void 0!==s.nsSeparator?s.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");const o=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let n=s.ns||this.options.defaultNS||[];const a=i&&t.includes(i),r=!(this.options.userDefinedKeySeparator||s.keySeparator||this.options.userDefinedNsSeparator||s.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const i=f.filter(e=>!t.includes(e)&&!s.includes(e));if(0===i.length)return!0;const o=m.getRegExp(`(${i.map(e=>"?"===e?"\\?":e).join("|")})`);let n=!o.test(e);if(!n){const t=e.indexOf(s);t>0&&!o.test(e.substring(0,t))&&(n=!0)}return n})(t,i,o));if(a&&!r){const s=t.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:t,namespaces:e(n)?[n]:n};const a=t.split(i);(i!==o||i===o&&this.options.ns.includes(a[0]))&&(n=a.shift()),t=a.join(o)}return{key:t,namespaces:e(n)?[n]:n}}translate(t,s,i){let o="object"==typeof s?{...s}:s;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==t)return"";"function"==typeof t&&(t=C(t,{...this.options,...o})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>"function"==typeof e?C(e,{...this.options,...o}):String(e));const n=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,a=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:r,namespaces:l}=this.extractFromKey(t[t.length-1],o),c=l[l.length-1];let h=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===h&&(h=":");const u=o.lng||this.language,p=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return p?n?{res:`${c}${h}${r}`,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:`${c}${h}${r}`:n?{res:r,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:r;const g=this.resolve(t,o);let d=g?.res;const f=g?.usedKey||r,m=g?.exactUsedKey||r,y=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==o.count&&!e(o.count),k=P.hasDefaultValue(o),x=v?this.pluralResolver.getSuffix(u,o.count,o):"",S=o.ordinal&&v?this.pluralResolver.getSuffix(u,o.count,{ordinal:!1}):"",L=v&&!o.ordinal&&0===o.count,w=L&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${x}`]||o[`defaultValue${S}`]||o.defaultValue;let $=d;b&&!d&&k&&($=w);const O=R($),j=Object.prototype.toString.apply($);if(!(b&&$&&O)||["[object Number]","[object Function]","[object RegExp]"].includes(j)||e(y)&&Array.isArray($))if(b&&e(y)&&Array.isArray(d))d=d.join(y),d&&(d=this.extendTranslation(d,t,o,g,i));else{let e=!1,s=!1;!this.isValidLookup(d)&&k&&(e=!0,d=w),this.isValidLookup(d)||(s=!0,d=r);const n=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:d,l=k&&w!==d&&this.options.updateMissing;if(s||e||l){if(this.logger.log(l?"updateKey":"missingKey",u,c,v&&!l?`${r}${this.pluralResolver.getSuffix(u,o.count,o)}`:r,l?w:d),a){const e=this.resolve(r,{...o,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let s=0;s<t.length;s++)e.push(t[s]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);const s=(e,t,s)=>{const i=k&&s!==d?s:n;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,i,l,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,i,l,o,void 0,this.utils?.hasLoadedNamespace),this.emit("missingKey",e,c,t,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,o);L&&o[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{s([e],r+t,o[`defaultValue${t}`]||w)})}):s(e,r,w))}d=this.extendTranslation(d,t,o,g,i),s&&d===r&&this.options.appendNamespaceToMissingKey&&(d=`${c}${h}${r}`),(s||e)&&this.options.parseMissingKeyHandler&&(d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${r}`:r,e?d:void 0,o))}else{if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||(this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.logger.once("returnedObject","deprecate","accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)"));const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,$,{...o,ns:l}):`key '${r} (${this.language})' returned an object instead of string.`;return n?(g.res=e,g.usedParams=this.getUsedParamsDetails(o),g):e}if(a){const e=Array.isArray($),t=e?[]:{},s=e?m:f;for(const e in $)if(Object.prototype.hasOwnProperty.call($,e)){const i=`${s}${a}${e}`;t[e]=k&&!d?this.translate(i,{...o,defaultValue:R(w)?w[e]:void 0,joinArrays:!1,ns:l}):this.translate(i,{...o,joinArrays:!1,ns:l}),t[e]===i&&(t[e]=$[e])}d=t}}return n?(g.res=d,g.usedParams=this.getUsedParamsDetails(o),g):d}extendTranslation(t,s,i,o,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const a=e(t)&&(void 0!==i?.interpolation?.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(a){const e=t.match(this.interpolator.nestingRegexp);r=e&&e.length}let l=i.replace&&!e(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,i.lng||this.language||o.usedLng,i),a){const e=t.match(this.interpolator.nestingRegexp);r<(e&&e.length)&&(i.nest=!1)}!i.lng&&o&&o.res&&(i.lng=this.language||o.usedLng),!1!==i.nest&&(t=this.interpolator.nest(t,(...e)=>n?.[0]!==e[0]||i.context?this.translate(...e,s):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${s[0]}`),null),i)),i.interpolation&&this.interpolator.reset()}const a=i.postProcess||this.options.postProcess,r=e(a)?[a]:a;return null!=t&&r?.length&&!1!==i.applyPostProcessor&&(r.forEach(e=>{this.logger.debug&&$.processors[e]&&this.ownPostProcessors&&!this.ownPostProcessors.has(e)&&this.logger.once(e,"deprecate",`postProcess: '${e}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`)}),t=$.handle(r,t,s,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),t}resolve(t,s={}){let i,o,n,a,r;return e(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(e=>"function"==typeof e?C(e,{...this.options,...s}):e)),t.forEach(t=>{if(this.isValidLookup(i))return;const l=this.extractFromKey(t,s),c=l.key;o=c;let h=l.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const u=void 0!==s.count&&!e(s.count),p=u&&!s.ordinal&&0===s.count,g=void 0!==s.context&&(e(s.context)||"number"==typeof s.context)&&""!==s.context,d=s.lngs?s.lngs:this.languageUtils.toResolveHierarchy(s.lng||this.language,s.fallbackLng);h.forEach(e=>{this.isValidLookup(i)||(r=e,this.checkedLoadedFor[`${d[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||(this.checkedLoadedFor[`${d[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${d.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach(t=>{if(this.isValidLookup(i))return;a=t;const o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,t,e,s);else{let e;u&&(e=this.pluralResolver.getSuffix(t,s.count,s));const i=`${this.options.pluralSeparator}zero`,n=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(s.ordinal&&e.startsWith(n)&&o.push(c+e.replace(n,this.options.pluralSeparator)),o.push(c+e),p&&o.push(c+i)),g){const t=`${c}${this.options.contextSeparator||"_"}${s.context}`;o.push(t),u&&(s.ordinal&&e.startsWith(n)&&o.push(t+e.replace(n,this.options.pluralSeparator)),o.push(t+e),p&&o.push(t+i))}}let r;for(;r=o.pop();)this.isValidLookup(i)||(n=r,i=this.getResource(t,e,r,s))}))})}),{res:i,usedKey:o,exactUsedKey:n,usedLng:a,usedNS:r}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(t={}){const s=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=t.replace&&!e(t.replace);let o=i?t.replace:t;if(i&&void 0!==t.count&&(o={...o,count:t.count}),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!i){o={...o};for(const e of s)delete o[e]}return o}static hasDefaultValue(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith("defaultValue")&&void 0!==e[t])return!0;return!1}}class j{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=x.create("languageUtils"),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(!(e=b(e))||!e.includes("-"))return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=b(e))||!e.includes("-"))return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(t){if(e(t)&&t.includes("-")){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(e){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}const s=this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t;return this.logger.debug&&e(t)&&this.deprecateBareCode(t,s),s}deprecateBareCode(e,t){let s;try{s=Intl.getCanonicalLocales(e)[0]}catch(e){return}this.options.lowerCaseLng&&(s=s.toLowerCase()),s!==t&&this.logger.once(e,"deprecate",`language code '${e}' is used as '${t}'; i18next v27 canonicalizes it to '${s}', use '${s}' in lng, fallbackLng, supportedLngs and the resources`)}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;const s=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(s)||(t=s)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;const s=this.getScriptPartFromCode(e);if(this.isSupportedCode(s))return t=s;const i=this.getLanguagePartFromCode(e);if(this.isSupportedCode(i))return t=i;t=this.options.supportedLngs.find(e=>e===i||!(!e.includes("-")&&!i.includes("-"))&&!(!e.includes("-")||i.includes("-")||e.slice(0,e.indexOf("-"))!==i))}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(t,s){if(!t)return[];if("function"==typeof t&&(t=t(s)),e(t)&&(t=[t]),Array.isArray(t))return t;if(!s)return t.default||[];let i=t[s];return i||(i=t[this.getScriptPartFromCode(s)]),i||(i=t[this.formatLanguageCode(s)]),i||(i=t[this.getLanguagePartFromCode(s)]),i||(i=t.default),i||[]}toResolveHierarchy(t,s){const i=this.options.fallbackLng,o=Array.isArray(i)?i.join("|"):i;o!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=o);const n=void 0===s||!1===s||e(s),a=void 0===s&&"function"==typeof this.options.fallbackLng;let r=null;if(e(t)&&n&&!a){let e;e=void 0===s?"undefined":!1===s?"boolean:false":`string:${s}`,r=`${t.length}:${t}|${e}`}if(null!==r){const e=this.resolveHierarchyCache[r];if(void 0!==e)return e.slice()}const l=this.getFallbackCodes((!1===s?[]:s)||this.options.fallbackLng||[],t),c=[],h=e=>{e&&(this.isSupportedCode(e)?c.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return e(t)&&(t.includes("-")||t.includes("_"))?("languageOnly"!==this.options.load&&h(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&h(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&h(this.getLanguagePartFromCode(t))):e(t)&&h(this.formatLanguageCode(t)),l.forEach(e=>{const t=this.formatLanguageCode(e);c.includes(t)||h(t)}),null!==r?(this.resolveHierarchyCache[r]=c,c.slice()):c}}const N={zero:0,one:1,two:2,few:3,many:4,other:5},E={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class F{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=x.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=b("dev"===e?"en":e),i=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:s,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let n;try{n=new Intl.PluralRules(s,{type:i})}catch(s){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),E;if(!e.match(/-|_/))return E;const i=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(i,t)}return this.pluralRulesCache[o]=n,n}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((e,t)=>N[e]-N[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const D=(t,s,i,o=".",n=!0)=>{let a=((e,t,s)=>{const i=h(e,s);return void 0!==i?i:h(t,s)})(t,s,i);return null==a&&n&&e(i)&&(a=y(t,i,o),void 0===a&&(a=y(s,i,o))),a};class A{constructor(e={}){this.logger=x.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:o,prefixEscaped:n,suffix:a,suffixEscaped:r,formatSeparator:l,unescapeSuffix:c,unescapePrefix:h,nestingPrefix:u,nestingPrefixEscaped:g,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:v}=e.interpolation;if(n||r||g||m){const e=Object.entries({prefixEscaped:n,suffixEscaped:r,nestingPrefixEscaped:g,nestingSuffixEscaped:m}).filter(([,e])=>e).map(([e])=>e);this.logger.once(e.join(),"deprecate",`interpolation.${e.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`)}this.escape=void 0!==t?t:d,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==i&&i,this.prefix=o?p(o):n||"{{",this.suffix=a?p(a):r||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":h?p(h):"-",this.unescapeSuffix=this.unescapePrefix?"":c?p(c):"",this.nestingPrefix=u?p(u):g||p("$t("),this.nestingSuffix=f?p(f):m||p(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,i,o,n){let a,r,l;const c=t,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){const t=D(i,h,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(t,void 0,o,{...n,...i,interpolationkey:e}):t}const t=e.split(this.formatSeparator),s=t.shift().trim(),a=t.join(this.formatSeparator).trim();return this.format(D(i,h,s,this.options.keySeparator,this.options.ignoreJSONStructure),a,o,{...n,...i,interpolationkey:s})};this.resetRegExp(),!this.escapeValue&&"string"==typeof t&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const p=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,g=void 0!==n?.interpolation?.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,f=[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:t=>this.escapeValue?(this.escape===d&&!1!==this.options?.interpolation?.escapeValue&&e(t)&&t.includes("/")&&this.logger.once("/","deprecate","escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is"),this.escape(t)):t}],m=[];let y=0;return f.forEach(i=>{for(l=0;a=i.regex.exec(t);){const o=a.index-y,h=m.find(([e,t])=>o>=e&&o<t);if(h){i.regex.lastIndex=h[1]+y;continue}const d=a[1].trim();if(r=u(d),void 0===r)if("function"==typeof p){const s=p(t,a,n);r=e(s)?s:""}else if(n&&Object.prototype.hasOwnProperty.call(n,d))r="";else{if(g){this.logger.debug&&this.logger.once(`${c}\0${a[0]}`,"warn",`missed to pass in variable ${d} for interpolating ${c}`),r=a[0];continue}this.logger.warn(`missed to pass in variable ${d} for interpolating ${t}`),r=""}else e(r)||this.useRawValueToEscape||(r=s(r));const f=s(i.safeValue(r));if(t=t.slice(0,a.index)+f+t.slice(a.index+a[0].length),g?(i.regex===this.regexpUnescape?m.push([a.index,a.index+f.length]):y+=f.length-a[0].length,i.regex.lastIndex+=f.length,i.regex.lastIndex-=a[0].length):i.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,i,o={}){let n,a,r;const l=(e,t)=>{const s=this.nestingOptionsSeparator;if(!e.includes(s))return e;const i=e.split(new RegExp(`${p(s)}[ ]*{`));let o=`{${i[1]}`;e=i[0],o=this.interpolate(o,r);const n=o.match(/'/g),a=o.match(/"/g);((n?.length??0)%2==0&&!a||(a?.length??0)%2!=0)&&(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),t&&(r={...t,...r})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${o}`}return r.defaultValue&&r.defaultValue.includes(this.prefix)&&delete r.defaultValue,e},c=new RegExp(this.nestingRegexp);let h="",u=0;for(;n=c.exec(t);){let p=[];r={...o},r=r.replace&&!e(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const g=/{.*}/s.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==g&&(p=n[1].slice(g).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,g)),a=i(l.call(this,n[1].trim(),r),r),a&&n[0]===t&&!e(a))return a;e(a)||(a=s(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${t}`),a=""),p.length&&(a=p.reduce((e,t)=>this.format(e,t,o.lng,{...o,interpolationkey:n[1].trim()}),a.trim())),h+=t.slice(u,n.index)+s(a),u=c.lastIndex,this.regexp.lastIndex=0}return u?h+t.slice(u):t}}const V=e=>{const t={};return(s,i,o)=>{let n,a=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(a={...a,[o.interpolationkey]:void 0});try{n=i+JSON.stringify(a)}catch(t){return e(b(i),o)(s)}let r=t[n];return r||(r=e(b(i),o),t[n]=r),r(s)}},I=e=>(t,s,i)=>e(b(s),i)(t);class T{constructor(e={}){this.logger=x.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?V:I;this.formats={number:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t});return e=>s.format(e)}),currency:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>s.format(e)}),datetime:s((e,t)=>{const s=new Intl.DateTimeFormat(e,{...t});return e=>s.format(e)}),relativetime:s((e,t)=>{const s=new Intl.RelativeTimeFormat(e,{...t});return e=>s.format(e,t.range||"day")}),list:s((e,t)=>{const s=new Intl.ListFormat(e,{...t});return e=>s.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=V(t)}format(e,t,s,i={}){if(!t)return e;if(null==e)return e;const o=t.split(this.formatSeparator),n=[];for(let e=0;e<o.length;e++){let t=o[e];for(;t.indexOf("(")>-1&&!t.includes(")")&&e+1<o.length;)t=`${t}${this.formatSeparator}${o[++e]}`;n.push(t)}return n.reduce((e,t)=>{const{formatName:o,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.includes("(")){const i=e.split("(");t=i[0].toLowerCase().trim();const o=i[1].slice(0,-1);"currency"!==t||o.includes(":")?"relativetime"!==t||o.includes(":")?o.split(";").forEach(e=>{if(e){const[t,...i]=e.split(":"),o=i.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();s[n]||(s[n]=o),"false"===o&&(s[n]=!1),"true"===o&&(s[n]=!0),isNaN(o)||(s[n]=parseInt(o,10))}}):s.range||(s.range=o.trim()):s.currency||(s.currency=o.trim())}return{formatName:t,formatOptions:s}})(t);if(this.formats[o]){let t=e;try{const a=i?.formatParams?.[i.interpolationkey]||{},r=a.locale||a.lng||i.locale||i.lng||s;t=this.formats[o](e,r,{...n,...i,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class H extends S{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=x.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i),this.callbackApi=o(this.backend),this.backend&&void 0===this.callbackApi&&(this.backend.read||this.backend.create)&&this.logger.deprecate("backend: set callbackApi to declare the calling convention (true: read(language, namespace, callback) and create(languages, namespace, key, fallbackValue, callback, options); false: both return a promise or a value); guessing it from the number of parameters is deprecated")}queueLoad(e,t,s,i){const o={},n={},a={},r={};return e.forEach(e=>{let i=!0;t.forEach(t=>{const a=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===n[a]&&(n[a]=!0):(this.state[a]=1,i=!1,void 0===n[a]&&(n[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===r[t]&&(r[t]=!0)))}),i||(a[e]=!0)}),(Object.keys(o).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(n),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(r)}}loaded(e,t,s){const i=e.split("|"),o=i[0],n=i[1];t&&this.emit("failedLoading",o,n,t),!t&&s&&this.store.addResourceBundle(o,n,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(s=>{((e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);i[o]=i[o]||[],i[o].push(s)})(s.loaded,[o],n),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach(e=>{a[e]||(a[e]={});const t=s.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,s,i=0,o=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:o,callback:n});this.readingCalls++;const a=(a,r)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&r&&i<this.maxRetries?setTimeout(()=>{this.read(e,t,s,i+1,2*o,n)},o):n(a,r)},r=this.backend[s].bind(this.backend);if(!1!==this.callbackApi&&(void 0!==this.callbackApi||2!==r.length))return r(e,t,a);try{const s=r(e,t);s&&"function"==typeof s.then?s.then(e=>a(null,e)).catch(a):a(null,s)}catch(e){a(e)}}prepareLoading(t,s,i={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();e(t)&&(t=this.languageUtils.toResolveHierarchy(t)),e(s)&&(s=[s]);const n=this.queueLoad(t,s,i,o);if(!n.toLoad.length)return n.pending.length||o(),null;n.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}noticeDevFallback(e){"dev"===e&&this.devIsDefaultFallback&&this.logger.once("dev","warn","language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior")}loadOne(e,t=""){const s=e.split("|"),i=s[0],o=s[1];this.noticeDevFallback(i),this.read(i,o,"read",void 0,void 0,(s,n)=>{s&&this.logger.warn(`${t}loading namespace ${o} for language ${i} failed`,s),!s&&n&&this.logger.log(`${t}loaded namespace ${o} for language ${i}`,n),this.loaded(e,s,n)})}saveMissing(e,t,s,i,o,n={},a=()=>{},r=this.newestCloneHasLoadedNamespace||this.services?.utils?.hasLoadedNamespace){if(!r||r(t)){if(null!=s&&""!==s){if(this.backend?.create){e?.forEach?.(e=>this.noticeDevFallback(e));const r={...n,isUpdate:o},l=this.backend.create.bind(this.backend);if(!1===this.callbackApi||void 0===this.callbackApi&&l.length<6)try{let o;o=!1===this.callbackApi||5===l.length?l(e,t,s,i,r):l(e,t,s,i),o&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,s,i,a,r)}e&&e[0]&&this.store.addResource(e[0],t,s,i)}}else this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const U=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,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:t=>{let s={};if("object"==typeof t[1]&&(s=t[1]),e(t[1])&&(s.defaultValue=t[1]),e(t[2])&&(s.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const e=t[3]||t[2];Object.keys(e).forEach(t=>{s[t]=e[t]})}return s},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=t=>(e(t.ns)&&(t.ns=[t.ns]),e(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),e(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),z=()=>{};let M;class B extends S{constructor(e={},t){var s;if(super(),this.options=K(e),this.services={ownPostProcessors:new Set},this.logger=x,this.modules={external:[]},s=this,Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach(e=>{"function"==typeof s[e]&&(s[e]=s[e].bind(s))}),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(s={},i){this.isInitializing=!0,"function"==typeof s&&(i=s,s={}),null==s.defaultNS&&s.ns&&(e(s.ns)?s.defaultNS=s.ns:s.ns.includes("translation")||(s.defaultNS=s.ns[0]));const n=void 0===s.fallbackLng&&void 0===this.options.fallbackLng,a=U();this.options={...a,...this.options,...K(s)},this.options.interpolation={...a.interpolation,...this.options.interpolation},void 0!==s.keySeparator&&(this.options.userDefinedKeySeparator=s.keySeparator),void 0!==s.nsSeparator&&(this.options.userDefinedNsSeparator=s.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=a.overloadTranslationOptionHandler);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;M&&M!==this&&M.modules.logger!==this.modules.logger&&x.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger"),M=this.modules.logger?this:void 0,this.modules.logger?x.init(r(this.modules.logger),this.options):x.init(null,this.options),this.pendingWarnings?.forEach(e=>this.logger.warn(e)),this.pendingWarnings=void 0,e=this.modules.formatter?this.modules.formatter:T;const t=new j(this.options);this.store=new w(this.options.resources,this.options);const s=this.services;s.logger=x,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new F(t,{prepend:this.options.pluralSeparator}),e&&(s.formatter=r(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new A(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this),reloadResources:this.reloadResources.bind(this)},s.backendConnector=new H(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.devIsDefaultFallback=n,s.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options),s.languageDetector.async&&void 0===o(s.languageDetector)&&this.logger.deprecate("languageDetector: set callbackApi to declare how the async detect() answers (true: detect(callback); false: detect() returns a promise); guessing it from the number of parameters is deprecated")),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new P(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,i||(i=z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});const l=t(),c=()=>{const e=(e,t)=>{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),l.resolve(t),i(e,t)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,s=z){let i=s;const o=e(t)?t:this.language;if("function"==typeof t&&(i=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===o?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return i();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&(e.includes(t)||e.push(t))})};if(o)t(o);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e))}this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),i(e)})}else i(null)}reloadResources(e,s,i){const o=t();return"function"==typeof e&&(i=e,e=void 0),"function"==typeof s&&(i=s,s=void 0),e||(e=this.languages||[]),s||(s=this.options.ns),i||(i=z),this.services.backendConnector.reload(e,s,e=>{o.resolve(),i(e)}),o}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()");const t=t=>{if(this.modules[t]&&this.modules[t]!==e){const e=`use: this ${t} replaces the ${t} passed to an earlier use() call; only one ${t} is used per instance`;this.isInitializing||this.isInitialized?this.logger.warn(e):(this.pendingWarnings=this.pendingWarnings||[]).push(e)}this.modules[t]=e};return"backend"===e.type&&t("backend"),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&t("languageDetector"),"i18nFormat"===e.type&&t("i18nFormat"),"postProcessor"===e.type&&($.addPostProcessor(e),this.services.ownPostProcessors?.add(e.name)),"formatter"===e.type&&t("formatter"),"3rdParty"===e.type&&this.modules.external.push(e),this}hydrate(e,t){return this.options.isClone?this:this.services.resourceStore?(e&&!this.initializedStoreOnce&&(this.services.resourceStore.data=e,Object.values(e).forEach(e=>{Object.keys(e).forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)})}),this.initializedStoreOnce=!0,this.isInitialized=!0),t&&!this.initializedLanguageOnce&&(this.changeLanguage(t),this.initializedLanguageOnce=!0),this):(this.logger.warn("hydrate: call init() first, the instance has no resource store yet"),this)}setResolvedLanguage(e){if(e&&this.languages&&!["cimode","dev"].includes(e)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!["cimode","dev"].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}this.resolvedLanguage||this.languages.includes(e)||!this.store.hasLanguageSomeTranslations(e)||(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(s,n){this.isLanguageChangingTo=s;const a=t();this.emit("languageChanging",s);const r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},l=(e,t)=>{t?this.isLanguageChangingTo===s&&(r(t),this.translator.changeLanguage(t),this.isLanguageChangingTo=void 0,this.emit("languageChanged",t),this.logger.log("languageChanged",t)):this.isLanguageChangingTo=void 0,a.resolve((...e)=>this.t(...e)),n&&n(e,(...e)=>this.t(...e))},c=t=>{s||t||!this.services.languageDetector||(t=[]);const o=e(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(o)?o:this.services.languageUtils.getBestMatchFromCodes(e(t)?[t]:t);if(n&&this.logger.debug&&!i(n)){[].concat(this.options.supportedLngs||[],this.services.languageUtils.getFallbackCodes(this.options.fallbackLng,n),this.options.preload||[]).includes(n)||Object.prototype.hasOwnProperty.call(this.store.data,n)||this.logger.once(`lng:${n}`,"deprecate",`changeLanguage: the language code '${n.slice(0,64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`)}n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{l(e,n)})};if(s||!this.services.languageDetector||this.services.languageDetector.async)if(!s&&this.services.languageDetector&&this.services.languageDetector.async){const e=o(this.services.languageDetector);!1===e||void 0===e&&0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c)}else c(s);else c(this.services.languageDetector.detect());return a}getFixedT(t,s,i,o){const n=o?.scopeNs,a=(e,t,...s)=>{let o;o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;const r=void 0!==o.ns&&null!==o.ns;o.ns=o.ns||a.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||i||a.keyPrefix);const l={...this.options,...o};Array.isArray(n)&&!r&&(l.ns=n),"function"==typeof o.keyPrefix&&(o.keyPrefix=C(o.keyPrefix,l));const c=this.options.keySeparator||".";let h;return o.keyPrefix&&Array.isArray(e)?h=e.map(e=>("function"==typeof e&&(e=C(e,l)),`${o.keyPrefix}${c}${e}`)):("function"==typeof e&&(e=C(e,l)),h=o.keyPrefix?`${o.keyPrefix}${c}${e}`:e),this.t(h,o)};return e(t)?a.lng=t:a.lngs=t,a.ns=s,a.keyPrefix=i,a}t(...e){return this.translator?this.translator.translate(...e):(this.logger.warn("t: called before init(); returning an empty string"),"")}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const n=(e,t)=>{const s=this.services.backendConnector.state[`${e}|${t}`];return-1===s||0===s||2===s};if(t.precheck){const e=t.precheck(this,n);if(void 0!==e)return e}if(this.hasResourceBundle(s,e))return!0;if(!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;const{languageUtils:a}=this.services,r=t.lng?a.isSupportedCode(s)&&a.toResolveHierarchy(s,!1)[0]:s;return!(r&&!n(r,e)||i&&!n(o,e))}loadNamespaces(s,i){const o=t();return this.options.ns?(e(s)&&(s=[s]),s.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}loadLanguages(s,i){const o=t();e(s)&&(s=[s]);const n=this.options.preload||[],a=s.filter(e=>!n.includes(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"ltr";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}const t=this.services?.languageUtils||new j(U());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].includes(t.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new B(e,t);return s.createInstance=B.createInstance,s}cloneInstance(e={},t=z){const s=e.forkResourceStore;s&&delete(e={...e}).forkResourceStore;const i={...this.options,preload:!1,...e,isClone:!0},o=new B(i);void 0===e.debug&&void 0===e.prefix||(o.logger=o.logger.clone(e));if(["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={...o.services.utils,hasLoadedNamespace:o.hasLoadedNamespace.bind(o),reloadResources:o.reloadResources.bind(o)},s){const e=t=>{const s=Array.isArray(t)?[...t]:{...t};return Object.keys(s).forEach(t=>{s[t]&&"object"==typeof s[t]&&(s[t]=e(s[t]))}),s},t=e(this.store.data);o.store=new w(t,i),o.services.resourceStore=o.store}if(e.interpolation){const t={...U().interpolation,...this.options.interpolation,...e.interpolation},s={...i,interpolation:t};o.services.interpolator=new A(s)}return o.translator=new P(o.services,i),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(i,t),o.translator.options=i,o.translator.backendConnector.newestCloneHasLoadedNamespace=o.hasLoadedNamespace.bind(o),o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _=B.createInstance();return _.keyFromSelector=C,_.isSafeLanguageCode=i,_});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).i18next=t()}(this,function(){"use strict";const e=e=>"string"==typeof e,t=()=>{let e,t;const s=new Promise((s,i)=>{e=s,t=i});return s.resolve=e,s.reject=t,s},s=e=>null==e?"":String(e),i=t=>e(t)&&/^[A-Za-z0-9_@.-]{1,128}$/.test(t)&&!t.includes("..")&&!["__proto__","constructor","prototype"].includes(t),o=e=>e?.callbackApi??e?.constructor?.callbackApi,n=/###/g,a=e=>e&&e.includes("###")?e.replace(n,"."):e,r=t=>!t||e(t),l=(t,s,i)=>{const o=e(s)?s.split("."):s;let n=0;for(;n<o.length-1;){if(r(t))return{};const e=a(o[n]);!t[e]&&i&&(t[e]=new i),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++n}return r(t)?{}:{obj:t,k:a(o[n])}},c=(e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);if(void 0!==i||1===t.length)return void(i[o]=s);let n=t[t.length-1],a=t.slice(0,t.length-1),r=l(e,a,Object);for(;void 0===r.obj&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),r=l(e,a,Object),r?.obj&&void 0!==r.obj[`${r.k}.${n}`]&&(r.obj=void 0);r.obj[`${r.k}.${n}`]=s},h=(e,t)=>{const{obj:s,k:i}=l(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,i))return s[i]},u=(t,s,i)=>{for(const o in s)"__proto__"!==o&&"constructor"!==o&&(Object.prototype.hasOwnProperty.call(t,o)?e(t[o])||t[o]instanceof String||e(s[o])||s[o]instanceof String?i&&(t[o]=s[o]):u(t[o],s[o],i):t[o]=s[o]);return t},p=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},d=t=>e(t)?t.replace(/[&<>"'\/]/g,e=>g[e]):t;const f=[" ",",","?","!",";"],m=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}(20),y=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const i=t.split(s);let o=e;for(let e=0;e<i.length;){if(!o||"object"!=typeof o)return;let t,n="";for(let a=e;a<i.length;++a)if(a!==e&&(n+=s),n+=i[a],t=o[n],"function"!=typeof t&&"__proto__"!==n||Object.prototype.hasOwnProperty.call(o,n)||(t=void 0),void 0!==t){if(["string","number","boolean"].includes(typeof t)&&a<i.length-1)continue;e+=a-e+1;break}o=t}return o},b=e=>e?.replace(/_/g,"-"),v={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class k{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||v,this.options=t,this.debug=t.debug,this.seen=new Set}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)}once(e,t,...s){return!this.debug||this.seen.has(e)||this.seen.size>=1e3?null:(this.seen.add(e),this[t](...s))}forward(t,s,i,o){return o&&!this.debug?null:(t=t.map(t=>e(t)?t.replace(/[\r\n\x00-\x1F\x7F]/g," "):t),e(t[0])&&(t[0]=`${i}${this.prefix} ${t[0]}`),this.logger[s](t))}create(e){return new k(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new k(this.logger,e)}}var x=new k;class S{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);const s=this.observers[e].get(t)||0;this.observers[e].set(t,s+1)}),this}off(e,t){("string"==typeof e?e.split(" "):[e]).forEach(e=>{this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])})}once(e,t){const s=(...i)=>{t(...i),this.off(e,s)};return this.on(e,s),this}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach(([e,s])=>{for(let i=0;i<s;i++)e(...t)})}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach(([s,i])=>{for(let o=0;o<i;o++)s(e,...t)})}}}const L=new WeakSet;class w extends S{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.logger=x.create("resourceStore"),void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}deprecateDottedLng(e){this.logger.once(e,"deprecate",`${e}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`)}getResource(t,s,i,o={}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.includes(".")?(this.deprecateDottedLng("getResource"),r=t.split(".")):(r=[t,s],i&&(Array.isArray(i)?r.push(...i):e(i)&&n?r.push(...i.split(n)):r.push(i)));const l=h(this.data,r);return null!=l||s||i||!t.includes(".")||(t=r[0],s=r[1],i=r.slice(2).join(".")),null==l&&a&&e(i)?y(this.data?.[t]?.[s],i,n):l}addResource(e,t,s,i,o={silent:!1}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(n?s.split(n):s)),e.includes(".")&&(this.deprecateDottedLng("addResource"),a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),c(this.data,a,i),o.silent||this.emit("added",e,t,s,i)}addResources(t,s,i,o={silent:!1}){for(const o in i)(e(i[o])||Array.isArray(i[o]))&&this.addResource(t,s,o,i[o],{silent:!0});o.silent||this.emit("added",t,s,i)}addResourceBundle(e,t,s,i,o,n={silent:!1,skipCopy:!1}){let a=[e,t];e.includes(".")&&(this.deprecateDottedLng("addResourceBundle"),a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let r=h(this.data,a)||{};n.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?u(r,s,o):r={...r,...s},c(this.data,a,r),n.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{const s=t[e];return!!L.has(s)||!(!s||0===Object.keys(s).length)&&("object"==typeof s&&L.add(s),!0)})}toJSON(){return this.data}}var $={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,i,o){return e.forEach(e=>{t=this.processors[e]?.process(t,s,i,o)??t}),t}};const C=Symbol("i18next/PATH_KEY");function O(e,t){const{[C]:s}=e(function(){const e=[],t=Object.create(null);let s;return t.get=(i,o)=>(s?.revoke?.(),o===C?e:(e.push(o),s=Proxy.revocable(i,t),s.proxy)),Proxy.revocable(Object.create(null),t).proxy}()),i=t?.keySeparator??".",o=t?.nsSeparator??":",n="strict"===t?.enableSelector;if(s.length>1&&o){const e=t?.ns,a=n?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(a){if((n?a:a.length>1?a.slice(1):[]).includes(s[0]))return`${s[0]}${o}${s.slice(1).join(i)}`}}return s.join(i)}const R=t=>!e(t)&&"boolean"!=typeof t&&"number"!=typeof t;class P extends S{constructor(e,t={}){var s,i;super(),s=e,i=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils","ownPostProcessors"].forEach(e=>{s[e]&&(i[e]=s[e])}),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=x.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const i=this.resolve(e,s);if(void 0===i?.res)return!1;const o=R(i.res);return!1!==s.returnObjects||!o}extractFromKey(t,s){let i=void 0!==s.nsSeparator?s.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");const o=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let n=s.ns||this.options.defaultNS||[];const a=i&&t.includes(i),r=!(this.options.userDefinedKeySeparator||s.keySeparator||this.options.userDefinedNsSeparator||s.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const i=f.filter(e=>!t.includes(e)&&!s.includes(e));if(0===i.length)return!0;const o=m.getRegExp(`(${i.map(e=>"?"===e?"\\?":e).join("|")})`);let n=!o.test(e);if(!n){const t=e.indexOf(s);t>0&&!o.test(e.substring(0,t))&&(n=!0)}return n})(t,i,o));if(a&&!r){const s=t.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:t,namespaces:e(n)?[n]:n};const a=t.split(i);(i!==o||i===o&&this.options.ns.includes(a[0]))&&(n=a.shift()),t=a.join(o)}return{key:t,namespaces:e(n)?[n]:n}}translate(t,s,i){let o="object"==typeof s?{...s}:s;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==t)return"";"function"==typeof t&&(t=O(t,{...this.options,...o})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>"function"==typeof e?O(e,{...this.options,...o}):String(e));const n=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,a=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:r,namespaces:l}=this.extractFromKey(t[t.length-1],o),c=l[l.length-1];let h=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===h&&(h=":");const u=o.lng||this.language,p=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return p?n?{res:`${c}${h}${r}`,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:`${c}${h}${r}`:n?{res:r,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:r;const g=this.resolve(t,o);let d=g?.res;const f=g?.usedKey||r,m=g?.exactUsedKey||r,y=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==o.count&&!e(o.count),k=P.hasDefaultValue(o),x=v?this.pluralResolver.getSuffix(u,o.count,o):"",S=o.ordinal&&v?this.pluralResolver.getSuffix(u,o.count,{ordinal:!1}):"",L=v&&!o.ordinal&&0===o.count,w=L&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${x}`]||o[`defaultValue${S}`]||o.defaultValue;let $=d;b&&!d&&k&&($=w);const C=R($),j=Object.prototype.toString.apply($);if(!(b&&$&&C)||["[object Number]","[object Function]","[object RegExp]"].includes(j)||e(y)&&Array.isArray($))if(b&&e(y)&&Array.isArray(d))d=d.join(y),d&&(d=this.extendTranslation(d,t,o,g,i));else{let e=!1,s=!1;!this.isValidLookup(d)&&k&&(e=!0,d=w),this.isValidLookup(d)||(s=!0,d=r);const n=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:d,l=k&&w!==d&&this.options.updateMissing;if(s||e||l){if(this.logger.log(l?"updateKey":"missingKey",u,c,v&&!l?`${r}${this.pluralResolver.getSuffix(u,o.count,o)}`:r,l?w:d),a){const e=this.resolve(r,{...o,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let s=0;s<t.length;s++)e.push(t[s]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);const s=(e,t,s)=>{const i=k&&s!==d?s:n;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,i,l,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,i,l,o,void 0,this.utils?.hasLoadedNamespace),this.emit("missingKey",e,c,t,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,o);L&&o[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{s([e],r+t,o[`defaultValue${t}`]||w)})}):s(e,r,w))}d=this.extendTranslation(d,t,o,g,i),s&&d===r&&this.options.appendNamespaceToMissingKey&&(d=`${c}${h}${r}`),(s||e)&&this.options.parseMissingKeyHandler&&(d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${r}`:r,e?d:void 0,o))}else{if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||(this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.logger.once("returnedObject","deprecate","accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)"));const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,$,{...o,ns:l}):`key '${r} (${this.language})' returned an object instead of string.`;return n?(g.res=e,g.usedParams=this.getUsedParamsDetails(o),g):e}if(a){const e=Array.isArray($),t=e?[]:{},s=e?m:f;for(const e in $)if(Object.prototype.hasOwnProperty.call($,e)){const i=`${s}${a}${e}`;t[e]=k&&!d?this.translate(i,{...o,defaultValue:R(w)?w[e]:void 0,joinArrays:!1,ns:l}):this.translate(i,{...o,joinArrays:!1,ns:l}),t[e]===i&&(t[e]=$[e])}d=t}}return n?(g.res=d,g.usedParams=this.getUsedParamsDetails(o),g):d}extendTranslation(t,s,i,o,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const a=e(t)&&(void 0!==i?.interpolation?.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(a){const e=t.match(this.interpolator.nestingRegexp);r=e&&e.length}let l=i.replace&&!e(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,i.lng||this.language||o.usedLng,i),a){const e=t.match(this.interpolator.nestingRegexp);r<(e&&e.length)&&(i.nest=!1)}!i.lng&&o&&o.res&&(i.lng=this.language||o.usedLng),!1!==i.nest&&(t=this.interpolator.nest(t,(...e)=>n?.[0]!==e[0]||i.context?this.translate(...e,s):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${s[0]}`),null),i)),i.interpolation&&this.interpolator.reset()}const a=i.postProcess||this.options.postProcess,r=e(a)?[a]:a;return null!=t&&r?.length&&!1!==i.applyPostProcessor&&(r.forEach(e=>{this.logger.debug&&$.processors[e]&&this.ownPostProcessors&&!this.ownPostProcessors.has(e)&&this.logger.once(e,"deprecate",`postProcess: '${e}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`)}),t=$.handle(r,t,s,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),t}resolve(t,s={}){let i,o,n,a,r;return e(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(e=>"function"==typeof e?O(e,{...this.options,...s}):e)),t.forEach(t=>{if(this.isValidLookup(i))return;const l=this.extractFromKey(t,s),c=l.key;o=c;let h=l.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const u=void 0!==s.count&&!e(s.count),p=u&&!s.ordinal&&0===s.count,g=void 0!==s.context&&(e(s.context)||"number"==typeof s.context)&&""!==s.context,d=s.lngs?s.lngs:this.languageUtils.toResolveHierarchy(s.lng||this.language,s.fallbackLng);h.forEach(e=>{this.isValidLookup(i)||(r=e,this.checkedLoadedFor[`${d[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||(this.checkedLoadedFor[`${d[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${d.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach(t=>{if(this.isValidLookup(i))return;a=t;const o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,t,e,s);else{let e;u&&(e=this.pluralResolver.getSuffix(t,s.count,s));const i=`${this.options.pluralSeparator}zero`,n=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(s.ordinal&&e.startsWith(n)&&o.push(c+e.replace(n,this.options.pluralSeparator)),o.push(c+e),p&&o.push(c+i)),g){const t=`${c}${this.options.contextSeparator||"_"}${s.context}`;o.push(t),u&&(s.ordinal&&e.startsWith(n)&&o.push(t+e.replace(n,this.options.pluralSeparator)),o.push(t+e),p&&o.push(t+i))}}let r;for(;r=o.pop();)this.isValidLookup(i)||(n=r,i=this.getResource(t,e,r,s))}))})}),{res:i,usedKey:o,exactUsedKey:n,usedLng:a,usedNS:r}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(t={}){const s=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=t.replace&&!e(t.replace);let o=i?t.replace:t;if(i&&void 0!==t.count&&(o={...o,count:t.count}),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!i){o={...o};for(const e of s)delete o[e]}return o}static hasDefaultValue(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith("defaultValue")&&void 0!==e[t])return!0;return!1}}class j{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=x.create("languageUtils"),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(!(e=b(e))||!e.includes("-"))return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=b(e))||!e.includes("-"))return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(t){if(e(t)&&t.includes("-")){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(e){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}const s=this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t;return this.logger.debug&&e(t)&&this.deprecateBareCode(t,s),s}deprecateBareCode(e,t){let s;try{s=Intl.getCanonicalLocales(e)[0]}catch(e){return}let i=s.toLowerCase()===e.toLowerCase()?s:e.toLowerCase();this.options.lowerCaseLng&&(i=i.toLowerCase()),i!==t&&this.logger.once(e,"deprecate",`language code '${e}' is used as '${t}'; i18next v27 gives it the canonical casing '${i}', use '${i}' in lng, fallbackLng, supportedLngs and the resources`)}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;const s=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(s)||(t=s)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;const s=this.getScriptPartFromCode(e);if(this.isSupportedCode(s))return t=s;const i=this.getLanguagePartFromCode(e);if(this.isSupportedCode(i))return t=i;t=this.options.supportedLngs.find(e=>e===i||!(!e.includes("-")&&!i.includes("-"))&&!(!e.includes("-")||i.includes("-")||e.slice(0,e.indexOf("-"))!==i))}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(t,s){if(!t)return[];if("function"==typeof t&&(t=t(s)),e(t)&&(t=[t]),Array.isArray(t))return t;if(!s)return t.default||[];let i=t[s];return i||(i=t[this.getScriptPartFromCode(s)]),i||(i=t[this.formatLanguageCode(s)]),i||(i=t[this.getLanguagePartFromCode(s)]),i||(i=t.default),i||[]}toResolveHierarchy(t,s){const i=this.options.fallbackLng,o=Array.isArray(i)?i.join("|"):i;o!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=o);const n=void 0===s||!1===s||e(s),a=void 0===s&&"function"==typeof this.options.fallbackLng;let r=null;if(e(t)&&n&&!a){let e;e=void 0===s?"undefined":!1===s?"boolean:false":`string:${s}`,r=`${t.length}:${t}|${e}`}if(null!==r){const e=this.resolveHierarchyCache[r];if(void 0!==e)return e.slice()}const l=this.getFallbackCodes((!1===s?[]:s)||this.options.fallbackLng||[],t),c=[],h=e=>{e&&(this.isSupportedCode(e)?c.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return e(t)&&(t.includes("-")||t.includes("_"))?("languageOnly"!==this.options.load&&h(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&h(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&h(this.getLanguagePartFromCode(t))):e(t)&&h(this.formatLanguageCode(t)),l.forEach(e=>{const t=this.formatLanguageCode(e);c.includes(t)||h(t)}),null!==r?(this.resolveHierarchyCache[r]=c,c.slice()):c}}const N={zero:0,one:1,two:2,few:3,many:4,other:5},E={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class F{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=x.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=b("dev"===e?"en":e),i=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:s,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let n;try{n=new Intl.PluralRules(s,{type:i})}catch(s){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),E;if(!e.match(/-|_/))return E;const i=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(i,t)}return this.pluralRulesCache[o]=n,n}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((e,t)=>N[e]-N[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const D=(t,s,i,o=".",n=!0)=>{let a=((e,t,s)=>{const i=h(e,s);return void 0!==i?i:h(t,s)})(t,s,i);return null==a&&n&&e(i)&&(a=y(t,i,o),void 0===a&&(a=y(s,i,o))),a};class A{constructor(e={}){this.logger=x.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:o,prefixEscaped:n,suffix:a,suffixEscaped:r,formatSeparator:l,unescapeSuffix:c,unescapePrefix:h,nestingPrefix:u,nestingPrefixEscaped:g,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:v}=e.interpolation;if(n||r||g||m){const e=Object.entries({prefixEscaped:n,suffixEscaped:r,nestingPrefixEscaped:g,nestingSuffixEscaped:m}).filter(([,e])=>e).map(([e])=>e);this.logger.once(e.join(),"deprecate",`interpolation.${e.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`)}this.escape=void 0!==t?t:d,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==i&&i,this.prefix=o?p(o):n||"{{",this.suffix=a?p(a):r||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":h?p(h):"-",this.unescapeSuffix=this.unescapePrefix?"":c?p(c):"",this.nestingPrefix=u?p(u):g||p("$t("),this.nestingSuffix=f?p(f):m||p(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,i,o,n){let a,r,l;const c=t,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){const t=D(i,h,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(t,void 0,o,{...n,...i,interpolationkey:e}):t}const t=e.split(this.formatSeparator),s=t.shift().trim(),a=t.join(this.formatSeparator).trim();return this.format(D(i,h,s,this.options.keySeparator,this.options.ignoreJSONStructure),a,o,{...n,...i,interpolationkey:s})};this.resetRegExp(),!this.escapeValue&&"string"==typeof t&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const p=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,g=void 0!==n?.interpolation?.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,f=[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:t=>this.escapeValue?(this.escape===d&&!1!==this.options?.interpolation?.escapeValue&&e(t)&&t.includes("/")&&this.logger.once("/","deprecate","escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is"),this.escape(t)):t}],m=[];let y=0;return f.forEach(i=>{for(l=0;a=i.regex.exec(t);){const o=a.index-y,h=m.find(([e,t])=>o>=e&&o<t);if(h){i.regex.lastIndex=h[1]+y;continue}const d=a[1].trim();if(r=u(d),void 0===r)if("function"==typeof p){const s=p(t,a,n);r=e(s)?s:""}else if(n&&Object.prototype.hasOwnProperty.call(n,d))r="";else{if(g){this.logger.debug&&this.logger.once(`${c}\0${a[0]}`,"warn",`missed to pass in variable ${d} for interpolating ${c}`),r=a[0];continue}this.logger.warn(`missed to pass in variable ${d} for interpolating ${t}`),r=""}else e(r)||this.useRawValueToEscape||(r=s(r));const f=s(i.safeValue(r));if(t=t.slice(0,a.index)+f+t.slice(a.index+a[0].length),g?(i.regex===this.regexpUnescape?m.push([a.index,a.index+f.length]):y+=f.length-a[0].length,i.regex.lastIndex+=f.length,i.regex.lastIndex-=a[0].length):i.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,i,o={}){let n,a,r;const l=(e,t)=>{const s=this.nestingOptionsSeparator;if(!e.includes(s))return e;const i=e.split(new RegExp(`${p(s)}[ ]*{`));let o=`{${i[1]}`;e=i[0],o=this.interpolate(o,r);const n=o.match(/'/g),a=o.match(/"/g);((n?.length??0)%2==0&&!a||(a?.length??0)%2!=0)&&(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),t&&(r={...t,...r})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${o}`}return r.defaultValue&&r.defaultValue.includes(this.prefix)&&delete r.defaultValue,e},c=new RegExp(this.nestingRegexp);let h="",u=0;for(;n=c.exec(t);){let p=[];r={...o},r=r.replace&&!e(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const g=/{.*}/s.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==g&&(p=n[1].slice(g).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,g)),a=i(l.call(this,n[1].trim(),r),r),a&&n[0]===t&&!e(a))return a;e(a)||(a=s(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${t}`),a=""),p.length&&(a=p.reduce((e,t)=>this.format(e,t,o.lng,{...o,interpolationkey:n[1].trim()}),a.trim())),h+=t.slice(u,n.index)+s(a),u=c.lastIndex,this.regexp.lastIndex=0}return u?h+t.slice(u):t}}const V=e=>{const t={};return(s,i,o)=>{let n,a=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(a={...a,[o.interpolationkey]:void 0});try{n=i+JSON.stringify(a)}catch(t){return e(b(i),o)(s)}let r=t[n];return r||(r=e(b(i),o),t[n]=r),r(s)}},I=e=>(t,s,i)=>e(b(s),i)(t);class T{constructor(e={}){this.logger=x.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?V:I;this.formats={number:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t});return e=>s.format(e)}),currency:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>s.format(e)}),datetime:s((e,t)=>{const s=new Intl.DateTimeFormat(e,{...t});return e=>s.format(e)}),relativetime:s((e,t)=>{const s=new Intl.RelativeTimeFormat(e,{...t});return e=>s.format(e,t.range||"day")}),list:s((e,t)=>{const s=new Intl.ListFormat(e,{...t});return e=>s.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=V(t)}format(e,t,s,i={}){if(!t)return e;if(null==e)return e;const o=t.split(this.formatSeparator),n=[];for(let e=0;e<o.length;e++){let t=o[e];for(;t.indexOf("(")>-1&&!t.includes(")")&&e+1<o.length;)t=`${t}${this.formatSeparator}${o[++e]}`;n.push(t)}return n.reduce((e,t)=>{const{formatName:o,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.includes("(")){const i=e.split("(");t=i[0].toLowerCase().trim();const o=i[1].slice(0,-1);"currency"!==t||o.includes(":")?"relativetime"!==t||o.includes(":")?o.split(";").forEach(e=>{if(e){const[t,...i]=e.split(":"),o=i.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();s[n]||(s[n]=o),"false"===o&&(s[n]=!1),"true"===o&&(s[n]=!0),isNaN(o)||(s[n]=parseInt(o,10))}}):s.range||(s.range=o.trim()):s.currency||(s.currency=o.trim())}return{formatName:t,formatOptions:s}})(t);if(this.formats[o]){let t=e;try{const a=i?.formatParams?.[i.interpolationkey]||{},r=a.locale||a.lng||i.locale||i.lng||s;t=this.formats[o](e,r,{...n,...i,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class H extends S{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=x.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i),this.callbackApi=o(this.backend),this.backend&&void 0===this.callbackApi&&(this.backend.read||this.backend.create)&&this.logger.deprecate("backend: set callbackApi to declare the calling convention (true: read(language, namespace, callback) and create(languages, namespace, key, fallbackValue, callback, options); false: both return a promise or a value); guessing it from the number of parameters is deprecated")}queueLoad(e,t,s,i){const o={},n={},a={},r={};return e.forEach(e=>{let i=!0;t.forEach(t=>{const a=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:!s.reload&&this.state[a]<0||(1===this.state[a]?void 0===n[a]&&(n[a]=!0):(this.state[a]=1,i=!1,void 0===n[a]&&(n[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===r[t]&&(r[t]=!0)))}),i||(a[e]=!0)}),(Object.keys(o).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(n),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(r)}}loaded(e,t,s){const i=e.split("|"),o=i[0],n=i[1];t&&this.emit("failedLoading",o,n,t),!t&&s&&this.store.addResourceBundle(o,n,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(s=>{((e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);i[o]=i[o]||[],i[o].push(s)})(s.loaded,[o],n),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach(e=>{a[e]||(a[e]={});const t=s.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,s,i=0,o=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:o,callback:n});this.readingCalls++;const a=(a,r)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&r&&i<this.maxRetries?setTimeout(()=>{this.read(e,t,s,i+1,2*o,n)},o):n(a,r)},r=this.backend[s].bind(this.backend);if(!1!==this.callbackApi&&(void 0!==this.callbackApi||2!==r.length))return r(e,t,a);try{const s=r(e,t);s&&"function"==typeof s.then?s.then(e=>a(null,e)).catch(a):a(null,s)}catch(e){a(e)}}prepareLoading(t,s,i={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();e(t)&&(t=this.languageUtils.toResolveHierarchy(t)),e(s)&&(s=[s]);const n=this.queueLoad(t,s,i,o);if(!n.toLoad.length)return n.pending.length||o(),null;n.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}noticeDevFallback(e){"dev"===e&&this.devIsDefaultFallback&&this.logger.once("dev","warn","language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior")}loadOne(e,t=""){const s=e.split("|"),i=s[0],o=s[1];this.noticeDevFallback(i),this.read(i,o,"read",void 0,void 0,(s,n)=>{s&&this.logger.warn(`${t}loading namespace ${o} for language ${i} failed`,s),!s&&n&&this.logger.log(`${t}loaded namespace ${o} for language ${i}`,n),this.loaded(e,s,n)})}saveMissing(e,t,s,i,o,n={},a=()=>{},r=this.newestCloneHasLoadedNamespace||this.services?.utils?.hasLoadedNamespace){if(!r||r(t)){if(null!=s&&""!==s){if(this.backend?.create){e?.forEach?.(e=>this.noticeDevFallback(e));const r={...n,isUpdate:o},l=this.backend.create.bind(this.backend);if(!1===this.callbackApi||void 0===this.callbackApi&&l.length<6)try{let o;o=!1===this.callbackApi||5===l.length?l(e,t,s,i,r):l(e,t,s,i),o&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,s,i,a,r)}e&&e[0]&&this.store.addResource(e[0],t,s,i)}}else this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const U=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,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:t=>{let s={};if("object"==typeof t[1]&&(s=t[1]),e(t[1])&&(s.defaultValue=t[1]),e(t[2])&&(s.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const e=t[3]||t[2];Object.keys(e).forEach(t=>{s[t]=e[t]})}return s},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=t=>(e(t.ns)&&(t.ns=[t.ns]),e(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),e(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),z=()=>{};let M;class B extends S{constructor(e={},t){var s;if(super(),this.options=K(e),this.services={ownPostProcessors:new Set},this.logger=x,this.modules={external:[]},s=this,Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach(e=>{"function"==typeof s[e]&&(s[e]=s[e].bind(s))}),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(s={},i){this.isInitializing=!0,"function"==typeof s&&(i=s,s={}),null==s.defaultNS&&s.ns&&(e(s.ns)?s.defaultNS=s.ns:s.ns.includes("translation")||(s.defaultNS=s.ns[0]));const n=void 0===s.fallbackLng&&void 0===this.options.fallbackLng,a=U();this.options={...a,...this.options,...K(s)},this.options.interpolation={...a.interpolation,...this.options.interpolation},void 0!==s.keySeparator&&(this.options.userDefinedKeySeparator=s.keySeparator),void 0!==s.nsSeparator&&(this.options.userDefinedNsSeparator=s.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=a.overloadTranslationOptionHandler);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;M&&M!==this&&M.modules.logger!==this.modules.logger&&x.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger"),M=this.modules.logger?this:void 0,this.modules.logger?x.init(r(this.modules.logger),this.options):x.init(null,this.options),this.pendingWarnings?.forEach(e=>this.logger.warn(e)),this.pendingWarnings=void 0,e=this.modules.formatter?this.modules.formatter:T;const t=new j(this.options);this.store=new w(this.options.resources,this.options);const s=this.services;s.logger=x,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new F(t,{prepend:this.options.pluralSeparator}),e&&(s.formatter=r(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new A(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this),reloadResources:this.reloadResources.bind(this)},s.backendConnector=new H(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.devIsDefaultFallback=n,s.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options),s.languageDetector.async&&void 0===o(s.languageDetector)&&this.logger.deprecate("languageDetector: set callbackApi to declare how the async detect() answers (true: detect(callback); false: detect() returns a promise); guessing it from the number of parameters is deprecated")),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new P(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,i||(i=z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});const l=t(),c=()=>{const e=(e,t)=>{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),l.resolve(t),i(e,t)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,s=z){let i=s;const o=e(t)?t:this.language;if("function"==typeof t&&(i=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===o?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return i();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&(e.includes(t)||e.push(t))})};if(o)t(o);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e))}this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),i(e)})}else i(null)}reloadResources(e,s,i){const o=t();if("function"==typeof e&&(i=e,e=void 0),"function"==typeof s&&(i=s,s=void 0),!e){const t=Object.keys(this.services.backendConnector.state).map(e=>e.split("|")[0]);e=[...new Set([...this.languages||[],...t])].filter(e=>"cimode"!==e)}return s||(s=this.options.ns),i||(i=z),this.services.backendConnector.reload(e,s,e=>{o.resolve(),i(e)}),o}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()");const t=t=>{if(this.modules[t]&&this.modules[t]!==e){const e=`use: this ${t} replaces the ${t} passed to an earlier use() call; only one ${t} is used per instance`;this.isInitializing||this.isInitialized?this.logger.warn(e):(this.pendingWarnings=this.pendingWarnings||[]).push(e)}this.modules[t]=e};return"backend"===e.type&&t("backend"),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&t("languageDetector"),"i18nFormat"===e.type&&t("i18nFormat"),"postProcessor"===e.type&&($.addPostProcessor(e),this.services.ownPostProcessors?.add(e.name)),"formatter"===e.type&&t("formatter"),"3rdParty"===e.type&&this.modules.external.push(e),this}hydrate(e,t){return this.options.isClone?this:this.services.resourceStore?(e&&!this.initializedStoreOnce&&(this.services.resourceStore.data=e,Object.values(e).forEach(e=>{Object.keys(e).forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)})}),this.initializedStoreOnce=!0,this.isInitialized=!0),t&&!this.initializedLanguageOnce&&(this.changeLanguage(t),this.initializedLanguageOnce=!0),this):(this.logger.warn("hydrate: call init() first, the instance has no resource store yet"),this)}setResolvedLanguage(e){if(e&&this.languages&&!["cimode","dev"].includes(e)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!["cimode","dev"].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}this.resolvedLanguage||this.languages.includes(e)||!this.store.hasLanguageSomeTranslations(e)||(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(s,n){this.isLanguageChangingTo=s;const a=t();this.emit("languageChanging",s);const r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},l=(e,t)=>{t?this.isLanguageChangingTo===s&&(r(t),this.translator.changeLanguage(t),this.isLanguageChangingTo=void 0,this.emit("languageChanged",t),this.logger.log("languageChanged",t)):this.isLanguageChangingTo=void 0,a.resolve((...e)=>this.t(...e)),n&&n(e,(...e)=>this.t(...e))},c=t=>{s||t||!this.services.languageDetector||(t=[]);const o=e(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(o)?o:this.services.languageUtils.getBestMatchFromCodes(e(t)?[t]:t);if(n&&this.logger.debug&&!i(n)){[].concat(this.options.supportedLngs||[],this.services.languageUtils.getFallbackCodes(this.options.fallbackLng,n),this.options.preload||[]).includes(n)||Object.prototype.hasOwnProperty.call(this.store.data,n)||this.logger.once(`lng:${n}`,"deprecate",`changeLanguage: the language code '${n.slice(0,64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`)}n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{l(e,n)})};if(s||!this.services.languageDetector||this.services.languageDetector.async)if(!s&&this.services.languageDetector&&this.services.languageDetector.async){const e=o(this.services.languageDetector);!1===e||void 0===e&&0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c)}else c(s);else c(this.services.languageDetector.detect());return a}getFixedT(t,s,i,o){const n=o?.scopeNs,a=(e,t,...s)=>{let o;o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;const r=void 0!==o.ns&&null!==o.ns;o.ns=o.ns||a.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||i||a.keyPrefix);const l={...this.options,...o};Array.isArray(n)&&!r&&(l.ns=n),"function"==typeof o.keyPrefix&&(o.keyPrefix=O(o.keyPrefix,l));const c=this.options.keySeparator||".";let h;return o.keyPrefix&&Array.isArray(e)?h=e.map(e=>("function"==typeof e&&(e=O(e,l)),`${o.keyPrefix}${c}${e}`)):("function"==typeof e&&(e=O(e,l)),h=o.keyPrefix?`${o.keyPrefix}${c}${e}`:e),this.t(h,o)};return e(t)?a.lng=t:a.lngs=t,a.ns=s,a.keyPrefix=i,a}t(...e){return this.translator?this.translator.translate(...e):(this.logger.warn("t: called before init(); returning an empty string"),"")}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const n=(e,t)=>{const s=this.services.backendConnector.state[`${e}|${t}`];return-1===s||0===s||2===s};if(t.precheck){const e=t.precheck(this,n);if(void 0!==e)return e}if(this.hasResourceBundle(s,e))return!0;if(!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;const{languageUtils:a}=this.services,r=t.lng?a.isSupportedCode(s)&&a.toResolveHierarchy(s,!1)[0]:s;return!(r&&!n(r,e)||i&&!n(o,e))}loadNamespaces(s,i){const o=t();return this.options.ns?(e(s)&&(s=[s]),s.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}loadLanguages(s,i){const o=t();e(s)&&(s=[s]);const n=this.options.preload||[],a=s.filter(e=>!n.includes(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"ltr";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}const t=this.services?.languageUtils||new j(U());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].includes(t.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new B(e,t);return s.createInstance=B.createInstance,s}cloneInstance(e={},t=z){const s=e.forkResourceStore;s&&delete(e={...e}).forkResourceStore;const i={...this.options,preload:!1,...e,isClone:!0},o=new B(i);void 0===e.debug&&void 0===e.prefix||(o.logger=o.logger.clone(e));if(["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={...o.services.utils,hasLoadedNamespace:o.hasLoadedNamespace.bind(o),reloadResources:o.reloadResources.bind(o)},s){const e=t=>{const s=Array.isArray(t)?[...t]:{...t};return Object.keys(s).forEach(t=>{s[t]&&"object"==typeof s[t]&&(s[t]=e(s[t]))}),s},t=e(this.store.data);o.store=new w(t,i),o.services.resourceStore=o.store}if(e.interpolation){const t={...U().interpolation,...this.options.interpolation,...e.interpolation},s={...i,interpolation:t};o.services.interpolator=new A(s)}return o.translator=new P(o.services,i),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(i,t),o.translator.options=i,o.translator.backendConnector.newestCloneHasLoadedNamespace=o.hasLoadedNamespace.bind(o),o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _=B.createInstance();return _.keyFromSelector=O,_.isSafeLanguageCode=i,_});
|
package/i18next.js
CHANGED
|
@@ -997,15 +997,16 @@
|
|
|
997
997
|
return formatted;
|
|
998
998
|
}
|
|
999
999
|
deprecateBareCode(code, formatted) {
|
|
1000
|
-
let
|
|
1000
|
+
let canonical;
|
|
1001
1001
|
try {
|
|
1002
|
-
|
|
1002
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
1003
1003
|
} catch (e) {
|
|
1004
1004
|
return;
|
|
1005
1005
|
}
|
|
1006
|
+
let v27 = canonical.toLowerCase() === code.toLowerCase() ? canonical : code.toLowerCase();
|
|
1006
1007
|
if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
|
|
1007
1008
|
if (v27 === formatted) return;
|
|
1008
|
-
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27
|
|
1009
|
+
this.logger.once(code, 'deprecate', `language code '${code}' is used as '${formatted}'; i18next v27 gives it the canonical casing '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
|
|
1009
1010
|
}
|
|
1010
1011
|
isSupportedCode(code) {
|
|
1011
1012
|
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
@@ -1601,7 +1602,7 @@
|
|
|
1601
1602
|
const name = `${lng}|${ns}`;
|
|
1602
1603
|
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
1603
1604
|
this.state[name] = 2;
|
|
1604
|
-
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1605
|
+
} else if (!options.reload && this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1605
1606
|
if (pending[name] === undefined) pending[name] = true;
|
|
1606
1607
|
} else {
|
|
1607
1608
|
this.state[name] = 1;
|
|
@@ -2071,7 +2072,10 @@
|
|
|
2071
2072
|
callback = ns;
|
|
2072
2073
|
ns = undefined;
|
|
2073
2074
|
}
|
|
2074
|
-
if (!lngs)
|
|
2075
|
+
if (!lngs) {
|
|
2076
|
+
const requested = Object.keys(this.services.backendConnector.state).map(name => name.split('|')[0]);
|
|
2077
|
+
lngs = [...new Set([...(this.languages || []), ...requested])].filter(l => l !== 'cimode');
|
|
2078
|
+
}
|
|
2075
2079
|
if (!ns) ns = this.options.ns;
|
|
2076
2080
|
if (!callback) callback = noop;
|
|
2077
2081
|
this.services.backendConnector.reload(lngs, ns, err => {
|
package/i18next.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).i18next=t()}(this,function(){"use strict";const e=e=>"string"==typeof e,t=()=>{let e,t;const s=new Promise((s,i)=>{e=s,t=i});return s.resolve=e,s.reject=t,s},s=e=>null==e?"":String(e),i=t=>e(t)&&/^[A-Za-z0-9_@.-]{1,128}$/.test(t)&&!t.includes("..")&&!["__proto__","constructor","prototype"].includes(t),o=e=>e?.callbackApi??e?.constructor?.callbackApi,n=/###/g,a=e=>e&&e.includes("###")?e.replace(n,"."):e,r=t=>!t||e(t),l=(t,s,i)=>{const o=e(s)?s.split("."):s;let n=0;for(;n<o.length-1;){if(r(t))return{};const e=a(o[n]);!t[e]&&i&&(t[e]=new i),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++n}return r(t)?{}:{obj:t,k:a(o[n])}},c=(e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);if(void 0!==i||1===t.length)return void(i[o]=s);let n=t[t.length-1],a=t.slice(0,t.length-1),r=l(e,a,Object);for(;void 0===r.obj&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),r=l(e,a,Object),r?.obj&&void 0!==r.obj[`${r.k}.${n}`]&&(r.obj=void 0);r.obj[`${r.k}.${n}`]=s},h=(e,t)=>{const{obj:s,k:i}=l(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,i))return s[i]},u=(t,s,i)=>{for(const o in s)"__proto__"!==o&&"constructor"!==o&&(Object.prototype.hasOwnProperty.call(t,o)?e(t[o])||t[o]instanceof String||e(s[o])||s[o]instanceof String?i&&(t[o]=s[o]):u(t[o],s[o],i):t[o]=s[o]);return t},p=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},d=t=>e(t)?t.replace(/[&<>"'\/]/g,e=>g[e]):t;const f=[" ",",","?","!",";"],m=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}(20),y=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const i=t.split(s);let o=e;for(let e=0;e<i.length;){if(!o||"object"!=typeof o)return;let t,n="";for(let a=e;a<i.length;++a)if(a!==e&&(n+=s),n+=i[a],t=o[n],"function"!=typeof t&&"__proto__"!==n||Object.prototype.hasOwnProperty.call(o,n)||(t=void 0),void 0!==t){if(["string","number","boolean"].includes(typeof t)&&a<i.length-1)continue;e+=a-e+1;break}o=t}return o},b=e=>e?.replace(/_/g,"-"),v={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class k{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||v,this.options=t,this.debug=t.debug,this.seen=new Set}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)}once(e,t,...s){return!this.debug||this.seen.has(e)||this.seen.size>=1e3?null:(this.seen.add(e),this[t](...s))}forward(t,s,i,o){return o&&!this.debug?null:(t=t.map(t=>e(t)?t.replace(/[\r\n\x00-\x1F\x7F]/g," "):t),e(t[0])&&(t[0]=`${i}${this.prefix} ${t[0]}`),this.logger[s](t))}create(e){return new k(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new k(this.logger,e)}}var x=new k;class S{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);const s=this.observers[e].get(t)||0;this.observers[e].set(t,s+1)}),this}off(e,t){("string"==typeof e?e.split(" "):[e]).forEach(e=>{this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])})}once(e,t){const s=(...i)=>{t(...i),this.off(e,s)};return this.on(e,s),this}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach(([e,s])=>{for(let i=0;i<s;i++)e(...t)})}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach(([s,i])=>{for(let o=0;o<i;o++)s(e,...t)})}}}const L=new WeakSet;class w extends S{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.logger=x.create("resourceStore"),void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}deprecateDottedLng(e){this.logger.once(e,"deprecate",`${e}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`)}getResource(t,s,i,o={}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.includes(".")?(this.deprecateDottedLng("getResource"),r=t.split(".")):(r=[t,s],i&&(Array.isArray(i)?r.push(...i):e(i)&&n?r.push(...i.split(n)):r.push(i)));const l=h(this.data,r);return null!=l||s||i||!t.includes(".")||(t=r[0],s=r[1],i=r.slice(2).join(".")),null==l&&a&&e(i)?y(this.data?.[t]?.[s],i,n):l}addResource(e,t,s,i,o={silent:!1}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(n?s.split(n):s)),e.includes(".")&&(this.deprecateDottedLng("addResource"),a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),c(this.data,a,i),o.silent||this.emit("added",e,t,s,i)}addResources(t,s,i,o={silent:!1}){for(const o in i)(e(i[o])||Array.isArray(i[o]))&&this.addResource(t,s,o,i[o],{silent:!0});o.silent||this.emit("added",t,s,i)}addResourceBundle(e,t,s,i,o,n={silent:!1,skipCopy:!1}){let a=[e,t];e.includes(".")&&(this.deprecateDottedLng("addResourceBundle"),a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let r=h(this.data,a)||{};n.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?u(r,s,o):r={...r,...s},c(this.data,a,r),n.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{const s=t[e];return!!L.has(s)||!(!s||0===Object.keys(s).length)&&("object"==typeof s&&L.add(s),!0)})}toJSON(){return this.data}}var $={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,i,o){return e.forEach(e=>{t=this.processors[e]?.process(t,s,i,o)??t}),t}};const O=Symbol("i18next/PATH_KEY");function C(e,t){const{[O]:s}=e(function(){const e=[],t=Object.create(null);let s;return t.get=(i,o)=>(s?.revoke?.(),o===O?e:(e.push(o),s=Proxy.revocable(i,t),s.proxy)),Proxy.revocable(Object.create(null),t).proxy}()),i=t?.keySeparator??".",o=t?.nsSeparator??":",n="strict"===t?.enableSelector;if(s.length>1&&o){const e=t?.ns,a=n?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(a){if((n?a:a.length>1?a.slice(1):[]).includes(s[0]))return`${s[0]}${o}${s.slice(1).join(i)}`}}return s.join(i)}const R=t=>!e(t)&&"boolean"!=typeof t&&"number"!=typeof t;class P extends S{constructor(e,t={}){var s,i;super(),s=e,i=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils","ownPostProcessors"].forEach(e=>{s[e]&&(i[e]=s[e])}),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=x.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const i=this.resolve(e,s);if(void 0===i?.res)return!1;const o=R(i.res);return!1!==s.returnObjects||!o}extractFromKey(t,s){let i=void 0!==s.nsSeparator?s.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");const o=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let n=s.ns||this.options.defaultNS||[];const a=i&&t.includes(i),r=!(this.options.userDefinedKeySeparator||s.keySeparator||this.options.userDefinedNsSeparator||s.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const i=f.filter(e=>!t.includes(e)&&!s.includes(e));if(0===i.length)return!0;const o=m.getRegExp(`(${i.map(e=>"?"===e?"\\?":e).join("|")})`);let n=!o.test(e);if(!n){const t=e.indexOf(s);t>0&&!o.test(e.substring(0,t))&&(n=!0)}return n})(t,i,o));if(a&&!r){const s=t.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:t,namespaces:e(n)?[n]:n};const a=t.split(i);(i!==o||i===o&&this.options.ns.includes(a[0]))&&(n=a.shift()),t=a.join(o)}return{key:t,namespaces:e(n)?[n]:n}}translate(t,s,i){let o="object"==typeof s?{...s}:s;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==t)return"";"function"==typeof t&&(t=C(t,{...this.options,...o})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>"function"==typeof e?C(e,{...this.options,...o}):String(e));const n=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,a=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:r,namespaces:l}=this.extractFromKey(t[t.length-1],o),c=l[l.length-1];let h=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===h&&(h=":");const u=o.lng||this.language,p=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return p?n?{res:`${c}${h}${r}`,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:`${c}${h}${r}`:n?{res:r,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:r;const g=this.resolve(t,o);let d=g?.res;const f=g?.usedKey||r,m=g?.exactUsedKey||r,y=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==o.count&&!e(o.count),k=P.hasDefaultValue(o),x=v?this.pluralResolver.getSuffix(u,o.count,o):"",S=o.ordinal&&v?this.pluralResolver.getSuffix(u,o.count,{ordinal:!1}):"",L=v&&!o.ordinal&&0===o.count,w=L&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${x}`]||o[`defaultValue${S}`]||o.defaultValue;let $=d;b&&!d&&k&&($=w);const O=R($),j=Object.prototype.toString.apply($);if(!(b&&$&&O)||["[object Number]","[object Function]","[object RegExp]"].includes(j)||e(y)&&Array.isArray($))if(b&&e(y)&&Array.isArray(d))d=d.join(y),d&&(d=this.extendTranslation(d,t,o,g,i));else{let e=!1,s=!1;!this.isValidLookup(d)&&k&&(e=!0,d=w),this.isValidLookup(d)||(s=!0,d=r);const n=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:d,l=k&&w!==d&&this.options.updateMissing;if(s||e||l){if(this.logger.log(l?"updateKey":"missingKey",u,c,v&&!l?`${r}${this.pluralResolver.getSuffix(u,o.count,o)}`:r,l?w:d),a){const e=this.resolve(r,{...o,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let s=0;s<t.length;s++)e.push(t[s]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);const s=(e,t,s)=>{const i=k&&s!==d?s:n;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,i,l,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,i,l,o,void 0,this.utils?.hasLoadedNamespace),this.emit("missingKey",e,c,t,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,o);L&&o[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{s([e],r+t,o[`defaultValue${t}`]||w)})}):s(e,r,w))}d=this.extendTranslation(d,t,o,g,i),s&&d===r&&this.options.appendNamespaceToMissingKey&&(d=`${c}${h}${r}`),(s||e)&&this.options.parseMissingKeyHandler&&(d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${r}`:r,e?d:void 0,o))}else{if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||(this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.logger.once("returnedObject","deprecate","accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)"));const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,$,{...o,ns:l}):`key '${r} (${this.language})' returned an object instead of string.`;return n?(g.res=e,g.usedParams=this.getUsedParamsDetails(o),g):e}if(a){const e=Array.isArray($),t=e?[]:{},s=e?m:f;for(const e in $)if(Object.prototype.hasOwnProperty.call($,e)){const i=`${s}${a}${e}`;t[e]=k&&!d?this.translate(i,{...o,defaultValue:R(w)?w[e]:void 0,joinArrays:!1,ns:l}):this.translate(i,{...o,joinArrays:!1,ns:l}),t[e]===i&&(t[e]=$[e])}d=t}}return n?(g.res=d,g.usedParams=this.getUsedParamsDetails(o),g):d}extendTranslation(t,s,i,o,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const a=e(t)&&(void 0!==i?.interpolation?.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(a){const e=t.match(this.interpolator.nestingRegexp);r=e&&e.length}let l=i.replace&&!e(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,i.lng||this.language||o.usedLng,i),a){const e=t.match(this.interpolator.nestingRegexp);r<(e&&e.length)&&(i.nest=!1)}!i.lng&&o&&o.res&&(i.lng=this.language||o.usedLng),!1!==i.nest&&(t=this.interpolator.nest(t,(...e)=>n?.[0]!==e[0]||i.context?this.translate(...e,s):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${s[0]}`),null),i)),i.interpolation&&this.interpolator.reset()}const a=i.postProcess||this.options.postProcess,r=e(a)?[a]:a;return null!=t&&r?.length&&!1!==i.applyPostProcessor&&(r.forEach(e=>{this.logger.debug&&$.processors[e]&&this.ownPostProcessors&&!this.ownPostProcessors.has(e)&&this.logger.once(e,"deprecate",`postProcess: '${e}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`)}),t=$.handle(r,t,s,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),t}resolve(t,s={}){let i,o,n,a,r;return e(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(e=>"function"==typeof e?C(e,{...this.options,...s}):e)),t.forEach(t=>{if(this.isValidLookup(i))return;const l=this.extractFromKey(t,s),c=l.key;o=c;let h=l.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const u=void 0!==s.count&&!e(s.count),p=u&&!s.ordinal&&0===s.count,g=void 0!==s.context&&(e(s.context)||"number"==typeof s.context)&&""!==s.context,d=s.lngs?s.lngs:this.languageUtils.toResolveHierarchy(s.lng||this.language,s.fallbackLng);h.forEach(e=>{this.isValidLookup(i)||(r=e,this.checkedLoadedFor[`${d[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||(this.checkedLoadedFor[`${d[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${d.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach(t=>{if(this.isValidLookup(i))return;a=t;const o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,t,e,s);else{let e;u&&(e=this.pluralResolver.getSuffix(t,s.count,s));const i=`${this.options.pluralSeparator}zero`,n=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(s.ordinal&&e.startsWith(n)&&o.push(c+e.replace(n,this.options.pluralSeparator)),o.push(c+e),p&&o.push(c+i)),g){const t=`${c}${this.options.contextSeparator||"_"}${s.context}`;o.push(t),u&&(s.ordinal&&e.startsWith(n)&&o.push(t+e.replace(n,this.options.pluralSeparator)),o.push(t+e),p&&o.push(t+i))}}let r;for(;r=o.pop();)this.isValidLookup(i)||(n=r,i=this.getResource(t,e,r,s))}))})}),{res:i,usedKey:o,exactUsedKey:n,usedLng:a,usedNS:r}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(t={}){const s=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=t.replace&&!e(t.replace);let o=i?t.replace:t;if(i&&void 0!==t.count&&(o={...o,count:t.count}),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!i){o={...o};for(const e of s)delete o[e]}return o}static hasDefaultValue(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith("defaultValue")&&void 0!==e[t])return!0;return!1}}class j{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=x.create("languageUtils"),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(!(e=b(e))||!e.includes("-"))return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=b(e))||!e.includes("-"))return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(t){if(e(t)&&t.includes("-")){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(e){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}const s=this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t;return this.logger.debug&&e(t)&&this.deprecateBareCode(t,s),s}deprecateBareCode(e,t){let s;try{s=Intl.getCanonicalLocales(e)[0]}catch(e){return}this.options.lowerCaseLng&&(s=s.toLowerCase()),s!==t&&this.logger.once(e,"deprecate",`language code '${e}' is used as '${t}'; i18next v27 canonicalizes it to '${s}', use '${s}' in lng, fallbackLng, supportedLngs and the resources`)}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;const s=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(s)||(t=s)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;const s=this.getScriptPartFromCode(e);if(this.isSupportedCode(s))return t=s;const i=this.getLanguagePartFromCode(e);if(this.isSupportedCode(i))return t=i;t=this.options.supportedLngs.find(e=>e===i||!(!e.includes("-")&&!i.includes("-"))&&!(!e.includes("-")||i.includes("-")||e.slice(0,e.indexOf("-"))!==i))}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(t,s){if(!t)return[];if("function"==typeof t&&(t=t(s)),e(t)&&(t=[t]),Array.isArray(t))return t;if(!s)return t.default||[];let i=t[s];return i||(i=t[this.getScriptPartFromCode(s)]),i||(i=t[this.formatLanguageCode(s)]),i||(i=t[this.getLanguagePartFromCode(s)]),i||(i=t.default),i||[]}toResolveHierarchy(t,s){const i=this.options.fallbackLng,o=Array.isArray(i)?i.join("|"):i;o!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=o);const n=void 0===s||!1===s||e(s),a=void 0===s&&"function"==typeof this.options.fallbackLng;let r=null;if(e(t)&&n&&!a){let e;e=void 0===s?"undefined":!1===s?"boolean:false":`string:${s}`,r=`${t.length}:${t}|${e}`}if(null!==r){const e=this.resolveHierarchyCache[r];if(void 0!==e)return e.slice()}const l=this.getFallbackCodes((!1===s?[]:s)||this.options.fallbackLng||[],t),c=[],h=e=>{e&&(this.isSupportedCode(e)?c.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return e(t)&&(t.includes("-")||t.includes("_"))?("languageOnly"!==this.options.load&&h(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&h(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&h(this.getLanguagePartFromCode(t))):e(t)&&h(this.formatLanguageCode(t)),l.forEach(e=>{const t=this.formatLanguageCode(e);c.includes(t)||h(t)}),null!==r?(this.resolveHierarchyCache[r]=c,c.slice()):c}}const N={zero:0,one:1,two:2,few:3,many:4,other:5},E={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class F{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=x.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=b("dev"===e?"en":e),i=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:s,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let n;try{n=new Intl.PluralRules(s,{type:i})}catch(s){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),E;if(!e.match(/-|_/))return E;const i=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(i,t)}return this.pluralRulesCache[o]=n,n}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((e,t)=>N[e]-N[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const D=(t,s,i,o=".",n=!0)=>{let a=((e,t,s)=>{const i=h(e,s);return void 0!==i?i:h(t,s)})(t,s,i);return null==a&&n&&e(i)&&(a=y(t,i,o),void 0===a&&(a=y(s,i,o))),a};class A{constructor(e={}){this.logger=x.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:o,prefixEscaped:n,suffix:a,suffixEscaped:r,formatSeparator:l,unescapeSuffix:c,unescapePrefix:h,nestingPrefix:u,nestingPrefixEscaped:g,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:v}=e.interpolation;if(n||r||g||m){const e=Object.entries({prefixEscaped:n,suffixEscaped:r,nestingPrefixEscaped:g,nestingSuffixEscaped:m}).filter(([,e])=>e).map(([e])=>e);this.logger.once(e.join(),"deprecate",`interpolation.${e.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`)}this.escape=void 0!==t?t:d,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==i&&i,this.prefix=o?p(o):n||"{{",this.suffix=a?p(a):r||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":h?p(h):"-",this.unescapeSuffix=this.unescapePrefix?"":c?p(c):"",this.nestingPrefix=u?p(u):g||p("$t("),this.nestingSuffix=f?p(f):m||p(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,i,o,n){let a,r,l;const c=t,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){const t=D(i,h,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(t,void 0,o,{...n,...i,interpolationkey:e}):t}const t=e.split(this.formatSeparator),s=t.shift().trim(),a=t.join(this.formatSeparator).trim();return this.format(D(i,h,s,this.options.keySeparator,this.options.ignoreJSONStructure),a,o,{...n,...i,interpolationkey:s})};this.resetRegExp(),!this.escapeValue&&"string"==typeof t&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const p=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,g=void 0!==n?.interpolation?.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,f=[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:t=>this.escapeValue?(this.escape===d&&!1!==this.options?.interpolation?.escapeValue&&e(t)&&t.includes("/")&&this.logger.once("/","deprecate","escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is"),this.escape(t)):t}],m=[];let y=0;return f.forEach(i=>{for(l=0;a=i.regex.exec(t);){const o=a.index-y,h=m.find(([e,t])=>o>=e&&o<t);if(h){i.regex.lastIndex=h[1]+y;continue}const d=a[1].trim();if(r=u(d),void 0===r)if("function"==typeof p){const s=p(t,a,n);r=e(s)?s:""}else if(n&&Object.prototype.hasOwnProperty.call(n,d))r="";else{if(g){this.logger.debug&&this.logger.once(`${c}\0${a[0]}`,"warn",`missed to pass in variable ${d} for interpolating ${c}`),r=a[0];continue}this.logger.warn(`missed to pass in variable ${d} for interpolating ${t}`),r=""}else e(r)||this.useRawValueToEscape||(r=s(r));const f=s(i.safeValue(r));if(t=t.slice(0,a.index)+f+t.slice(a.index+a[0].length),g?(i.regex===this.regexpUnescape?m.push([a.index,a.index+f.length]):y+=f.length-a[0].length,i.regex.lastIndex+=f.length,i.regex.lastIndex-=a[0].length):i.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,i,o={}){let n,a,r;const l=(e,t)=>{const s=this.nestingOptionsSeparator;if(!e.includes(s))return e;const i=e.split(new RegExp(`${p(s)}[ ]*{`));let o=`{${i[1]}`;e=i[0],o=this.interpolate(o,r);const n=o.match(/'/g),a=o.match(/"/g);((n?.length??0)%2==0&&!a||(a?.length??0)%2!=0)&&(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),t&&(r={...t,...r})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${o}`}return r.defaultValue&&r.defaultValue.includes(this.prefix)&&delete r.defaultValue,e},c=new RegExp(this.nestingRegexp);let h="",u=0;for(;n=c.exec(t);){let p=[];r={...o},r=r.replace&&!e(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const g=/{.*}/s.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==g&&(p=n[1].slice(g).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,g)),a=i(l.call(this,n[1].trim(),r),r),a&&n[0]===t&&!e(a))return a;e(a)||(a=s(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${t}`),a=""),p.length&&(a=p.reduce((e,t)=>this.format(e,t,o.lng,{...o,interpolationkey:n[1].trim()}),a.trim())),h+=t.slice(u,n.index)+s(a),u=c.lastIndex,this.regexp.lastIndex=0}return u?h+t.slice(u):t}}const V=e=>{const t={};return(s,i,o)=>{let n,a=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(a={...a,[o.interpolationkey]:void 0});try{n=i+JSON.stringify(a)}catch(t){return e(b(i),o)(s)}let r=t[n];return r||(r=e(b(i),o),t[n]=r),r(s)}},I=e=>(t,s,i)=>e(b(s),i)(t);class T{constructor(e={}){this.logger=x.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?V:I;this.formats={number:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t});return e=>s.format(e)}),currency:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>s.format(e)}),datetime:s((e,t)=>{const s=new Intl.DateTimeFormat(e,{...t});return e=>s.format(e)}),relativetime:s((e,t)=>{const s=new Intl.RelativeTimeFormat(e,{...t});return e=>s.format(e,t.range||"day")}),list:s((e,t)=>{const s=new Intl.ListFormat(e,{...t});return e=>s.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=V(t)}format(e,t,s,i={}){if(!t)return e;if(null==e)return e;const o=t.split(this.formatSeparator),n=[];for(let e=0;e<o.length;e++){let t=o[e];for(;t.indexOf("(")>-1&&!t.includes(")")&&e+1<o.length;)t=`${t}${this.formatSeparator}${o[++e]}`;n.push(t)}return n.reduce((e,t)=>{const{formatName:o,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.includes("(")){const i=e.split("(");t=i[0].toLowerCase().trim();const o=i[1].slice(0,-1);"currency"!==t||o.includes(":")?"relativetime"!==t||o.includes(":")?o.split(";").forEach(e=>{if(e){const[t,...i]=e.split(":"),o=i.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();s[n]||(s[n]=o),"false"===o&&(s[n]=!1),"true"===o&&(s[n]=!0),isNaN(o)||(s[n]=parseInt(o,10))}}):s.range||(s.range=o.trim()):s.currency||(s.currency=o.trim())}return{formatName:t,formatOptions:s}})(t);if(this.formats[o]){let t=e;try{const a=i?.formatParams?.[i.interpolationkey]||{},r=a.locale||a.lng||i.locale||i.lng||s;t=this.formats[o](e,r,{...n,...i,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class H extends S{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=x.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i),this.callbackApi=o(this.backend),this.backend&&void 0===this.callbackApi&&(this.backend.read||this.backend.create)&&this.logger.deprecate("backend: set callbackApi to declare the calling convention (true: read(language, namespace, callback) and create(languages, namespace, key, fallbackValue, callback, options); false: both return a promise or a value); guessing it from the number of parameters is deprecated")}queueLoad(e,t,s,i){const o={},n={},a={},r={};return e.forEach(e=>{let i=!0;t.forEach(t=>{const a=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===n[a]&&(n[a]=!0):(this.state[a]=1,i=!1,void 0===n[a]&&(n[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===r[t]&&(r[t]=!0)))}),i||(a[e]=!0)}),(Object.keys(o).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(n),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(r)}}loaded(e,t,s){const i=e.split("|"),o=i[0],n=i[1];t&&this.emit("failedLoading",o,n,t),!t&&s&&this.store.addResourceBundle(o,n,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(s=>{((e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);i[o]=i[o]||[],i[o].push(s)})(s.loaded,[o],n),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach(e=>{a[e]||(a[e]={});const t=s.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,s,i=0,o=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:o,callback:n});this.readingCalls++;const a=(a,r)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&r&&i<this.maxRetries?setTimeout(()=>{this.read(e,t,s,i+1,2*o,n)},o):n(a,r)},r=this.backend[s].bind(this.backend);if(!1!==this.callbackApi&&(void 0!==this.callbackApi||2!==r.length))return r(e,t,a);try{const s=r(e,t);s&&"function"==typeof s.then?s.then(e=>a(null,e)).catch(a):a(null,s)}catch(e){a(e)}}prepareLoading(t,s,i={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();e(t)&&(t=this.languageUtils.toResolveHierarchy(t)),e(s)&&(s=[s]);const n=this.queueLoad(t,s,i,o);if(!n.toLoad.length)return n.pending.length||o(),null;n.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}noticeDevFallback(e){"dev"===e&&this.devIsDefaultFallback&&this.logger.once("dev","warn","language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior")}loadOne(e,t=""){const s=e.split("|"),i=s[0],o=s[1];this.noticeDevFallback(i),this.read(i,o,"read",void 0,void 0,(s,n)=>{s&&this.logger.warn(`${t}loading namespace ${o} for language ${i} failed`,s),!s&&n&&this.logger.log(`${t}loaded namespace ${o} for language ${i}`,n),this.loaded(e,s,n)})}saveMissing(e,t,s,i,o,n={},a=()=>{},r=this.newestCloneHasLoadedNamespace||this.services?.utils?.hasLoadedNamespace){if(!r||r(t)){if(null!=s&&""!==s){if(this.backend?.create){e?.forEach?.(e=>this.noticeDevFallback(e));const r={...n,isUpdate:o},l=this.backend.create.bind(this.backend);if(!1===this.callbackApi||void 0===this.callbackApi&&l.length<6)try{let o;o=!1===this.callbackApi||5===l.length?l(e,t,s,i,r):l(e,t,s,i),o&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,s,i,a,r)}e&&e[0]&&this.store.addResource(e[0],t,s,i)}}else this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const U=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,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:t=>{let s={};if("object"==typeof t[1]&&(s=t[1]),e(t[1])&&(s.defaultValue=t[1]),e(t[2])&&(s.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const e=t[3]||t[2];Object.keys(e).forEach(t=>{s[t]=e[t]})}return s},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=t=>(e(t.ns)&&(t.ns=[t.ns]),e(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),e(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),z=()=>{};let M;class B extends S{constructor(e={},t){var s;if(super(),this.options=K(e),this.services={ownPostProcessors:new Set},this.logger=x,this.modules={external:[]},s=this,Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach(e=>{"function"==typeof s[e]&&(s[e]=s[e].bind(s))}),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(s={},i){this.isInitializing=!0,"function"==typeof s&&(i=s,s={}),null==s.defaultNS&&s.ns&&(e(s.ns)?s.defaultNS=s.ns:s.ns.includes("translation")||(s.defaultNS=s.ns[0]));const n=void 0===s.fallbackLng&&void 0===this.options.fallbackLng,a=U();this.options={...a,...this.options,...K(s)},this.options.interpolation={...a.interpolation,...this.options.interpolation},void 0!==s.keySeparator&&(this.options.userDefinedKeySeparator=s.keySeparator),void 0!==s.nsSeparator&&(this.options.userDefinedNsSeparator=s.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=a.overloadTranslationOptionHandler);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;M&&M!==this&&M.modules.logger!==this.modules.logger&&x.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger"),M=this.modules.logger?this:void 0,this.modules.logger?x.init(r(this.modules.logger),this.options):x.init(null,this.options),this.pendingWarnings?.forEach(e=>this.logger.warn(e)),this.pendingWarnings=void 0,e=this.modules.formatter?this.modules.formatter:T;const t=new j(this.options);this.store=new w(this.options.resources,this.options);const s=this.services;s.logger=x,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new F(t,{prepend:this.options.pluralSeparator}),e&&(s.formatter=r(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new A(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this),reloadResources:this.reloadResources.bind(this)},s.backendConnector=new H(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.devIsDefaultFallback=n,s.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options),s.languageDetector.async&&void 0===o(s.languageDetector)&&this.logger.deprecate("languageDetector: set callbackApi to declare how the async detect() answers (true: detect(callback); false: detect() returns a promise); guessing it from the number of parameters is deprecated")),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new P(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,i||(i=z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});const l=t(),c=()=>{const e=(e,t)=>{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),l.resolve(t),i(e,t)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,s=z){let i=s;const o=e(t)?t:this.language;if("function"==typeof t&&(i=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===o?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return i();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&(e.includes(t)||e.push(t))})};if(o)t(o);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e))}this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),i(e)})}else i(null)}reloadResources(e,s,i){const o=t();return"function"==typeof e&&(i=e,e=void 0),"function"==typeof s&&(i=s,s=void 0),e||(e=this.languages||[]),s||(s=this.options.ns),i||(i=z),this.services.backendConnector.reload(e,s,e=>{o.resolve(),i(e)}),o}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()");const t=t=>{if(this.modules[t]&&this.modules[t]!==e){const e=`use: this ${t} replaces the ${t} passed to an earlier use() call; only one ${t} is used per instance`;this.isInitializing||this.isInitialized?this.logger.warn(e):(this.pendingWarnings=this.pendingWarnings||[]).push(e)}this.modules[t]=e};return"backend"===e.type&&t("backend"),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&t("languageDetector"),"i18nFormat"===e.type&&t("i18nFormat"),"postProcessor"===e.type&&($.addPostProcessor(e),this.services.ownPostProcessors?.add(e.name)),"formatter"===e.type&&t("formatter"),"3rdParty"===e.type&&this.modules.external.push(e),this}hydrate(e,t){return this.options.isClone?this:this.services.resourceStore?(e&&!this.initializedStoreOnce&&(this.services.resourceStore.data=e,Object.values(e).forEach(e=>{Object.keys(e).forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)})}),this.initializedStoreOnce=!0,this.isInitialized=!0),t&&!this.initializedLanguageOnce&&(this.changeLanguage(t),this.initializedLanguageOnce=!0),this):(this.logger.warn("hydrate: call init() first, the instance has no resource store yet"),this)}setResolvedLanguage(e){if(e&&this.languages&&!["cimode","dev"].includes(e)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!["cimode","dev"].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}this.resolvedLanguage||this.languages.includes(e)||!this.store.hasLanguageSomeTranslations(e)||(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(s,n){this.isLanguageChangingTo=s;const a=t();this.emit("languageChanging",s);const r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},l=(e,t)=>{t?this.isLanguageChangingTo===s&&(r(t),this.translator.changeLanguage(t),this.isLanguageChangingTo=void 0,this.emit("languageChanged",t),this.logger.log("languageChanged",t)):this.isLanguageChangingTo=void 0,a.resolve((...e)=>this.t(...e)),n&&n(e,(...e)=>this.t(...e))},c=t=>{s||t||!this.services.languageDetector||(t=[]);const o=e(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(o)?o:this.services.languageUtils.getBestMatchFromCodes(e(t)?[t]:t);if(n&&this.logger.debug&&!i(n)){[].concat(this.options.supportedLngs||[],this.services.languageUtils.getFallbackCodes(this.options.fallbackLng,n),this.options.preload||[]).includes(n)||Object.prototype.hasOwnProperty.call(this.store.data,n)||this.logger.once(`lng:${n}`,"deprecate",`changeLanguage: the language code '${n.slice(0,64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`)}n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{l(e,n)})};if(s||!this.services.languageDetector||this.services.languageDetector.async)if(!s&&this.services.languageDetector&&this.services.languageDetector.async){const e=o(this.services.languageDetector);!1===e||void 0===e&&0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c)}else c(s);else c(this.services.languageDetector.detect());return a}getFixedT(t,s,i,o){const n=o?.scopeNs,a=(e,t,...s)=>{let o;o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;const r=void 0!==o.ns&&null!==o.ns;o.ns=o.ns||a.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||i||a.keyPrefix);const l={...this.options,...o};Array.isArray(n)&&!r&&(l.ns=n),"function"==typeof o.keyPrefix&&(o.keyPrefix=C(o.keyPrefix,l));const c=this.options.keySeparator||".";let h;return o.keyPrefix&&Array.isArray(e)?h=e.map(e=>("function"==typeof e&&(e=C(e,l)),`${o.keyPrefix}${c}${e}`)):("function"==typeof e&&(e=C(e,l)),h=o.keyPrefix?`${o.keyPrefix}${c}${e}`:e),this.t(h,o)};return e(t)?a.lng=t:a.lngs=t,a.ns=s,a.keyPrefix=i,a}t(...e){return this.translator?this.translator.translate(...e):(this.logger.warn("t: called before init(); returning an empty string"),"")}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const n=(e,t)=>{const s=this.services.backendConnector.state[`${e}|${t}`];return-1===s||0===s||2===s};if(t.precheck){const e=t.precheck(this,n);if(void 0!==e)return e}if(this.hasResourceBundle(s,e))return!0;if(!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;const{languageUtils:a}=this.services,r=t.lng?a.isSupportedCode(s)&&a.toResolveHierarchy(s,!1)[0]:s;return!(r&&!n(r,e)||i&&!n(o,e))}loadNamespaces(s,i){const o=t();return this.options.ns?(e(s)&&(s=[s]),s.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}loadLanguages(s,i){const o=t();e(s)&&(s=[s]);const n=this.options.preload||[],a=s.filter(e=>!n.includes(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"ltr";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}const t=this.services?.languageUtils||new j(U());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].includes(t.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new B(e,t);return s.createInstance=B.createInstance,s}cloneInstance(e={},t=z){const s=e.forkResourceStore;s&&delete(e={...e}).forkResourceStore;const i={...this.options,preload:!1,...e,isClone:!0},o=new B(i);void 0===e.debug&&void 0===e.prefix||(o.logger=o.logger.clone(e));if(["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={...o.services.utils,hasLoadedNamespace:o.hasLoadedNamespace.bind(o),reloadResources:o.reloadResources.bind(o)},s){const e=t=>{const s=Array.isArray(t)?[...t]:{...t};return Object.keys(s).forEach(t=>{s[t]&&"object"==typeof s[t]&&(s[t]=e(s[t]))}),s},t=e(this.store.data);o.store=new w(t,i),o.services.resourceStore=o.store}if(e.interpolation){const t={...U().interpolation,...this.options.interpolation,...e.interpolation},s={...i,interpolation:t};o.services.interpolator=new A(s)}return o.translator=new P(o.services,i),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(i,t),o.translator.options=i,o.translator.backendConnector.newestCloneHasLoadedNamespace=o.hasLoadedNamespace.bind(o),o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _=B.createInstance();return _.keyFromSelector=C,_.isSafeLanguageCode=i,_});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).i18next=t()}(this,function(){"use strict";const e=e=>"string"==typeof e,t=()=>{let e,t;const s=new Promise((s,i)=>{e=s,t=i});return s.resolve=e,s.reject=t,s},s=e=>null==e?"":String(e),i=t=>e(t)&&/^[A-Za-z0-9_@.-]{1,128}$/.test(t)&&!t.includes("..")&&!["__proto__","constructor","prototype"].includes(t),o=e=>e?.callbackApi??e?.constructor?.callbackApi,n=/###/g,a=e=>e&&e.includes("###")?e.replace(n,"."):e,r=t=>!t||e(t),l=(t,s,i)=>{const o=e(s)?s.split("."):s;let n=0;for(;n<o.length-1;){if(r(t))return{};const e=a(o[n]);!t[e]&&i&&(t[e]=new i),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++n}return r(t)?{}:{obj:t,k:a(o[n])}},c=(e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);if(void 0!==i||1===t.length)return void(i[o]=s);let n=t[t.length-1],a=t.slice(0,t.length-1),r=l(e,a,Object);for(;void 0===r.obj&&a.length;)n=`${a[a.length-1]}.${n}`,a=a.slice(0,a.length-1),r=l(e,a,Object),r?.obj&&void 0!==r.obj[`${r.k}.${n}`]&&(r.obj=void 0);r.obj[`${r.k}.${n}`]=s},h=(e,t)=>{const{obj:s,k:i}=l(e,t);if(s&&Object.prototype.hasOwnProperty.call(s,i))return s[i]},u=(t,s,i)=>{for(const o in s)"__proto__"!==o&&"constructor"!==o&&(Object.prototype.hasOwnProperty.call(t,o)?e(t[o])||t[o]instanceof String||e(s[o])||s[o]instanceof String?i&&(t[o]=s[o]):u(t[o],s[o],i):t[o]=s[o]);return t},p=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},d=t=>e(t)?t.replace(/[&<>"'\/]/g,e=>g[e]):t;const f=[" ",",","?","!",";"],m=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(void 0!==t)return t;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}(20),y=(e,t,s=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}const i=t.split(s);let o=e;for(let e=0;e<i.length;){if(!o||"object"!=typeof o)return;let t,n="";for(let a=e;a<i.length;++a)if(a!==e&&(n+=s),n+=i[a],t=o[n],"function"!=typeof t&&"__proto__"!==n||Object.prototype.hasOwnProperty.call(o,n)||(t=void 0),void 0!==t){if(["string","number","boolean"].includes(typeof t)&&a<i.length-1)continue;e+=a-e+1;break}o=t}return o},b=e=>e?.replace(/_/g,"-"),v={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class k{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||v,this.options=t,this.debug=t.debug,this.seen=new Set}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)}once(e,t,...s){return!this.debug||this.seen.has(e)||this.seen.size>=1e3?null:(this.seen.add(e),this[t](...s))}forward(t,s,i,o){return o&&!this.debug?null:(t=t.map(t=>e(t)?t.replace(/[\r\n\x00-\x1F\x7F]/g," "):t),e(t[0])&&(t[0]=`${i}${this.prefix} ${t[0]}`),this.logger[s](t))}create(e){return new k(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new k(this.logger,e)}}var x=new k;class S{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);const s=this.observers[e].get(t)||0;this.observers[e].set(t,s+1)}),this}off(e,t){("string"==typeof e?e.split(" "):[e]).forEach(e=>{this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])})}once(e,t){const s=(...i)=>{t(...i),this.off(e,s)};return this.on(e,s),this}emit(e,...t){if(this.observers[e]){Array.from(this.observers[e].entries()).forEach(([e,s])=>{for(let i=0;i<s;i++)e(...t)})}if(this.observers["*"]){Array.from(this.observers["*"].entries()).forEach(([s,i])=>{for(let o=0;o<i;o++)s(e,...t)})}}}const L=new WeakSet;class w extends S{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,this.logger=x.create("resourceStore"),void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}deprecateDottedLng(e){this.logger.once(e,"deprecate",`${e}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`)}getResource(t,s,i,o={}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.includes(".")?(this.deprecateDottedLng("getResource"),r=t.split(".")):(r=[t,s],i&&(Array.isArray(i)?r.push(...i):e(i)&&n?r.push(...i.split(n)):r.push(i)));const l=h(this.data,r);return null!=l||s||i||!t.includes(".")||(t=r[0],s=r[1],i=r.slice(2).join(".")),null==l&&a&&e(i)?y(this.data?.[t]?.[s],i,n):l}addResource(e,t,s,i,o={silent:!1}){const n=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator;let a=[e,t];s&&(a=a.concat(n?s.split(n):s)),e.includes(".")&&(this.deprecateDottedLng("addResource"),a=e.split("."),i=t,t=a[1]),this.addNamespaces(t),c(this.data,a,i),o.silent||this.emit("added",e,t,s,i)}addResources(t,s,i,o={silent:!1}){for(const o in i)(e(i[o])||Array.isArray(i[o]))&&this.addResource(t,s,o,i[o],{silent:!0});o.silent||this.emit("added",t,s,i)}addResourceBundle(e,t,s,i,o,n={silent:!1,skipCopy:!1}){let a=[e,t];e.includes(".")&&(this.deprecateDottedLng("addResourceBundle"),a=e.split("."),i=s,s=t,t=a[1]),this.addNamespaces(t);let r=h(this.data,a)||{};n.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?u(r,s,o):r={...r,...s},c(this.data,a,r),n.silent||this.emit("added",e,t,s)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{const s=t[e];return!!L.has(s)||!(!s||0===Object.keys(s).length)&&("object"==typeof s&&L.add(s),!0)})}toJSON(){return this.data}}var $={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,s,i,o){return e.forEach(e=>{t=this.processors[e]?.process(t,s,i,o)??t}),t}};const C=Symbol("i18next/PATH_KEY");function O(e,t){const{[C]:s}=e(function(){const e=[],t=Object.create(null);let s;return t.get=(i,o)=>(s?.revoke?.(),o===C?e:(e.push(o),s=Proxy.revocable(i,t),s.proxy)),Proxy.revocable(Object.create(null),t).proxy}()),i=t?.keySeparator??".",o=t?.nsSeparator??":",n="strict"===t?.enableSelector;if(s.length>1&&o){const e=t?.ns,a=n?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(a){if((n?a:a.length>1?a.slice(1):[]).includes(s[0]))return`${s[0]}${o}${s.slice(1).join(i)}`}}return s.join(i)}const R=t=>!e(t)&&"boolean"!=typeof t&&"number"!=typeof t;class P extends S{constructor(e,t={}){var s,i;super(),s=e,i=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils","ownPostProcessors"].forEach(e=>{s[e]&&(i[e]=s[e])}),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=x.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const s={...t};if(null==e)return!1;const i=this.resolve(e,s);if(void 0===i?.res)return!1;const o=R(i.res);return!1!==s.returnObjects||!o}extractFromKey(t,s){let i=void 0!==s.nsSeparator?s.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");const o=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator;let n=s.ns||this.options.defaultNS||[];const a=i&&t.includes(i),r=!(this.options.userDefinedKeySeparator||s.keySeparator||this.options.userDefinedNsSeparator||s.nsSeparator||((e,t,s)=>{t=t||"",s=s||"";const i=f.filter(e=>!t.includes(e)&&!s.includes(e));if(0===i.length)return!0;const o=m.getRegExp(`(${i.map(e=>"?"===e?"\\?":e).join("|")})`);let n=!o.test(e);if(!n){const t=e.indexOf(s);t>0&&!o.test(e.substring(0,t))&&(n=!0)}return n})(t,i,o));if(a&&!r){const s=t.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:t,namespaces:e(n)?[n]:n};const a=t.split(i);(i!==o||i===o&&this.options.ns.includes(a[0]))&&(n=a.shift()),t=a.join(o)}return{key:t,namespaces:e(n)?[n]:n}}translate(t,s,i){let o="object"==typeof s?{...s}:s;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==t)return"";"function"==typeof t&&(t=O(t,{...this.options,...o})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>"function"==typeof e?O(e,{...this.options,...o}):String(e));const n=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,a=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:r,namespaces:l}=this.extractFromKey(t[t.length-1],o),c=l[l.length-1];let h=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===h&&(h=":");const u=o.lng||this.language,p=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return p?n?{res:`${c}${h}${r}`,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:`${c}${h}${r}`:n?{res:r,usedKey:r,exactUsedKey:r,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(o)}:r;const g=this.resolve(t,o);let d=g?.res;const f=g?.usedKey||r,m=g?.exactUsedKey||r,y=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==o.count&&!e(o.count),k=P.hasDefaultValue(o),x=v?this.pluralResolver.getSuffix(u,o.count,o):"",S=o.ordinal&&v?this.pluralResolver.getSuffix(u,o.count,{ordinal:!1}):"",L=v&&!o.ordinal&&0===o.count,w=L&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${x}`]||o[`defaultValue${S}`]||o.defaultValue;let $=d;b&&!d&&k&&($=w);const C=R($),j=Object.prototype.toString.apply($);if(!(b&&$&&C)||["[object Number]","[object Function]","[object RegExp]"].includes(j)||e(y)&&Array.isArray($))if(b&&e(y)&&Array.isArray(d))d=d.join(y),d&&(d=this.extendTranslation(d,t,o,g,i));else{let e=!1,s=!1;!this.isValidLookup(d)&&k&&(e=!0,d=w),this.isValidLookup(d)||(s=!0,d=r);const n=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&s?void 0:d,l=k&&w!==d&&this.options.updateMissing;if(s||e||l){if(this.logger.log(l?"updateKey":"missingKey",u,c,v&&!l?`${r}${this.pluralResolver.getSuffix(u,o.count,o)}`:r,l?w:d),a){const e=this.resolve(r,{...o,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[];const t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let s=0;s<t.length;s++)e.push(t[s]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(o.lng||this.language):e.push(o.lng||this.language);const s=(e,t,s)=>{const i=k&&s!==d?s:n;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,i,l,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,i,l,o,void 0,this.utils?.hasLoadedNamespace),this.emit("missingKey",e,c,t,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{const t=this.pluralResolver.getSuffixes(e,o);L&&o[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{s([e],r+t,o[`defaultValue${t}`]||w)})}):s(e,r,w))}d=this.extendTranslation(d,t,o,g,i),s&&d===r&&this.options.appendNamespaceToMissingKey&&(d=`${c}${h}${r}`),(s||e)&&this.options.parseMissingKeyHandler&&(d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${h}${r}`:r,e?d:void 0,o))}else{if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||(this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.logger.once("returnedObject","deprecate","accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)"));const e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,$,{...o,ns:l}):`key '${r} (${this.language})' returned an object instead of string.`;return n?(g.res=e,g.usedParams=this.getUsedParamsDetails(o),g):e}if(a){const e=Array.isArray($),t=e?[]:{},s=e?m:f;for(const e in $)if(Object.prototype.hasOwnProperty.call($,e)){const i=`${s}${a}${e}`;t[e]=k&&!d?this.translate(i,{...o,defaultValue:R(w)?w[e]:void 0,joinArrays:!1,ns:l}):this.translate(i,{...o,joinArrays:!1,ns:l}),t[e]===i&&(t[e]=$[e])}d=t}}return n?(g.res=d,g.usedParams=this.getUsedParamsDetails(o),g):d}extendTranslation(t,s,i,o,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const a=e(t)&&(void 0!==i?.interpolation?.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let r;if(a){const e=t.match(this.interpolator.nestingRegexp);r=e&&e.length}let l=i.replace&&!e(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,i.lng||this.language||o.usedLng,i),a){const e=t.match(this.interpolator.nestingRegexp);r<(e&&e.length)&&(i.nest=!1)}!i.lng&&o&&o.res&&(i.lng=this.language||o.usedLng),!1!==i.nest&&(t=this.interpolator.nest(t,(...e)=>n?.[0]!==e[0]||i.context?this.translate(...e,s):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${s[0]}`),null),i)),i.interpolation&&this.interpolator.reset()}const a=i.postProcess||this.options.postProcess,r=e(a)?[a]:a;return null!=t&&r?.length&&!1!==i.applyPostProcessor&&(r.forEach(e=>{this.logger.debug&&$.processors[e]&&this.ownPostProcessors&&!this.ownPostProcessors.has(e)&&this.logger.once(e,"deprecate",`postProcess: '${e}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`)}),t=$.handle(r,t,s,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),t}resolve(t,s={}){let i,o,n,a,r;return e(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(e=>"function"==typeof e?O(e,{...this.options,...s}):e)),t.forEach(t=>{if(this.isValidLookup(i))return;const l=this.extractFromKey(t,s),c=l.key;o=c;let h=l.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const u=void 0!==s.count&&!e(s.count),p=u&&!s.ordinal&&0===s.count,g=void 0!==s.context&&(e(s.context)||"number"==typeof s.context)&&""!==s.context,d=s.lngs?s.lngs:this.languageUtils.toResolveHierarchy(s.lng||this.language,s.fallbackLng);h.forEach(e=>{this.isValidLookup(i)||(r=e,this.checkedLoadedFor[`${d[0]}-${e}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(r)||(this.checkedLoadedFor[`${d[0]}-${e}`]=!0,this.logger.warn(`key "${o}" for languages "${d.join(", ")}" won't get resolved as namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach(t=>{if(this.isValidLookup(i))return;a=t;const o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,t,e,s);else{let e;u&&(e=this.pluralResolver.getSuffix(t,s.count,s));const i=`${this.options.pluralSeparator}zero`,n=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(s.ordinal&&e.startsWith(n)&&o.push(c+e.replace(n,this.options.pluralSeparator)),o.push(c+e),p&&o.push(c+i)),g){const t=`${c}${this.options.contextSeparator||"_"}${s.context}`;o.push(t),u&&(s.ordinal&&e.startsWith(n)&&o.push(t+e.replace(n,this.options.pluralSeparator)),o.push(t+e),p&&o.push(t+i))}}let r;for(;r=o.pop();)this.isValidLookup(i)||(n=r,i=this.getResource(t,e,r,s))}))})}),{res:i,usedKey:o,exactUsedKey:n,usedLng:a,usedNS:r}}isValidLookup(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}getResource(e,t,s,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,s,i):this.resourceStore.getResource(e,t,s,i)}getUsedParamsDetails(t={}){const s=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=t.replace&&!e(t.replace);let o=i?t.replace:t;if(i&&void 0!==t.count&&(o={...o,count:t.count}),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!i){o={...o};for(const e of s)delete o[e]}return o}static hasDefaultValue(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith("defaultValue")&&void 0!==e[t])return!0;return!1}}class j{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=x.create("languageUtils"),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(!(e=b(e))||!e.includes("-"))return null;const t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}getLanguagePartFromCode(e){if(!(e=b(e))||!e.includes("-"))return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(t){if(e(t)&&t.includes("-")){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(e){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}const s=this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t;return this.logger.debug&&e(t)&&this.deprecateBareCode(t,s),s}deprecateBareCode(e,t){let s;try{s=Intl.getCanonicalLocales(e)[0]}catch(e){return}let i=s.toLowerCase()===e.toLowerCase()?s:e.toLowerCase();this.options.lowerCaseLng&&(i=i.toLowerCase()),i!==t&&this.logger.once(e,"deprecate",`language code '${e}' is used as '${t}'; i18next v27 gives it the canonical casing '${i}', use '${i}' in lng, fallbackLng, supportedLngs and the resources`)}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;const s=this.formatLanguageCode(e);this.options.supportedLngs&&!this.isSupportedCode(s)||(t=s)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;const s=this.getScriptPartFromCode(e);if(this.isSupportedCode(s))return t=s;const i=this.getLanguagePartFromCode(e);if(this.isSupportedCode(i))return t=i;t=this.options.supportedLngs.find(e=>e===i||!(!e.includes("-")&&!i.includes("-"))&&!(!e.includes("-")||i.includes("-")||e.slice(0,e.indexOf("-"))!==i))}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(t,s){if(!t)return[];if("function"==typeof t&&(t=t(s)),e(t)&&(t=[t]),Array.isArray(t))return t;if(!s)return t.default||[];let i=t[s];return i||(i=t[this.getScriptPartFromCode(s)]),i||(i=t[this.formatLanguageCode(s)]),i||(i=t[this.getLanguagePartFromCode(s)]),i||(i=t.default),i||[]}toResolveHierarchy(t,s){const i=this.options.fallbackLng,o=Array.isArray(i)?i.join("|"):i;o!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=o);const n=void 0===s||!1===s||e(s),a=void 0===s&&"function"==typeof this.options.fallbackLng;let r=null;if(e(t)&&n&&!a){let e;e=void 0===s?"undefined":!1===s?"boolean:false":`string:${s}`,r=`${t.length}:${t}|${e}`}if(null!==r){const e=this.resolveHierarchyCache[r];if(void 0!==e)return e.slice()}const l=this.getFallbackCodes((!1===s?[]:s)||this.options.fallbackLng||[],t),c=[],h=e=>{e&&(this.isSupportedCode(e)?c.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return e(t)&&(t.includes("-")||t.includes("_"))?("languageOnly"!==this.options.load&&h(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&h(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&h(this.getLanguagePartFromCode(t))):e(t)&&h(this.formatLanguageCode(t)),l.forEach(e=>{const t=this.formatLanguageCode(e);c.includes(t)||h(t)}),null!==r?(this.resolveHierarchyCache[r]=c,c.slice()):c}}const N={zero:0,one:1,two:2,few:3,many:4,other:5},E={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class F{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=x.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const s=b("dev"===e?"en":e),i=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:s,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let n;try{n=new Intl.PluralRules(s,{type:i})}catch(s){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),E;if(!e.match(/-|_/))return E;const i=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(i,t)}return this.pluralRulesCache[o]=n,n}needsPlural(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,s={}){return this.getSuffixes(e,s).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let s=this.getRule(e,t);return s||(s=this.getRule("dev",t)),s?s.resolvedOptions().pluralCategories.sort((e,t)=>N[e]-N[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,s={}){const i=this.getRule(e,s);return i?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,s))}}const D=(t,s,i,o=".",n=!0)=>{let a=((e,t,s)=>{const i=h(e,s);return void 0!==i?i:h(t,s)})(t,s,i);return null==a&&n&&e(i)&&(a=y(t,i,o),void 0===a&&(a=y(s,i,o))),a};class A{constructor(e={}){this.logger=x.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:s,useRawValueToEscape:i,prefix:o,prefixEscaped:n,suffix:a,suffixEscaped:r,formatSeparator:l,unescapeSuffix:c,unescapePrefix:h,nestingPrefix:u,nestingPrefixEscaped:g,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:v}=e.interpolation;if(n||r||g||m){const e=Object.entries({prefixEscaped:n,suffixEscaped:r,nestingPrefixEscaped:g,nestingSuffixEscaped:m}).filter(([,e])=>e).map(([e])=>e);this.logger.once(e.join(),"deprecate",`interpolation.${e.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`)}this.escape=void 0!==t?t:d,this.escapeValue=void 0===s||s,this.useRawValueToEscape=void 0!==i&&i,this.prefix=o?p(o):n||"{{",this.suffix=a?p(a):r||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":h?p(h):"-",this.unescapeSuffix=this.unescapePrefix?"":c?p(c):"",this.nestingPrefix=u?p(u):g||p("$t("),this.nestingSuffix=f?p(f):m||p(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=void 0!==v&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,i,o,n){let a,r,l;const c=t,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){const t=D(i,h,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(t,void 0,o,{...n,...i,interpolationkey:e}):t}const t=e.split(this.formatSeparator),s=t.shift().trim(),a=t.join(this.formatSeparator).trim();return this.format(D(i,h,s,this.options.keySeparator,this.options.ignoreJSONStructure),a,o,{...n,...i,interpolationkey:s})};this.resetRegExp(),!this.escapeValue&&"string"==typeof t&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const p=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,g=void 0!==n?.interpolation?.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,f=[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:t=>this.escapeValue?(this.escape===d&&!1!==this.options?.interpolation?.escapeValue&&e(t)&&t.includes("/")&&this.logger.once("/","deprecate","escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is"),this.escape(t)):t}],m=[];let y=0;return f.forEach(i=>{for(l=0;a=i.regex.exec(t);){const o=a.index-y,h=m.find(([e,t])=>o>=e&&o<t);if(h){i.regex.lastIndex=h[1]+y;continue}const d=a[1].trim();if(r=u(d),void 0===r)if("function"==typeof p){const s=p(t,a,n);r=e(s)?s:""}else if(n&&Object.prototype.hasOwnProperty.call(n,d))r="";else{if(g){this.logger.debug&&this.logger.once(`${c}\0${a[0]}`,"warn",`missed to pass in variable ${d} for interpolating ${c}`),r=a[0];continue}this.logger.warn(`missed to pass in variable ${d} for interpolating ${t}`),r=""}else e(r)||this.useRawValueToEscape||(r=s(r));const f=s(i.safeValue(r));if(t=t.slice(0,a.index)+f+t.slice(a.index+a[0].length),g?(i.regex===this.regexpUnescape?m.push([a.index,a.index+f.length]):y+=f.length-a[0].length,i.regex.lastIndex+=f.length,i.regex.lastIndex-=a[0].length):i.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,i,o={}){let n,a,r;const l=(e,t)=>{const s=this.nestingOptionsSeparator;if(!e.includes(s))return e;const i=e.split(new RegExp(`${p(s)}[ ]*{`));let o=`{${i[1]}`;e=i[0],o=this.interpolate(o,r);const n=o.match(/'/g),a=o.match(/"/g);((n?.length??0)%2==0&&!a||(a?.length??0)%2!=0)&&(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),t&&(r={...t,...r})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${s}${o}`}return r.defaultValue&&r.defaultValue.includes(this.prefix)&&delete r.defaultValue,e},c=new RegExp(this.nestingRegexp);let h="",u=0;for(;n=c.exec(t);){let p=[];r={...o},r=r.replace&&!e(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const g=/{.*}/s.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==g&&(p=n[1].slice(g).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,g)),a=i(l.call(this,n[1].trim(),r),r),a&&n[0]===t&&!e(a))return a;e(a)||(a=s(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${t}`),a=""),p.length&&(a=p.reduce((e,t)=>this.format(e,t,o.lng,{...o,interpolationkey:n[1].trim()}),a.trim())),h+=t.slice(u,n.index)+s(a),u=c.lastIndex,this.regexp.lastIndex=0}return u?h+t.slice(u):t}}const V=e=>{const t={};return(s,i,o)=>{let n,a=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(a={...a,[o.interpolationkey]:void 0});try{n=i+JSON.stringify(a)}catch(t){return e(b(i),o)(s)}let r=t[n];return r||(r=e(b(i),o),t[n]=r),r(s)}},I=e=>(t,s,i)=>e(b(s),i)(t);class T{constructor(e={}){this.logger=x.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const s=t.cacheInBuiltFormats?V:I;this.formats={number:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t});return e=>s.format(e)}),currency:s((e,t)=>{const s=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>s.format(e)}),datetime:s((e,t)=>{const s=new Intl.DateTimeFormat(e,{...t});return e=>s.format(e)}),relativetime:s((e,t)=>{const s=new Intl.RelativeTimeFormat(e,{...t});return e=>s.format(e,t.range||"day")}),list:s((e,t)=>{const s=new Intl.ListFormat(e,{...t});return e=>s.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=V(t)}format(e,t,s,i={}){if(!t)return e;if(null==e)return e;const o=t.split(this.formatSeparator),n=[];for(let e=0;e<o.length;e++){let t=o[e];for(;t.indexOf("(")>-1&&!t.includes(")")&&e+1<o.length;)t=`${t}${this.formatSeparator}${o[++e]}`;n.push(t)}return n.reduce((e,t)=>{const{formatName:o,formatOptions:n}=(e=>{let t=e.toLowerCase().trim();const s={};if(e.includes("(")){const i=e.split("(");t=i[0].toLowerCase().trim();const o=i[1].slice(0,-1);"currency"!==t||o.includes(":")?"relativetime"!==t||o.includes(":")?o.split(";").forEach(e=>{if(e){const[t,...i]=e.split(":"),o=i.join(":").trim().replace(/^'+|'+$/g,""),n=t.trim();s[n]||(s[n]=o),"false"===o&&(s[n]=!1),"true"===o&&(s[n]=!0),isNaN(o)||(s[n]=parseInt(o,10))}}):s.range||(s.range=o.trim()):s.currency||(s.currency=o.trim())}return{formatName:t,formatOptions:s}})(t);if(this.formats[o]){let t=e;try{const a=i?.formatParams?.[i.interpolationkey]||{},r=a.locale||a.lng||i.locale||i.lng||s;t=this.formats[o](e,r,{...n,...i,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class H extends S{constructor(e,t,s,i={}){super(),this.backend=e,this.store=t,this.services=s,this.languageUtils=s.languageUtils,this.options=i,this.logger=x.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(s,i.backend,i),this.callbackApi=o(this.backend),this.backend&&void 0===this.callbackApi&&(this.backend.read||this.backend.create)&&this.logger.deprecate("backend: set callbackApi to declare the calling convention (true: read(language, namespace, callback) and create(languages, namespace, key, fallbackValue, callback, options); false: both return a promise or a value); guessing it from the number of parameters is deprecated")}queueLoad(e,t,s,i){const o={},n={},a={},r={};return e.forEach(e=>{let i=!0;t.forEach(t=>{const a=`${e}|${t}`;!s.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:!s.reload&&this.state[a]<0||(1===this.state[a]?void 0===n[a]&&(n[a]=!0):(this.state[a]=1,i=!1,void 0===n[a]&&(n[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===r[t]&&(r[t]=!0)))}),i||(a[e]=!0)}),(Object.keys(o).length||Object.keys(n).length)&&this.queue.push({pending:n,pendingCount:Object.keys(n).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(n),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(r)}}loaded(e,t,s){const i=e.split("|"),o=i[0],n=i[1];t&&this.emit("failedLoading",o,n,t),!t&&s&&this.store.addResourceBundle(o,n,s,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&s&&(this.state[e]=0);const a={};this.queue.forEach(s=>{((e,t,s)=>{const{obj:i,k:o}=l(e,t,Object);i[o]=i[o]||[],i[o].push(s)})(s.loaded,[o],n),((e,t)=>{void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)})(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach(e=>{a[e]||(a[e]={});const t=s.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,s,i=0,o=this.retryTimeout,n){if(!e.length)return n(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:o,callback:n});this.readingCalls++;const a=(a,r)=>{if(this.readingCalls--,this.waitingReads.length>0){const e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&r&&i<this.maxRetries?setTimeout(()=>{this.read(e,t,s,i+1,2*o,n)},o):n(a,r)},r=this.backend[s].bind(this.backend);if(!1!==this.callbackApi&&(void 0!==this.callbackApi||2!==r.length))return r(e,t,a);try{const s=r(e,t);s&&"function"==typeof s.then?s.then(e=>a(null,e)).catch(a):a(null,s)}catch(e){a(e)}}prepareLoading(t,s,i={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();e(t)&&(t=this.languageUtils.toResolveHierarchy(t)),e(s)&&(s=[s]);const n=this.queueLoad(t,s,i,o);if(!n.toLoad.length)return n.pending.length||o(),null;n.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,s){this.prepareLoading(e,t,{},s)}reload(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}noticeDevFallback(e){"dev"===e&&this.devIsDefaultFallback&&this.logger.once("dev","warn","language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior")}loadOne(e,t=""){const s=e.split("|"),i=s[0],o=s[1];this.noticeDevFallback(i),this.read(i,o,"read",void 0,void 0,(s,n)=>{s&&this.logger.warn(`${t}loading namespace ${o} for language ${i} failed`,s),!s&&n&&this.logger.log(`${t}loaded namespace ${o} for language ${i}`,n),this.loaded(e,s,n)})}saveMissing(e,t,s,i,o,n={},a=()=>{},r=this.newestCloneHasLoadedNamespace||this.services?.utils?.hasLoadedNamespace){if(!r||r(t)){if(null!=s&&""!==s){if(this.backend?.create){e?.forEach?.(e=>this.noticeDevFallback(e));const r={...n,isUpdate:o},l=this.backend.create.bind(this.backend);if(!1===this.callbackApi||void 0===this.callbackApi&&l.length<6)try{let o;o=!1===this.callbackApi||5===l.length?l(e,t,s,i,r):l(e,t,s,i),o&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,s,i,a,r)}e&&e[0]&&this.store.addResource(e[0],t,s,i)}}else this.logger.warn(`did not save key "${s}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const U=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,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:t=>{let s={};if("object"==typeof t[1]&&(s=t[1]),e(t[1])&&(s.defaultValue=t[1]),e(t[2])&&(s.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const e=t[3]||t[2];Object.keys(e).forEach(t=>{s[t]=e[t]})}return s},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),K=t=>(e(t.ns)&&(t.ns=[t.ns]),e(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),e(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),z=()=>{};let M;class B extends S{constructor(e={},t){var s;if(super(),this.options=K(e),this.services={ownPostProcessors:new Set},this.logger=x,this.modules={external:[]},s=this,Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach(e=>{"function"==typeof s[e]&&(s[e]=s[e].bind(s))}),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(s={},i){this.isInitializing=!0,"function"==typeof s&&(i=s,s={}),null==s.defaultNS&&s.ns&&(e(s.ns)?s.defaultNS=s.ns:s.ns.includes("translation")||(s.defaultNS=s.ns[0]));const n=void 0===s.fallbackLng&&void 0===this.options.fallbackLng,a=U();this.options={...a,...this.options,...K(s)},this.options.interpolation={...a.interpolation,...this.options.interpolation},void 0!==s.keySeparator&&(this.options.userDefinedKeySeparator=s.keySeparator),void 0!==s.nsSeparator&&(this.options.userDefinedNsSeparator=s.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=a.overloadTranslationOptionHandler);const r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;M&&M!==this&&M.modules.logger!==this.modules.logger&&x.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger"),M=this.modules.logger?this:void 0,this.modules.logger?x.init(r(this.modules.logger),this.options):x.init(null,this.options),this.pendingWarnings?.forEach(e=>this.logger.warn(e)),this.pendingWarnings=void 0,e=this.modules.formatter?this.modules.formatter:T;const t=new j(this.options);this.store=new w(this.options.resources,this.options);const s=this.services;s.logger=x,s.resourceStore=this.store,s.languageUtils=t,s.pluralResolver=new F(t,{prepend:this.options.pluralSeparator}),e&&(s.formatter=r(e),s.formatter.init&&s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new A(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this),reloadResources:this.reloadResources.bind(this)},s.backendConnector=new H(r(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.devIsDefaultFallback=n,s.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(s.languageDetector=r(this.modules.languageDetector),s.languageDetector.init&&s.languageDetector.init(s,this.options.detection,this.options),s.languageDetector.async&&void 0===o(s.languageDetector)&&this.logger.deprecate("languageDetector: set callbackApi to declare how the async detect() answers (true: detect(callback); false: detect() returns a promise); guessing it from the number of parameters is deprecated")),this.modules.i18nFormat&&(s.i18nFormat=r(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new P(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,i||(i=z),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});const l=t(),c=()=>{const e=(e,t)=>{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),l.resolve(t),i(e,t)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,s=z){let i=s;const o=e(t)?t:this.language;if("function"==typeof t&&(i=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===o?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return i();const e=[],t=t=>{if(!t)return;if("cimode"===t)return;this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&(e.includes(t)||e.push(t))})};if(o)t(o);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e))}this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),i(e)})}else i(null)}reloadResources(e,s,i){const o=t();if("function"==typeof e&&(i=e,e=void 0),"function"==typeof s&&(i=s,s=void 0),!e){const t=Object.keys(this.services.backendConnector.state).map(e=>e.split("|")[0]);e=[...new Set([...this.languages||[],...t])].filter(e=>"cimode"!==e)}return s||(s=this.options.ns),i||(i=z),this.services.backendConnector.reload(e,s,e=>{o.resolve(),i(e)}),o}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()");const t=t=>{if(this.modules[t]&&this.modules[t]!==e){const e=`use: this ${t} replaces the ${t} passed to an earlier use() call; only one ${t} is used per instance`;this.isInitializing||this.isInitialized?this.logger.warn(e):(this.pendingWarnings=this.pendingWarnings||[]).push(e)}this.modules[t]=e};return"backend"===e.type&&t("backend"),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&t("languageDetector"),"i18nFormat"===e.type&&t("i18nFormat"),"postProcessor"===e.type&&($.addPostProcessor(e),this.services.ownPostProcessors?.add(e.name)),"formatter"===e.type&&t("formatter"),"3rdParty"===e.type&&this.modules.external.push(e),this}hydrate(e,t){return this.options.isClone?this:this.services.resourceStore?(e&&!this.initializedStoreOnce&&(this.services.resourceStore.data=e,Object.values(e).forEach(e=>{Object.keys(e).forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)})}),this.initializedStoreOnce=!0,this.isInitialized=!0),t&&!this.initializedLanguageOnce&&(this.changeLanguage(t),this.initializedLanguageOnce=!0),this):(this.logger.warn("hydrate: call init() first, the instance has no resource store yet"),this)}setResolvedLanguage(e){if(e&&this.languages&&!["cimode","dev"].includes(e)){for(let e=0;e<this.languages.length;e++){const t=this.languages[e];if(!["cimode","dev"].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}this.resolvedLanguage||this.languages.includes(e)||!this.store.hasLanguageSomeTranslations(e)||(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(s,n){this.isLanguageChangingTo=s;const a=t();this.emit("languageChanging",s);const r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},l=(e,t)=>{t?this.isLanguageChangingTo===s&&(r(t),this.translator.changeLanguage(t),this.isLanguageChangingTo=void 0,this.emit("languageChanged",t),this.logger.log("languageChanged",t)):this.isLanguageChangingTo=void 0,a.resolve((...e)=>this.t(...e)),n&&n(e,(...e)=>this.t(...e))},c=t=>{s||t||!this.services.languageDetector||(t=[]);const o=e(t)?t:t&&t[0],n=this.store.hasLanguageSomeTranslations(o)?o:this.services.languageUtils.getBestMatchFromCodes(e(t)?[t]:t);if(n&&this.logger.debug&&!i(n)){[].concat(this.options.supportedLngs||[],this.services.languageUtils.getFallbackCodes(this.options.fallbackLng,n),this.options.preload||[]).includes(n)||Object.prototype.hasOwnProperty.call(this.store.data,n)||this.logger.once(`lng:${n}`,"deprecate",`changeLanguage: the language code '${n.slice(0,64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`)}n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{l(e,n)})};if(s||!this.services.languageDetector||this.services.languageDetector.async)if(!s&&this.services.languageDetector&&this.services.languageDetector.async){const e=o(this.services.languageDetector);!1===e||void 0===e&&0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c)}else c(s);else c(this.services.languageDetector.detect());return a}getFixedT(t,s,i,o){const n=o?.scopeNs,a=(e,t,...s)=>{let o;o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(s)):{...t},o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;const r=void 0!==o.ns&&null!==o.ns;o.ns=o.ns||a.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||i||a.keyPrefix);const l={...this.options,...o};Array.isArray(n)&&!r&&(l.ns=n),"function"==typeof o.keyPrefix&&(o.keyPrefix=O(o.keyPrefix,l));const c=this.options.keySeparator||".";let h;return o.keyPrefix&&Array.isArray(e)?h=e.map(e=>("function"==typeof e&&(e=O(e,l)),`${o.keyPrefix}${c}${e}`)):("function"==typeof e&&(e=O(e,l)),h=o.keyPrefix?`${o.keyPrefix}${c}${e}`:e),this.t(h,o)};return e(t)?a.lng=t:a.lngs=t,a.ns=s,a.keyPrefix=i,a}t(...e){return this.translator?this.translator.translate(...e):(this.logger.warn("t: called before init(); returning an empty string"),"")}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=t.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const n=(e,t)=>{const s=this.services.backendConnector.state[`${e}|${t}`];return-1===s||0===s||2===s};if(t.precheck){const e=t.precheck(this,n);if(void 0!==e)return e}if(this.hasResourceBundle(s,e))return!0;if(!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;const{languageUtils:a}=this.services,r=t.lng?a.isSupportedCode(s)&&a.toResolveHierarchy(s,!1)[0]:s;return!(r&&!n(r,e)||i&&!n(o,e))}loadNamespaces(s,i){const o=t();return this.options.ns?(e(s)&&(s=[s]),s.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}loadLanguages(s,i){const o=t();e(s)&&(s=[s]);const n=this.options.preload||[],a=s.filter(e=>!n.includes(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{o.resolve(),i&&i(e)}),o):(i&&i(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"ltr";try{const t=new Intl.Locale(e);if(t&&t.getTextInfo){const e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}const t=this.services?.languageUtils||new j(U());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].includes(t.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){const s=new B(e,t);return s.createInstance=B.createInstance,s}cloneInstance(e={},t=z){const s=e.forkResourceStore;s&&delete(e={...e}).forkResourceStore;const i={...this.options,preload:!1,...e,isClone:!0},o=new B(i);void 0===e.debug&&void 0===e.prefix||(o.logger=o.logger.clone(e));if(["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={...o.services.utils,hasLoadedNamespace:o.hasLoadedNamespace.bind(o),reloadResources:o.reloadResources.bind(o)},s){const e=t=>{const s=Array.isArray(t)?[...t]:{...t};return Object.keys(s).forEach(t=>{s[t]&&"object"==typeof s[t]&&(s[t]=e(s[t]))}),s},t=e(this.store.data);o.store=new w(t,i),o.services.resourceStore=o.store}if(e.interpolation){const t={...U().interpolation,...this.options.interpolation,...e.interpolation},s={...i,interpolation:t};o.services.interpolator=new A(s)}return o.translator=new P(o.services,i),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(i,t),o.translator.options=i,o.translator.backendConnector.newestCloneHasLoadedNamespace=o.hasLoadedNamespace.bind(o),o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _=B.createInstance();return _.keyFromSelector=O,_.isSafeLanguageCode=i,_});
|
package/index.d.ts
CHANGED
|
@@ -417,6 +417,8 @@ export interface i18n extends CustomInstanceExtensions {
|
|
|
417
417
|
|
|
418
418
|
/**
|
|
419
419
|
* Reloads resources on given state. Optionally you can pass an array of languages and namespaces as params if you don't want to reload all.
|
|
420
|
+
* Without languages it reloads the current languages and every language the backend loaded or tried to load, for this
|
|
421
|
+
* instance and its clones (since v26.7.1), and it retries the bundles that failed.
|
|
420
422
|
*/
|
|
421
423
|
reloadResources(
|
|
422
424
|
lngs?: string | readonly string[],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next",
|
|
3
|
-
"version": "26.7.
|
|
3
|
+
"version": "26.7.2",
|
|
4
4
|
"description": "i18next internationalization framework",
|
|
5
5
|
"main": "./dist/cjs/i18next.js",
|
|
6
6
|
"module": "./dist/esm/i18next.js",
|
|
@@ -66,40 +66,34 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@arktype/attest": "^0.
|
|
69
|
+
"@arktype/attest": "^0.58.0",
|
|
70
70
|
"@babel/core": "^7.29.0",
|
|
71
|
-
"@babel/plugin-transform-async-generator-functions": "^7.29.0",
|
|
72
|
-
"@babel/plugin-transform-modules-commonjs": "^7.29.0",
|
|
73
71
|
"@babel/preset-env": "^7.29.0",
|
|
74
72
|
"@babel/preset-react": "^7.29.0",
|
|
75
|
-
"@babel/register": "^7.29.0",
|
|
76
73
|
"@rollup/plugin-babel": "^7.1.0",
|
|
77
|
-
"@rollup/plugin-
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@typescript-eslint/parser": "^8.67.0",
|
|
83
|
-
"@vitest/coverage-v8": "4.1.12",
|
|
84
|
-
"babelify": "^10.0.0",
|
|
74
|
+
"@rollup/plugin-terser": "^1.0.2",
|
|
75
|
+
"@types/node": "^26.6.6",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
|
77
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
78
|
+
"@vitest/coverage-v8": "5.1.0",
|
|
85
79
|
"cpy-cli": "^7.0.0",
|
|
86
|
-
"eslint": "
|
|
80
|
+
"eslint": "^10.14.0",
|
|
87
81
|
"gh-release": "^8.1.0",
|
|
88
82
|
"husky": "^9.1.7",
|
|
89
|
-
"i18next-browser-languagedetector": "^8.
|
|
90
|
-
"i18next-fs-backend": "^2.6.
|
|
91
|
-
"i18next-http-backend": "^4.0.
|
|
83
|
+
"i18next-browser-languagedetector": "^8.3.0",
|
|
84
|
+
"i18next-fs-backend": "^2.6.10",
|
|
85
|
+
"i18next-http-backend": "^4.0.10",
|
|
92
86
|
"i18next-localstorage-cache": "^1.1.1",
|
|
93
87
|
"i18next-sprintf-postprocessor": "^0.2.2",
|
|
94
|
-
"lint-staged": "^17.
|
|
95
|
-
"neostandard": "^0.
|
|
88
|
+
"lint-staged": "^17.6.0",
|
|
89
|
+
"neostandard": "^0.14.1",
|
|
96
90
|
"nise": "6.1.5",
|
|
97
|
-
"prettier": "^3.9.
|
|
98
|
-
"rimraf": "^6.1.
|
|
99
|
-
"rollup": "^4.
|
|
91
|
+
"prettier": "^3.9.10",
|
|
92
|
+
"rimraf": "^6.1.4",
|
|
93
|
+
"rollup": "^4.67.4",
|
|
100
94
|
"typescript": "^6.0.3",
|
|
101
|
-
"typescript-eslint": "^8.
|
|
102
|
-
"vitest": "
|
|
95
|
+
"typescript-eslint": "^8.72.1",
|
|
96
|
+
"vitest": "5.1.0"
|
|
103
97
|
},
|
|
104
98
|
"scripts": {
|
|
105
99
|
"lint": "eslint src typescript test \"./*.{ts,mts,mjs}\"",
|
|
@@ -122,5 +116,8 @@
|
|
|
122
116
|
"license": "MIT",
|
|
123
117
|
"lint-staged": {
|
|
124
118
|
"*": "prettier --write --ignore-unknown"
|
|
119
|
+
},
|
|
120
|
+
"overrides": {
|
|
121
|
+
"minimatch": "^11.0.4"
|
|
125
122
|
}
|
|
126
123
|
}
|