From 3a247e13a6e21815d413e199c0577e8aea7ee7ee Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Sat, 24 Feb 2024 08:59:48 +0100 Subject: [PATCH 01/14] ci: add `codeQuality` and `build` jobs (#2146) * ci: add codeQuality and build jobs * chore: add pre-push hook with lint and format task --- .github/workflows/CI.yml | 78 +++++++++++++++++++++++++++++ .github/workflows/lint_and_test.yml | 43 ---------------- .husky/pre-push | 5 ++ README.md | 2 +- package.json | 5 +- 5 files changed, 87 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/lint_and_test.yml create mode 100755 .husky/pre-push diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..110c9db1a --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,78 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + # types: [opened, synchronize, reopened, ready_for_review] + branches: + - '**' + +jobs: + codeQuality: + name: Check code quality (lint and format) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Format check + run: npm run format + + - name: Format check + run: npm run lint + + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + test: + name: Test on node ${{ matrix.node }} and ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + node: [ '20.x', '18.x' ] + os: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Test + run: npm test + + - name: Run test to generate coverage + run: npm run test:coverage + + - name: Coveralls + uses: coverallsapp/github-action@v2 diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml deleted file mode 100644 index 9522596b4..000000000 --- a/.github/workflows/lint_and_test.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Lint & Test - -on: - push: - branches: - - master - pull_request: - # types: [opened, synchronize, reopened, ready_for_review] - branches: - - '**' - -jobs: - test: - name: Lint & test on node ${{ matrix.node }} and ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - node: [ '20.x', '18.x' ] - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: 'npm' - - - name: Install dependencies - run: npm install - - # lint is included in pretest - # - name: Lint - # run: npm run lint - - - name: Test - run: npm test - - - name: Run test to generate coverage - run: npm run test:coverage - - - name: Coveralls - uses: coverallsapp/github-action@v2 \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 000000000..174e92694 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,5 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run format +npm run lint diff --git a/README.md b/README.md index 5a9ad4440..a60cea698 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # i18next: learn once - translate everywhere [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Awesome%20i18next:%20learn%20once%20-%20translate%20everywhere%20-%20the%20internationalization%20ecosystem%20&url=https://github.com/i18next/i18next&via=jamuhl&hashtags=i18n,javascript,dev) -[![Lint & Test](https://github.com/i18next/i18next/actions/workflows/lint_and_test.yml/badge.svg?branch=master)](https://github.com/i18next/i18next/actions/workflows/lint_and_test.yml) +[![CI](https://github.com/i18next/i18next/actions/workflows/CI.yml/badge.svg)](https://github.com/i18next/i18next/actions/workflows/CI.yml) [![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/i18next/i18next) [![Coveralls](https://img.shields.io/coveralls/i18next/i18next/master.svg?style=flat-square)](https://coveralls.io/github/i18next/i18next) [![Package Quality](https://packagequality.com/shield/i18next.svg)](https://packagequality.com/#?package=i18next) diff --git a/package.json b/package.json index d33303620..717aff09a 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,9 @@ }, "scripts": { "lint": "eslint src typescript test \"./*.{ts,mts}\"", - "pretest": "npm run generate_ts_v4_index && npm run lint", + "format": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --check", + "format:fix": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --write", + "pretest": "npm run generate_ts_v4_index", "test": "vitest --run", "test:coverage": "vitest --project runtime --project compatibility --coverage --run", "test:runtime": "vitest --project runtime", @@ -113,7 +115,6 @@ "fix_dist_package": "node -e 'console.log(`{\"type\":\"module\",\"version\":\"${process.env.npm_package_version}\"}`)' > dist/esm/package.json", "preversion": "npm run test && npm run build && git push", "postversion": "npm run fix_dist_package && git push && git push --tags && npm run release", - "prettier": "prettier --write \"{,**/}*.{ts,tsx,mts,js,json,md}\"", "prepare": "husky install", "release": "gh-release" }, From 4685beae6be252f74d5b1002f93e731b5f46220d Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:03:20 +0100 Subject: [PATCH 02/14] test: move ts tests in a separate workspace, add test for ts v4, collect coverage only once (#2147) --- .github/workflows/CI.yml | 31 ++++++++++++++++++++++-- CONTRIBUTING.md | 5 ++-- package.json | 4 +++- vitest.workspace.mts | 38 ----------------------------- vitest.workspace.typescript.mts | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 44 deletions(-) create mode 100644 vitest.workspace.typescript.mts diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 110c9db1a..a8662a287 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -28,7 +28,7 @@ jobs: - name: Format check run: npm run format - - name: Format check + - name: Lint run: npm run lint build: @@ -56,6 +56,12 @@ jobs: matrix: node: [ '20.x', '18.x' ] os: [ubuntu-latest] + # Collect coverage only for node 20 and ubuntu-latest, no need to run it twice + # @see https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations + include: + - collectCoverage: true + node: '20.x' + os: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -69,10 +75,31 @@ jobs: run: npm install - name: Test + if: ${{ !matrix.collectCoverage }} run: npm test - - name: Run test to generate coverage + - name: Test with coverage + if: ${{ matrix.collectCoverage }} run: npm run test:coverage - name: Coveralls + if: ${{ matrix.collectCoverage }} uses: coverallsapp/github-action@v2 + + testTypescript: + name: Test typescript + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Test + run: npm run test:typescript diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 33d171aeb..3cd2e2056 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,10 +37,9 @@ npm run test:local ### Typescript If you want to run only a specific project use `--project` flag. -As value provide `ts-` followed by the folder name ```bash -npx vitest --project ts-custom-types +npm run test:typescript -- --project custom-types ``` #### New Test scenario @@ -51,4 +50,4 @@ If you need to create a new typescript test scenario: 2. Create a `tsconfig.json` and a `i18next.d.ts` with the relevant properties inside `CustomOptions` 3. If you need to test multiple tsconfig within the same scenario you can create another `tsconfig.json` but with a semantic name between tsconfig and json. E.g.: `tsconfig.nonEsModuleInterop.json` inside `test/typescript/misc` -4. For more information about workspace setup check `vitest.workspace.mts` +4. For more information about workspace setup check `vitest.workspace.typescript.mts` diff --git a/package.json b/package.json index 717aff09a..aace77618 100644 --- a/package.json +++ b/package.json @@ -105,10 +105,12 @@ "format": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --check", "format:fix": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --write", "pretest": "npm run generate_ts_v4_index", + "pretest:typescript": "npm run generate_ts_v4_index", "test": "vitest --run", - "test:coverage": "vitest --project runtime --project compatibility --coverage --run", + "test:coverage": "vitest --coverage --run", "test:runtime": "vitest --project runtime", "test:compatibility": "vitest --project compatibility", + "test:typescript": "vitest --workspace vitest.workspace.typescript.mts", "test:local": "vitest --workspace vitest.workspace.local.mts", "build": "rimraf dist && rollup -c && echo '{\"type\":\"module\"}' > dist/esm/package.json && cpy \"./dist/umd/*.js\" ./", "generate_ts_v4_index": "cp index.d.ts index.v4.d.ts && node -e \"fs.writeFileSync('index.v4.d.ts', fs.readFileSync('index.v4.d.ts').toString().replace(/t.js/g, 't.v4.js').replace(/export type \\* /g, '// export type * '))\"", diff --git a/vitest.workspace.mts b/vitest.workspace.mts index 61f7b6519..f7feac254 100644 --- a/vitest.workspace.mts +++ b/vitest.workspace.mts @@ -1,7 +1,5 @@ -import { readdirSync } from 'node:fs'; // eslint-disable-next-line import/no-extraneous-dependencies import { defineWorkspace } from 'vitest/config'; -import type { UserProjectConfigExport } from 'vitest/config'; export default defineWorkspace([ { @@ -17,40 +15,4 @@ export default defineWorkspace([ dir: './test/compatibility', }, }, - - /** - * If you need to test multiple typescript configurations (like misc) simply create a file named tsconfig.{customName}.json - * and this script will automatically create a new workspace named with the dirName followed by `customName` - */ - ...readdirSync('./test/typescript', { withFileTypes: true }) - .filter((dir) => dir.isDirectory()) - .reduce((workspaces, dir) => { - const dirPath = `test/typescript/${dir.name}` as const; - - const tsConfigFiles = readdirSync(dirPath).filter( - // Do not include temporary vitest tsconfig files - (it) => it.startsWith('tsconfig.') && it.endsWith('.json') && !it.includes('vitest-temp'), - ); - - tsConfigFiles.forEach((tsConfigFileName) => { - const workspaceName = - tsConfigFileName === 'tsconfig.json' - ? dir.name - : `${dir.name}-${tsConfigFileName.split('.')[1]}`; - - workspaces.push({ - test: { - dir: `./${dirPath}`, - name: `ts-${workspaceName}`, - typecheck: { - enabled: true, - include: [`**/${dirPath}/*.test.ts`], - tsconfig: `./${dirPath}/${tsConfigFileName}`, - }, - }, - }); - }); - - return workspaces; - }, []), ]); diff --git a/vitest.workspace.typescript.mts b/vitest.workspace.typescript.mts new file mode 100644 index 000000000..618d75c21 --- /dev/null +++ b/vitest.workspace.typescript.mts @@ -0,0 +1,42 @@ +import { readdirSync } from 'node:fs'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { defineWorkspace } from 'vitest/config'; +import type { UserProjectConfigExport } from 'vitest/config'; + +export default defineWorkspace( + /** + * If you need to test multiple typescript configurations (like misc) simply create a file named tsconfig.{customName}.json + * and this script will automatically create a new workspace named with the dirName followed by `customName` + */ + readdirSync('./test/typescript', { withFileTypes: true }) + .filter((dir) => dir.isDirectory()) + .reduce((workspaces, dir) => { + const dirPath = `test/typescript/${dir.name}` as const; + + const tsConfigFiles = readdirSync(dirPath).filter( + // Do not include temporary vitest tsconfig files + (it) => it.startsWith('tsconfig.') && it.endsWith('.json') && !it.includes('vitest-temp'), + ); + + tsConfigFiles.forEach((tsConfigFileName) => { + const workspaceName = + tsConfigFileName === 'tsconfig.json' + ? dir.name + : `${dir.name}-${tsConfigFileName.split('.')[1]}`; + + workspaces.push({ + test: { + dir: `./${dirPath}`, + name: workspaceName, + typecheck: { + enabled: true, + include: [`**/${dirPath}/*.test.ts`], + tsconfig: `./${dirPath}/${tsConfigFileName}`, + }, + }, + }); + }); + + return workspaces; + }, []), +); From f7b81761d3141ceef1f2010eca5b9b60f6e32d0e Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Fri, 8 Mar 2024 07:08:28 +0100 Subject: [PATCH 03/14] optimize getBestMatchFromCodes for https://github.com/i18next/i18next-browser-languageDetector/issues/281 --- CHANGELOG.md | 4 ++++ i18next.js | 3 ++- i18next.min.js | 2 +- src/LanguageUtils.js | 9 +++++++-- test/runtime/languageUtils.test.js | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69199a51..235b2cb4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 23.10.1 + +- optimize getBestMatchFromCodes for https://github.com/i18next/i18next-browser-languageDetector/issues/281 + ## 23.10.0 - Add 'isInitializing' property so we're able to detect init() was already called [2141](https://github.com/i18next/i18next/issues/2141) diff --git a/i18next.js b/i18next.js index d34b59fa9..97af1f9cc 100644 --- a/i18next.js +++ b/i18next.js @@ -948,7 +948,8 @@ found = this.options.supportedLngs.find(supportedLng => { if (supportedLng === lngOnly) return supportedLng; if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return; - if (supportedLng.indexOf(lngOnly) === 0) return supportedLng; + if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng; + if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng; }); }); } diff --git a/i18next.min.js b/i18next.min.js index 95aef8eed..d6ce5f016 100644 --- a/i18next.min.js +++ b/i18next.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).i18next=e()}(this,(function(){"use strict";const t={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console&&console[t]&&console[t].apply(console,e)}};class e{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.init(t,e)}init(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=s.prefix||"i18next:",this.logger=e||t,this.options=s,this.debug=s.debug}log(){for(var t=arguments.length,e=new Array(t),s=0;s{this.observers[t]||(this.observers[t]=new Map);const s=this.observers[t].get(e)||0;this.observers[t].set(e,s+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i{let[e,i]=t;for(let t=0;t{let[i,n]=e;for(let e=0;e{t=s,e=i}));return s.resolve=t,s.reject=e,s}function o(t){return null==t?"":""+t}const r=/###/g;function a(t,e,s){function i(t){return t&&t.indexOf("###")>-1?t.replace(r,"."):t}function n(){return!t||"string"==typeof t}const o="string"!=typeof e?e:e.split(".");let a=0;for(;a":">",'"':""","'":"'","/":"/"};function g(t){return"string"==typeof t?t.replace(/[&<>"'\/]/g,(t=>c[t])):t}const d=[" ",",","?","!",";"],f=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const s=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,s),this.regExpQueue.push(t),s}}(20);function m(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!t)return;if(t[e])return t[e];const i=e.split(s);let n=t;for(let t=0;t-1&&r0?t.replace("_","-"):t}class v extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.indexOf(".")>-1?r=t.split("."):(r=[t,e],s&&(Array.isArray(s)?r.push(...s):"string"==typeof s&&n?r.push(...s.split(n)):r.push(s)));const a=u(this.data,r);return!a&&!e&&!s&&t.indexOf(".")>-1&&(t=r[0],e=r[1],s=r.slice(2).join(".")),a||!o||"string"!=typeof s?a:m(this.data&&this.data[t]&&this.data[t][e],s,n)}addResource(t,e,s,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];s&&(r=r.concat(o?s.split(o):s)),t.indexOf(".")>-1&&(r=t.split("."),i=e,e=r[1]),this.addNamespaces(e),l(this.data,r,i),n.silent||this.emit("added",t,e,s,i)}addResources(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(t,e,i,s[i],{silent:!0});i.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1,skipCopy:!1},r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),i=s,s=e,e=r[1]),this.addNamespaces(e);let a=u(this.data,r)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?h(a,s,n):a={...a,...s},l(this.data,r,a),o.silent||this.emit("added",t,e,s)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),"v1"===this.options.compatibilityAPI?{...this.getResource(t,e)}:this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var b={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,s,i,n){return t.forEach((t=>{this.processors[t]&&(e=this.processors[t].process(e,s,i,n))})),e}};const x={};class S extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;super(),i=t,n=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(n[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=s.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==t)return!1;const s=this.resolve(t,e);return s&&void 0!==s.res}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const i=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||function(t,e,s){e=e||"",s=s||"";const i=d.filter((t=>e.indexOf(t)<0&&s.indexOf(t)<0));if(0===i.length)return!0;const n=f.getRegExp(`(${i.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(s);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o}(t,s,i));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:n};const o=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(i)}return"string"==typeof n&&(n=[n]),{key:t,namespaces:n}}translate(t,e,s){if("object"!=typeof e&&this.options.overloadTranslationOptionHandler&&(e=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof e&&(e={...e}),e||(e={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);const i=void 0!==e.returnDetails?e.returnDetails:this.options.returnDetails,n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator,{key:o,namespaces:r}=this.extractFromKey(t[t.length-1],e),a=r[r.length-1],l=e.lng||this.language,u=e.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(u){const t=e.nsSeparator||this.options.nsSeparator;return i?{res:`${a}${t}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:`${a}${t}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:o}const h=this.resolve(t,e);let p=h&&h.res;const c=h&&h.usedKey||o,g=h&&h.exactUsedKey||o,d=Object.prototype.toString.apply(p),f=void 0!==e.joinArrays?e.joinArrays:this.options.joinArrays,m=!this.i18nFormat||this.i18nFormat.handleAsObject;if(m&&p&&("string"!=typeof p&&"boolean"!=typeof p&&"number"!=typeof p)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(d)<0&&("string"!=typeof f||"[object Array]"!==d)){if(!e.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(c,p,{...e,ns:r}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=t,h.usedParams=this.getUsedParamsDetails(e),h):t}if(n){const t="[object Array]"===d,s=t?[]:{},i=t?g:c;for(const t in p)if(Object.prototype.hasOwnProperty.call(p,t)){const o=`${i}${n}${t}`;s[t]=this.translate(o,{...e,joinArrays:!1,ns:r}),s[t]===o&&(s[t]=p[t])}p=s}}else if(m&&"string"==typeof f&&"[object Array]"===d)p=p.join(f),p&&(p=this.extendTranslation(p,t,e,s));else{let i=!1,r=!1;const u=void 0!==e.count&&"string"!=typeof e.count,c=S.hasDefaultValue(e),g=u?this.pluralResolver.getSuffix(l,e.count,e):"",d=e.ordinal&&u?this.pluralResolver.getSuffix(l,e.count,{ordinal:!1}):"",f=u&&!e.ordinal&&0===e.count&&this.pluralResolver.shouldUseIntlApi(),m=f&&e[`defaultValue${this.options.pluralSeparator}zero`]||e[`defaultValue${g}`]||e[`defaultValue${d}`]||e.defaultValue;!this.isValidLookup(p)&&c&&(i=!0,p=m),this.isValidLookup(p)||(r=!0,p=o);const y=(e.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:p,v=c&&m!==p&&this.options.updateMissing;if(r||i||v){if(this.logger.log(v?"updateKey":"missingKey",l,a,o,v?m:p),n){const t=this.resolve(o,{...e,keySeparator:!1});t&&t.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 t=[];const s=this.languageUtils.getFallbackCodes(this.options.fallbackLng,e.lng||this.language);if("fallback"===this.options.saveMissingTo&&s&&s[0])for(let e=0;e{const n=c&&i!==p?i:y;this.options.missingKeyHandler?this.options.missingKeyHandler(t,a,s,n,v,e):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(t,a,s,n,v,e),this.emit("missingKey",t,a,s,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&u?t.forEach((t=>{const s=this.pluralResolver.getSuffixes(t,e);f&&e[`defaultValue${this.options.pluralSeparator}zero`]&&s.indexOf(`${this.options.pluralSeparator}zero`)<0&&s.push(`${this.options.pluralSeparator}zero`),s.forEach((s=>{i([t],o+s,e[`defaultValue${s}`]||m)}))})):i(t,o,m))}p=this.extendTranslation(p,t,e,h,s),r&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${a}:${o}`),(r||i)&&this.options.parseMissingKeyHandler&&(p="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${o}`:o,i?p:void 0):this.options.parseMissingKeyHandler(p))}return i?(h.res=p,h.usedParams=this.getUsedParamsDetails(e),h):p}extendTranslation(t,e,s,i,n){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const r="string"==typeof t&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(r){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let l=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,s.lng||this.language,s),r){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&i&&i.res&&(s.lng=i.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,(function(){for(var t=arguments.length,i=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.forEach((t=>{if(this.isValidLookup(e))return;const a=this.extractFromKey(t,r),l=a.key;s=l;let u=a.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const h=void 0!==r.count&&"string"!=typeof r.count,p=h&&!r.ordinal&&0===r.count&&this.pluralResolver.shouldUseIntlApi(),c=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach((t=>{this.isValidLookup(e)||(o=t,!x[`${g[0]}-${t}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(x[`${g[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach((s=>{if(this.isValidLookup(e))return;n=s;const o=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(o,l,s,t,r);else{let t;h&&(t=this.pluralResolver.getSuffix(s,r.count,r));const e=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(o.push(l+t),r.ordinal&&0===t.indexOf(i)&&o.push(l+t.replace(i,this.options.pluralSeparator)),p&&o.push(l+e)),c){const s=`${l}${this.options.contextSeparator}${r.context}`;o.push(s),h&&(o.push(s+t),r.ordinal&&0===t.indexOf(i)&&o.push(s+t.replace(i,this.options.pluralSeparator)),p&&o.push(s+e))}}let a;for(;a=o.pop();)this.isValidLookup(e)||(i=a,e=this.getResource(s,t,a,r))})))}))})),{res:e,usedKey:s,exactUsedKey:i,usedLng:n,usedNS:o}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,e,s,i):this.resourceStore.getResource(t,e,s,i)}getUsedParamsDetails(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&"string"!=typeof t.replace;let i=s?t.replace:t;if(s&&void 0!==t.count&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const t of e)delete i[t]}return i}static hasDefaultValue(t){const e="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e===s.substring(0,12)&&void 0!==t[s])return!0;return!1}}function k(t){return t.charAt(0).toUpperCase()+t.slice(1)}class O{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=s.create("languageUtils")}getScriptPartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if("string"==typeof t&&t.indexOf("-")>-1){const e=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map((t=>t.toLowerCase())):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase())),e.indexOf(s[2].toLowerCase())>-1&&(s[2]=k(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const s=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(s)||(e=s)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:0===t.indexOf(s)?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),"string"==typeof t&&(t=[t]),"[object Array]"===Object.prototype.toString.apply(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes(e||this.options.fallbackLng||[],t),i=[],n=t=>{t&&(this.isSupportedCode(t)?i.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return"string"==typeof t&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):"string"==typeof t&&n(this.formatLanguageCode(t)),s.forEach((t=>{i.indexOf(t)<0&&n(this.formatLanguageCode(t))})),i}}let L=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],w={1:function(t){return Number(t>1)},2:function(t){return Number(1!=t)},3:function(t){return 0},4:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},5:function(t){return Number(0==t?0:1==t?1:2==t?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5)},6:function(t){return Number(1==t?0:t>=2&&t<=4?1:2)},7:function(t){return Number(1==t?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},8:function(t){return Number(1==t?0:2==t?1:8!=t&&11!=t?2:3)},9:function(t){return Number(t>=2)},10:function(t){return Number(1==t?0:2==t?1:t<7?2:t<11?3:4)},11:function(t){return Number(1==t||11==t?0:2==t||12==t?1:t>2&&t<20?2:3)},12:function(t){return Number(t%10!=1||t%100==11)},13:function(t){return Number(0!==t)},14:function(t){return Number(1==t?0:2==t?1:3==t?2:3)},15:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2)},16:function(t){return Number(t%10==1&&t%100!=11?0:0!==t?1:2)},17:function(t){return Number(1==t||t%10==1&&t%100!=11?0:1)},18:function(t){return Number(0==t?0:1==t?1:2)},19:function(t){return Number(1==t?0:0==t||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3)},20:function(t){return Number(1==t?0:0==t||t%100>0&&t%100<20?1:2)},21:function(t){return Number(t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0)},22:function(t){return Number(1==t?0:2==t?1:(t<0||t>10)&&t%10==0?2:3)}};const N=["v1","v2","v3"],$=["v4"],R={zero:0,one:1,two:2,few:3,many:4,other:5};class C{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=t,this.options=e,this.logger=s.create("pluralResolver"),this.options.compatibilityJSON&&!$.includes(this.options.compatibilityJSON)||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=function(){const t={};return L.forEach((e=>{e.lngs.forEach((s=>{t[s]={numbers:e.nr,plurals:w[e.fc]}}))})),t}()}addRule(t,e){this.rules[t]=e}getRule(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(y("dev"===t?"en":t),{type:e.ordinal?"ordinal":"cardinal"})}catch(t){return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(t,s).map((t=>`${e}${t}`))}getSuffixes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(((t,e)=>R[t]-R[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):s.numbers.map((s=>this.getSuffix(t,s,e))):[]}getSuffix(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(e)}`:this.getSuffixRetroCompatible(i,e):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,e){const s=t.noAbs?t.plurals(e):t.plurals(Math.abs(e));let i=t.numbers[s];this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]&&(2===i?i="plural":1===i&&(i=""));const n=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?`_plural_${i.toString()}`:n():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]?n():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!N.includes(this.options.compatibilityJSON)}}function P(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=function(t,e,s){const i=u(t,s);return void 0!==i?i:u(e,s)}(t,e,s);return!o&&n&&"string"==typeof s&&(o=m(t,s,i),void 0===o&&(o=m(e,s,i))),o}class j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(t=>t),this.init(t)}init(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const e=t.interpolation;this.escape=void 0!==e.escape?e.escape:g,this.escapeValue=void 0===e.escapeValue||e.escapeValue,this.useRawValueToEscape=void 0!==e.useRawValueToEscape&&e.useRawValueToEscape,this.prefix=e.prefix?p(e.prefix):e.prefixEscaped||"{{",this.suffix=e.suffix?p(e.suffix):e.suffixEscaped||"}}",this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||",",this.unescapePrefix=e.unescapeSuffix?"":e.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":e.unescapeSuffix||"",this.nestingPrefix=e.nestingPrefix?p(e.nestingPrefix):e.nestingPrefixEscaped||p("$t("),this.nestingSuffix=e.nestingSuffix?p(e.nestingSuffix):e.nestingSuffixEscaped||p(")"),this.nestingOptionsSeparator=e.nestingOptionsSeparator?e.nestingOptionsSeparator:e.nestingOptionsSeparator||",",this.maxReplaces=e.maxReplaces?e.maxReplaces:1e3,this.alwaysFormat=void 0!==e.alwaysFormat&&e.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t&&t.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,e,s,i){let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(t){return t.replace(/\$/g,"$$$$")}const h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=P(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,s,{...i,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format(P(e,l,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,s,{...i,...e,interpolationkey:o})};this.resetRegExp();const p=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,c=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>u(t)},{regex:this.regexp,safeValue:t=>this.escapeValue?u(this.escape(t)):u(t)}].forEach((e=>{for(a=0;n=e.regex.exec(t);){const s=n[1].trim();if(r=h(s),void 0===r)if("function"==typeof p){const e=p(t,n,i);r="string"==typeof e?e:""}else if(i&&Object.prototype.hasOwnProperty.call(i,s))r="";else{if(c){r=n[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),r=""}else"string"==typeof r||this.useRawValueToEscape||(r=o(r));const l=e.safeValue(r);if(t=t.replace(n[0],l),c?(e.regex.lastIndex+=r.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),t}nest(t,e){let s,i,n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(t,e){const s=this.nestingOptionsSeparator;if(t.indexOf(s)<0)return t;const i=t.split(new RegExp(`${s}[ ]*{`));let o=`{${i[1]}`;t=i[0],o=this.interpolate(o,n);const r=o.match(/'/g),a=o.match(/"/g);(r&&r.length%2==0&&!a||a.length%2!=0)&&(o=o.replace(/'/g,'"'));try{n=JSON.parse(o),e&&(n={...e,...n})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${s}${o}`}return delete n.defaultValue,t}for(;s=this.nestingRegexp.exec(t);){let l=[];n={...r},n=n.replace&&"string"!=typeof n.replace?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;let u=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){const t=s[1].split(this.formatSeparator).map((t=>t.trim()));s[1]=t.shift(),l=t,u=!0}if(i=e(a.call(this,s[1].trim(),n),n),i&&s[0]===t&&"string"!=typeof i)return i;"string"!=typeof i&&(i=o(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=l.reduce(((t,e)=>this.format(t,e,r.lng,{...r,interpolationkey:s[1].trim()})),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}function E(t){const e={};return function(s,i,n){const o=i+JSON.stringify(n);let r=e[o];return r||(r=t(y(i),n),e[o]=r),r(s)}}class I{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("formatter"),this.options=t,this.formats={number:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e});return t=>s.format(t)})),currency:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>s.format(t)})),datetime:E(((t,e)=>{const s=new Intl.DateTimeFormat(t,{...e});return t=>s.format(t)})),relativetime:E(((t,e)=>{const s=new Intl.RelativeTimeFormat(t,{...e});return t=>s.format(t,e.range||"day")})),list:E(((t,e)=>{const s=new Intl.ListFormat(t,{...e});return t=>s.format(t)}))},this.init(t)}init(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||","}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=E(e)}format(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.split(this.formatSeparator).reduce(((t,e)=>{const{formatName:n,formatOptions:o}=function(t){let e=t.toLowerCase().trim();const s={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const n=i[1].substring(0,i[1].length-1);"currency"===e&&n.indexOf(":")<0?s.currency||(s.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?s.range||(s.range=n.trim()):n.split(";").forEach((t=>{if(!t)return;const[e,...i]=t.split(":"),n=i.join(":").trim().replace(/^'+|'+$/g,"");s[e.trim()]||(s[e.trim()]=n),"false"===n&&(s[e.trim()]=!1),"true"===n&&(s[e.trim()]=!0),isNaN(n)||(s[e.trim()]=parseInt(n,10))}))}return{formatName:e,formatOptions:s}}(e);if(this.formats[n]){let e=t;try{const r=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},a=r.locale||r.lng||i.locale||i.lng||s;e=this.formats[n](t,a,{...o,...i,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class F extends i{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=n,this.logger=s.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(i,n.backend,n)}queueLoad(t,e,s,i){const n={},o={},r={},a={};return t.forEach((t=>{let i=!0;e.forEach((e=>{const r=`${t}|${e}`;!s.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,i=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),i||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,s){const i=t.split("|"),n=i[0],o=i[1];e&&this.emit("failedLoading",n,o,e),s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2;const r={};this.queue.forEach((s=>{!function(t,e,s,i){const{obj:n,k:o}=a(t,e,Object);n[o]=n[o]||[],i&&(n[o]=n[o].concat(s)),i||n[o].push(s)}(s.loaded,[n],o),function(t,e){void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)}(s,t),e&&s.errors.push(e),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((t=>{r[t]||(r[t]={});const e=s.loaded[t];e.length&&e.forEach((e=>{void 0===r[t][e]&&(r[t][e]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((t=>!t.done))}read(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:s,tried:i,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&i{this.read.call(this,t,e,s,i+1,2*n,o)}),n):o(r,a)},a=this.backend[s].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const s=a(t,e);s&&"function"==typeof s.then?s.then((t=>r(null,t))).catch(r):r(null,s)}catch(t){r(t)}}prepareLoading(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof t&&(t=this.languageUtils.toResolveHierarchy(t)),"string"==typeof e&&(e=[e]);const n=this.queueLoad(t,e,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,s){this.prepareLoading(t,e,{},s)}reload(t,e,s){this.prepareLoading(t,e,{reload:!0},s)}loadOne(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=t.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${e}loading namespace ${n} for language ${i} failed`,s),!s&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${i}`,o),this.loaded(t,s,o)}))}saveMissing(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(e))this.logger.warn(`did not save key "${s}" as the namespace "${e}" 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!!!");else if(null!=s&&""!==s){if(this.backend&&this.backend.create){const a={...o,isUpdate:n},l=this.backend.create.bind(this.backend);if(l.length<6)try{let n;n=5===l.length?l(t,e,s,i,a):l(t,e,s,i),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else l(t,e,s,i,r,a)}t&&t[0]&&this.store.addResource(t[0],e,s,i)}}}function V(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let e={};if("object"==typeof t[1]&&(e=t[1]),"string"==typeof t[1]&&(e.defaultValue=t[1]),"string"==typeof t[2]&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const s=t[3]||t[2];Object.keys(s).forEach((t=>{e[t]=s[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function A(t){return"string"==typeof t.ns&&(t.ns=[t.ns]),"string"==typeof t.fallbackLng&&(t.fallbackLng=[t.fallbackLng]),"string"==typeof t.fallbackNS&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function D(){}class U extends i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;var i;if(super(),this.options=A(t),this.services={},this.logger=s,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,"function"==typeof e&&(i=e,e={}),!e.defaultNS&&!1!==e.defaultNS&&e.ns&&("string"==typeof e.ns?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const o=V();function r(t){return t?"function"==typeof t?new t:t:null}if(this.options={...o,...this.options,...A(e)},"v1"!==this.options.compatibilityAPI&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),!this.options.isClone){let e;this.modules.logger?s.init(r(this.modules.logger),this.options):s.init(null,this.options),this.modules.formatter?e=this.modules.formatter:"undefined"!=typeof Intl&&(e=I);const i=new O(this.options);this.store=new v(this.options.resources,this.options);const n=this.services;n.logger=s,n.resourceStore=this.store,n.languageUtils=i,n.pluralResolver=new C(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!e||this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format||(n.formatter=r(e),n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new j(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new F(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on("*",(function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n1?s-1:0),n=1;n{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,i||(i=D),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[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]=function(){return t.store[e](...arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=function(){return t.store[e](...arguments),t}}));const a=n(),l=()=>{const t=(t,e)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(e),i(t,e)};if(this.languages&&"v1"!==this.options.compatibilityAPI&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),a}loadResources(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s="string"==typeof t?t:this.language;if("function"==typeof t&&(e=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return e();const t=[],i=e=>{if(!e)return;if("cimode"===e)return;this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};if(s)i(s);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>i(t)))}this.options.preload&&this.options.preload.forEach((t=>i(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),e(t)}))}else e(null)}reloadResources(t,e,s){const i=n();return t||(t=this.languages),e||(e=this.options.ns),s||(s=D),this.services.backendConnector.reload(t,e,(t=>{i.resolve(),s(t)})),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&b.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1))for(let t=0;t-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}}changeLanguage(t,e){var s=this;this.isLanguageChangingTo=t;const i=n();this.emit("languageChanging",t);const o=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},r=(t,n)=>{n?(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve((function(){return s.t(...arguments)})),e&&e(t,(function(){return s.t(...arguments)}))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s="string"==typeof e?e:this.services.languageUtils.getBestMatchFromCodes(e);s&&(this.language||o(s),this.translator.language||this.translator.changeLanguage(s),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(s)),this.loadResources(s,(t=>{r(t,s)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),i}getFixedT(t,e,s){var i=this;const n=function(t,e){let o;if("object"!=typeof e){for(var r=arguments.length,a=new Array(r>2?r-2:0),l=2;l`${o.keyPrefix}${u}${t}`)):o.keyPrefix?`${o.keyPrefix}${u}${t}`:t,i.t(h,o)};return"string"==typeof t?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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=e.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(t,e)=>{const s=this.services.backendConnector.state[`${t}|${e}`];return-1===s||2===s};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!!this.hasResourceBundle(s,t)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,t)||i&&!o(n,t)))}loadNamespaces(t,e){const s=n();return this.options.ns?("string"==typeof t&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}loadLanguages(t,e){const s=n();"string"==typeof t&&(t=[t]);const i=this.options.preload||[],o=t.filter((t=>i.indexOf(t)<0));return o.length?(this.options.preload=i.concat(o),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const e=this.services&&this.services.languageUtils||new O(V());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){return new U(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},n=new U(i);void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t));return["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s&&(n.store=new v(this.store.data,i),n.services.resourceStore=n.store),n.translator=new S(n.services,i),n.translator.on("*",(function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{};this.init(t,e)}init(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=s.prefix||"i18next:",this.logger=e||t,this.options=s,this.debug=s.debug}log(){for(var t=arguments.length,e=new Array(t),s=0;s{this.observers[t]||(this.observers[t]=new Map);const s=this.observers[t].get(e)||0;this.observers[t].set(e,s+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i{let[e,i]=t;for(let t=0;t{let[i,n]=e;for(let e=0;e{t=s,e=i}));return s.resolve=t,s.reject=e,s}function o(t){return null==t?"":""+t}const r=/###/g;function a(t,e,s){function i(t){return t&&t.indexOf("###")>-1?t.replace(r,"."):t}function n(){return!t||"string"==typeof t}const o="string"!=typeof e?e:e.split(".");let a=0;for(;a":">",'"':""","'":"'","/":"/"};function g(t){return"string"==typeof t?t.replace(/[&<>"'\/]/g,(t=>c[t])):t}const d=[" ",",","?","!",";"],f=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const s=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,s),this.regExpQueue.push(t),s}}(20);function m(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!t)return;if(t[e])return t[e];const i=e.split(s);let n=t;for(let t=0;t-1&&r0?t.replace("_","-"):t}class v extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.indexOf(".")>-1?r=t.split("."):(r=[t,e],s&&(Array.isArray(s)?r.push(...s):"string"==typeof s&&n?r.push(...s.split(n)):r.push(s)));const a=u(this.data,r);return!a&&!e&&!s&&t.indexOf(".")>-1&&(t=r[0],e=r[1],s=r.slice(2).join(".")),a||!o||"string"!=typeof s?a:m(this.data&&this.data[t]&&this.data[t][e],s,n)}addResource(t,e,s,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];s&&(r=r.concat(o?s.split(o):s)),t.indexOf(".")>-1&&(r=t.split("."),i=e,e=r[1]),this.addNamespaces(e),l(this.data,r,i),n.silent||this.emit("added",t,e,s,i)}addResources(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(t,e,i,s[i],{silent:!0});i.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1,skipCopy:!1},r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),i=s,s=e,e=r[1]),this.addNamespaces(e);let a=u(this.data,r)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?h(a,s,n):a={...a,...s},l(this.data,r,a),o.silent||this.emit("added",t,e,s)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),"v1"===this.options.compatibilityAPI?{...this.getResource(t,e)}:this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var b={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,s,i,n){return t.forEach((t=>{this.processors[t]&&(e=this.processors[t].process(e,s,i,n))})),e}};const x={};class S extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;super(),i=t,n=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(n[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=s.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==t)return!1;const s=this.resolve(t,e);return s&&void 0!==s.res}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const i=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||function(t,e,s){e=e||"",s=s||"";const i=d.filter((t=>e.indexOf(t)<0&&s.indexOf(t)<0));if(0===i.length)return!0;const n=f.getRegExp(`(${i.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(s);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o}(t,s,i));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:n};const o=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(i)}return"string"==typeof n&&(n=[n]),{key:t,namespaces:n}}translate(t,e,s){if("object"!=typeof e&&this.options.overloadTranslationOptionHandler&&(e=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof e&&(e={...e}),e||(e={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);const i=void 0!==e.returnDetails?e.returnDetails:this.options.returnDetails,n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator,{key:o,namespaces:r}=this.extractFromKey(t[t.length-1],e),a=r[r.length-1],l=e.lng||this.language,u=e.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(u){const t=e.nsSeparator||this.options.nsSeparator;return i?{res:`${a}${t}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:`${a}${t}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:o}const h=this.resolve(t,e);let p=h&&h.res;const c=h&&h.usedKey||o,g=h&&h.exactUsedKey||o,d=Object.prototype.toString.apply(p),f=void 0!==e.joinArrays?e.joinArrays:this.options.joinArrays,m=!this.i18nFormat||this.i18nFormat.handleAsObject;if(m&&p&&("string"!=typeof p&&"boolean"!=typeof p&&"number"!=typeof p)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(d)<0&&("string"!=typeof f||"[object Array]"!==d)){if(!e.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(c,p,{...e,ns:r}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=t,h.usedParams=this.getUsedParamsDetails(e),h):t}if(n){const t="[object Array]"===d,s=t?[]:{},i=t?g:c;for(const t in p)if(Object.prototype.hasOwnProperty.call(p,t)){const o=`${i}${n}${t}`;s[t]=this.translate(o,{...e,joinArrays:!1,ns:r}),s[t]===o&&(s[t]=p[t])}p=s}}else if(m&&"string"==typeof f&&"[object Array]"===d)p=p.join(f),p&&(p=this.extendTranslation(p,t,e,s));else{let i=!1,r=!1;const u=void 0!==e.count&&"string"!=typeof e.count,c=S.hasDefaultValue(e),g=u?this.pluralResolver.getSuffix(l,e.count,e):"",d=e.ordinal&&u?this.pluralResolver.getSuffix(l,e.count,{ordinal:!1}):"",f=u&&!e.ordinal&&0===e.count&&this.pluralResolver.shouldUseIntlApi(),m=f&&e[`defaultValue${this.options.pluralSeparator}zero`]||e[`defaultValue${g}`]||e[`defaultValue${d}`]||e.defaultValue;!this.isValidLookup(p)&&c&&(i=!0,p=m),this.isValidLookup(p)||(r=!0,p=o);const y=(e.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:p,v=c&&m!==p&&this.options.updateMissing;if(r||i||v){if(this.logger.log(v?"updateKey":"missingKey",l,a,o,v?m:p),n){const t=this.resolve(o,{...e,keySeparator:!1});t&&t.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 t=[];const s=this.languageUtils.getFallbackCodes(this.options.fallbackLng,e.lng||this.language);if("fallback"===this.options.saveMissingTo&&s&&s[0])for(let e=0;e{const n=c&&i!==p?i:y;this.options.missingKeyHandler?this.options.missingKeyHandler(t,a,s,n,v,e):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(t,a,s,n,v,e),this.emit("missingKey",t,a,s,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&u?t.forEach((t=>{const s=this.pluralResolver.getSuffixes(t,e);f&&e[`defaultValue${this.options.pluralSeparator}zero`]&&s.indexOf(`${this.options.pluralSeparator}zero`)<0&&s.push(`${this.options.pluralSeparator}zero`),s.forEach((s=>{i([t],o+s,e[`defaultValue${s}`]||m)}))})):i(t,o,m))}p=this.extendTranslation(p,t,e,h,s),r&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${a}:${o}`),(r||i)&&this.options.parseMissingKeyHandler&&(p="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${o}`:o,i?p:void 0):this.options.parseMissingKeyHandler(p))}return i?(h.res=p,h.usedParams=this.getUsedParamsDetails(e),h):p}extendTranslation(t,e,s,i,n){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const r="string"==typeof t&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(r){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let l=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,s.lng||this.language,s),r){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&i&&i.res&&(s.lng=i.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,(function(){for(var t=arguments.length,i=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.forEach((t=>{if(this.isValidLookup(e))return;const a=this.extractFromKey(t,r),l=a.key;s=l;let u=a.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const h=void 0!==r.count&&"string"!=typeof r.count,p=h&&!r.ordinal&&0===r.count&&this.pluralResolver.shouldUseIntlApi(),c=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach((t=>{this.isValidLookup(e)||(o=t,!x[`${g[0]}-${t}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(x[`${g[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach((s=>{if(this.isValidLookup(e))return;n=s;const o=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(o,l,s,t,r);else{let t;h&&(t=this.pluralResolver.getSuffix(s,r.count,r));const e=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(o.push(l+t),r.ordinal&&0===t.indexOf(i)&&o.push(l+t.replace(i,this.options.pluralSeparator)),p&&o.push(l+e)),c){const s=`${l}${this.options.contextSeparator}${r.context}`;o.push(s),h&&(o.push(s+t),r.ordinal&&0===t.indexOf(i)&&o.push(s+t.replace(i,this.options.pluralSeparator)),p&&o.push(s+e))}}let a;for(;a=o.pop();)this.isValidLookup(e)||(i=a,e=this.getResource(s,t,a,r))})))}))})),{res:e,usedKey:s,exactUsedKey:i,usedLng:n,usedNS:o}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,e,s,i):this.resourceStore.getResource(t,e,s,i)}getUsedParamsDetails(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&"string"!=typeof t.replace;let i=s?t.replace:t;if(s&&void 0!==t.count&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const t of e)delete i[t]}return i}static hasDefaultValue(t){const e="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e===s.substring(0,12)&&void 0!==t[s])return!0;return!1}}function k(t){return t.charAt(0).toUpperCase()+t.slice(1)}class O{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=s.create("languageUtils")}getScriptPartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if("string"==typeof t&&t.indexOf("-")>-1){const e=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map((t=>t.toLowerCase())):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase())),e.indexOf(s[2].toLowerCase())>-1&&(s[2]=k(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const s=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(s)||(e=s)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),"string"==typeof t&&(t=[t]),"[object Array]"===Object.prototype.toString.apply(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes(e||this.options.fallbackLng||[],t),i=[],n=t=>{t&&(this.isSupportedCode(t)?i.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return"string"==typeof t&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):"string"==typeof t&&n(this.formatLanguageCode(t)),s.forEach((t=>{i.indexOf(t)<0&&n(this.formatLanguageCode(t))})),i}}let L=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],w={1:function(t){return Number(t>1)},2:function(t){return Number(1!=t)},3:function(t){return 0},4:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},5:function(t){return Number(0==t?0:1==t?1:2==t?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5)},6:function(t){return Number(1==t?0:t>=2&&t<=4?1:2)},7:function(t){return Number(1==t?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},8:function(t){return Number(1==t?0:2==t?1:8!=t&&11!=t?2:3)},9:function(t){return Number(t>=2)},10:function(t){return Number(1==t?0:2==t?1:t<7?2:t<11?3:4)},11:function(t){return Number(1==t||11==t?0:2==t||12==t?1:t>2&&t<20?2:3)},12:function(t){return Number(t%10!=1||t%100==11)},13:function(t){return Number(0!==t)},14:function(t){return Number(1==t?0:2==t?1:3==t?2:3)},15:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2)},16:function(t){return Number(t%10==1&&t%100!=11?0:0!==t?1:2)},17:function(t){return Number(1==t||t%10==1&&t%100!=11?0:1)},18:function(t){return Number(0==t?0:1==t?1:2)},19:function(t){return Number(1==t?0:0==t||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3)},20:function(t){return Number(1==t?0:0==t||t%100>0&&t%100<20?1:2)},21:function(t){return Number(t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0)},22:function(t){return Number(1==t?0:2==t?1:(t<0||t>10)&&t%10==0?2:3)}};const N=["v1","v2","v3"],$=["v4"],R={zero:0,one:1,two:2,few:3,many:4,other:5};class C{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=t,this.options=e,this.logger=s.create("pluralResolver"),this.options.compatibilityJSON&&!$.includes(this.options.compatibilityJSON)||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=function(){const t={};return L.forEach((e=>{e.lngs.forEach((s=>{t[s]={numbers:e.nr,plurals:w[e.fc]}}))})),t}()}addRule(t,e){this.rules[t]=e}getRule(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(y("dev"===t?"en":t),{type:e.ordinal?"ordinal":"cardinal"})}catch(t){return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(t,s).map((t=>`${e}${t}`))}getSuffixes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(((t,e)=>R[t]-R[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):s.numbers.map((s=>this.getSuffix(t,s,e))):[]}getSuffix(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(e)}`:this.getSuffixRetroCompatible(i,e):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,e){const s=t.noAbs?t.plurals(e):t.plurals(Math.abs(e));let i=t.numbers[s];this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]&&(2===i?i="plural":1===i&&(i=""));const n=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?`_plural_${i.toString()}`:n():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]?n():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!N.includes(this.options.compatibilityJSON)}}function P(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=function(t,e,s){const i=u(t,s);return void 0!==i?i:u(e,s)}(t,e,s);return!o&&n&&"string"==typeof s&&(o=m(t,s,i),void 0===o&&(o=m(e,s,i))),o}class j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(t=>t),this.init(t)}init(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const e=t.interpolation;this.escape=void 0!==e.escape?e.escape:g,this.escapeValue=void 0===e.escapeValue||e.escapeValue,this.useRawValueToEscape=void 0!==e.useRawValueToEscape&&e.useRawValueToEscape,this.prefix=e.prefix?p(e.prefix):e.prefixEscaped||"{{",this.suffix=e.suffix?p(e.suffix):e.suffixEscaped||"}}",this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||",",this.unescapePrefix=e.unescapeSuffix?"":e.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":e.unescapeSuffix||"",this.nestingPrefix=e.nestingPrefix?p(e.nestingPrefix):e.nestingPrefixEscaped||p("$t("),this.nestingSuffix=e.nestingSuffix?p(e.nestingSuffix):e.nestingSuffixEscaped||p(")"),this.nestingOptionsSeparator=e.nestingOptionsSeparator?e.nestingOptionsSeparator:e.nestingOptionsSeparator||",",this.maxReplaces=e.maxReplaces?e.maxReplaces:1e3,this.alwaysFormat=void 0!==e.alwaysFormat&&e.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t&&t.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,e,s,i){let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(t){return t.replace(/\$/g,"$$$$")}const h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=P(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,s,{...i,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format(P(e,l,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,s,{...i,...e,interpolationkey:o})};this.resetRegExp();const p=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,c=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>u(t)},{regex:this.regexp,safeValue:t=>this.escapeValue?u(this.escape(t)):u(t)}].forEach((e=>{for(a=0;n=e.regex.exec(t);){const s=n[1].trim();if(r=h(s),void 0===r)if("function"==typeof p){const e=p(t,n,i);r="string"==typeof e?e:""}else if(i&&Object.prototype.hasOwnProperty.call(i,s))r="";else{if(c){r=n[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),r=""}else"string"==typeof r||this.useRawValueToEscape||(r=o(r));const l=e.safeValue(r);if(t=t.replace(n[0],l),c?(e.regex.lastIndex+=r.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),t}nest(t,e){let s,i,n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(t,e){const s=this.nestingOptionsSeparator;if(t.indexOf(s)<0)return t;const i=t.split(new RegExp(`${s}[ ]*{`));let o=`{${i[1]}`;t=i[0],o=this.interpolate(o,n);const r=o.match(/'/g),a=o.match(/"/g);(r&&r.length%2==0&&!a||a.length%2!=0)&&(o=o.replace(/'/g,'"'));try{n=JSON.parse(o),e&&(n={...e,...n})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${s}${o}`}return delete n.defaultValue,t}for(;s=this.nestingRegexp.exec(t);){let l=[];n={...r},n=n.replace&&"string"!=typeof n.replace?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;let u=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){const t=s[1].split(this.formatSeparator).map((t=>t.trim()));s[1]=t.shift(),l=t,u=!0}if(i=e(a.call(this,s[1].trim(),n),n),i&&s[0]===t&&"string"!=typeof i)return i;"string"!=typeof i&&(i=o(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=l.reduce(((t,e)=>this.format(t,e,r.lng,{...r,interpolationkey:s[1].trim()})),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}function E(t){const e={};return function(s,i,n){const o=i+JSON.stringify(n);let r=e[o];return r||(r=t(y(i),n),e[o]=r),r(s)}}class I{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("formatter"),this.options=t,this.formats={number:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e});return t=>s.format(t)})),currency:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>s.format(t)})),datetime:E(((t,e)=>{const s=new Intl.DateTimeFormat(t,{...e});return t=>s.format(t)})),relativetime:E(((t,e)=>{const s=new Intl.RelativeTimeFormat(t,{...e});return t=>s.format(t,e.range||"day")})),list:E(((t,e)=>{const s=new Intl.ListFormat(t,{...e});return t=>s.format(t)}))},this.init(t)}init(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||","}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=E(e)}format(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.split(this.formatSeparator).reduce(((t,e)=>{const{formatName:n,formatOptions:o}=function(t){let e=t.toLowerCase().trim();const s={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const n=i[1].substring(0,i[1].length-1);"currency"===e&&n.indexOf(":")<0?s.currency||(s.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?s.range||(s.range=n.trim()):n.split(";").forEach((t=>{if(!t)return;const[e,...i]=t.split(":"),n=i.join(":").trim().replace(/^'+|'+$/g,"");s[e.trim()]||(s[e.trim()]=n),"false"===n&&(s[e.trim()]=!1),"true"===n&&(s[e.trim()]=!0),isNaN(n)||(s[e.trim()]=parseInt(n,10))}))}return{formatName:e,formatOptions:s}}(e);if(this.formats[n]){let e=t;try{const r=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},a=r.locale||r.lng||i.locale||i.lng||s;e=this.formats[n](t,a,{...o,...i,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class F extends i{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=n,this.logger=s.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(i,n.backend,n)}queueLoad(t,e,s,i){const n={},o={},r={},a={};return t.forEach((t=>{let i=!0;e.forEach((e=>{const r=`${t}|${e}`;!s.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,i=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),i||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,s){const i=t.split("|"),n=i[0],o=i[1];e&&this.emit("failedLoading",n,o,e),s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2;const r={};this.queue.forEach((s=>{!function(t,e,s,i){const{obj:n,k:o}=a(t,e,Object);n[o]=n[o]||[],i&&(n[o]=n[o].concat(s)),i||n[o].push(s)}(s.loaded,[n],o),function(t,e){void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)}(s,t),e&&s.errors.push(e),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((t=>{r[t]||(r[t]={});const e=s.loaded[t];e.length&&e.forEach((e=>{void 0===r[t][e]&&(r[t][e]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((t=>!t.done))}read(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:s,tried:i,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&i{this.read.call(this,t,e,s,i+1,2*n,o)}),n):o(r,a)},a=this.backend[s].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const s=a(t,e);s&&"function"==typeof s.then?s.then((t=>r(null,t))).catch(r):r(null,s)}catch(t){r(t)}}prepareLoading(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof t&&(t=this.languageUtils.toResolveHierarchy(t)),"string"==typeof e&&(e=[e]);const n=this.queueLoad(t,e,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,s){this.prepareLoading(t,e,{},s)}reload(t,e,s){this.prepareLoading(t,e,{reload:!0},s)}loadOne(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=t.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${e}loading namespace ${n} for language ${i} failed`,s),!s&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${i}`,o),this.loaded(t,s,o)}))}saveMissing(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(e))this.logger.warn(`did not save key "${s}" as the namespace "${e}" 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!!!");else if(null!=s&&""!==s){if(this.backend&&this.backend.create){const a={...o,isUpdate:n},l=this.backend.create.bind(this.backend);if(l.length<6)try{let n;n=5===l.length?l(t,e,s,i,a):l(t,e,s,i),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else l(t,e,s,i,r,a)}t&&t[0]&&this.store.addResource(t[0],e,s,i)}}}function V(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let e={};if("object"==typeof t[1]&&(e=t[1]),"string"==typeof t[1]&&(e.defaultValue=t[1]),"string"==typeof t[2]&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const s=t[3]||t[2];Object.keys(s).forEach((t=>{e[t]=s[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function A(t){return"string"==typeof t.ns&&(t.ns=[t.ns]),"string"==typeof t.fallbackLng&&(t.fallbackLng=[t.fallbackLng]),"string"==typeof t.fallbackNS&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function D(){}class U extends i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;var i;if(super(),this.options=A(t),this.services={},this.logger=s,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,"function"==typeof e&&(i=e,e={}),!e.defaultNS&&!1!==e.defaultNS&&e.ns&&("string"==typeof e.ns?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const o=V();function r(t){return t?"function"==typeof t?new t:t:null}if(this.options={...o,...this.options,...A(e)},"v1"!==this.options.compatibilityAPI&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),!this.options.isClone){let e;this.modules.logger?s.init(r(this.modules.logger),this.options):s.init(null,this.options),this.modules.formatter?e=this.modules.formatter:"undefined"!=typeof Intl&&(e=I);const i=new O(this.options);this.store=new v(this.options.resources,this.options);const n=this.services;n.logger=s,n.resourceStore=this.store,n.languageUtils=i,n.pluralResolver=new C(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!e||this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format||(n.formatter=r(e),n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new j(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new F(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on("*",(function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n1?s-1:0),n=1;n{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,i||(i=D),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[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]=function(){return t.store[e](...arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=function(){return t.store[e](...arguments),t}}));const a=n(),l=()=>{const t=(t,e)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(e),i(t,e)};if(this.languages&&"v1"!==this.options.compatibilityAPI&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),a}loadResources(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s="string"==typeof t?t:this.language;if("function"==typeof t&&(e=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return e();const t=[],i=e=>{if(!e)return;if("cimode"===e)return;this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};if(s)i(s);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>i(t)))}this.options.preload&&this.options.preload.forEach((t=>i(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),e(t)}))}else e(null)}reloadResources(t,e,s){const i=n();return t||(t=this.languages),e||(e=this.options.ns),s||(s=D),this.services.backendConnector.reload(t,e,(t=>{i.resolve(),s(t)})),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&b.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1))for(let t=0;t-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}}changeLanguage(t,e){var s=this;this.isLanguageChangingTo=t;const i=n();this.emit("languageChanging",t);const o=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},r=(t,n)=>{n?(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve((function(){return s.t(...arguments)})),e&&e(t,(function(){return s.t(...arguments)}))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s="string"==typeof e?e:this.services.languageUtils.getBestMatchFromCodes(e);s&&(this.language||o(s),this.translator.language||this.translator.changeLanguage(s),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(s)),this.loadResources(s,(t=>{r(t,s)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),i}getFixedT(t,e,s){var i=this;const n=function(t,e){let o;if("object"!=typeof e){for(var r=arguments.length,a=new Array(r>2?r-2:0),l=2;l`${o.keyPrefix}${u}${t}`)):o.keyPrefix?`${o.keyPrefix}${u}${t}`:t,i.t(h,o)};return"string"==typeof t?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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=e.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(t,e)=>{const s=this.services.backendConnector.state[`${t}|${e}`];return-1===s||2===s};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!!this.hasResourceBundle(s,t)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,t)||i&&!o(n,t)))}loadNamespaces(t,e){const s=n();return this.options.ns?("string"==typeof t&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}loadLanguages(t,e){const s=n();"string"==typeof t&&(t=[t]);const i=this.options.preload||[],o=t.filter((t=>i.indexOf(t)<0));return o.length?(this.options.preload=i.concat(o),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const e=this.services&&this.services.languageUtils||new O(V());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){return new U(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},n=new U(i);void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t));return["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s&&(n.store=new v(this.store.data,i),n.services.resourceStore=n.store),n.translator=new S(n.services,i),n.translator.on("*",(function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i { if (supportedLng === lngOnly) return supportedLng; if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return; - if (supportedLng.indexOf(lngOnly) === 0) return supportedLng; + if ( + supportedLng.indexOf('-') > 0 && + lngOnly.indexOf('-') < 0 && + supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly + ) + return supportedLng; + if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng; }); }); } - // if nothing found, use fallbackLng if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0]; diff --git a/test/runtime/languageUtils.test.js b/test/runtime/languageUtils.test.js index 38a56bd6e..aceaa7383 100644 --- a/test/runtime/languageUtils.test.js +++ b/test/runtime/languageUtils.test.js @@ -316,6 +316,8 @@ describe('LanguageUtils', () => { { args: [['ru', 'en-GB']], expected: 'en' }, { args: [['de-CH']], expected: 'de-DE' }, { args: [['ru']], expected: 'en' }, + { args: [['c']], expected: 'en' }, + { args: [['e']], expected: 'en' }, { args: [[]], expected: 'en' }, ]; From da6d6544ffd55860eba1e1073c77015e0ea02208 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Fri, 8 Mar 2024 07:10:50 +0100 Subject: [PATCH 04/14] 23.10.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e37abea54..c841f043f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "i18next", - "version": "23.10.0", + "version": "23.10.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "i18next", - "version": "23.10.0", + "version": "23.10.1", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index aace77618..2e56cc6d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "i18next", - "version": "23.10.0", + "version": "23.10.1", "description": "i18next internationalization framework", "main": "./dist/cjs/i18next.js", "module": "./dist/esm/i18next.js", From 0949a2bb7633b06a8dc3fa2b8b623bd19955ad59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Fri, 8 Mar 2024 18:19:59 +0100 Subject: [PATCH 05/14] fix: log error when Intl.PluralRules error (#2155) --- i18next.js | 1 + 1 file changed, 1 insertion(+) diff --git a/i18next.js b/i18next.js index 97af1f9cc..8fa55353d 100644 --- a/i18next.js +++ b/i18next.js @@ -1200,6 +1200,7 @@ type: options.ordinal ? 'ordinal' : 'cardinal' }); } catch (err) { + this.logger.warn(err); return; } } From 3735a89d89cb9a05b1a6b8ace940fde98391afaa Mon Sep 17 00:00:00 2001 From: Felix Meziere Date: Mon, 8 Apr 2024 17:54:11 +0200 Subject: [PATCH 06/14] Fix typing performance regression (#2166) --- typescript/t.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/typescript/t.d.ts b/typescript/t.d.ts index 12ceccb6f..6b8f38e02 100644 --- a/typescript/t.d.ts +++ b/typescript/t.d.ts @@ -116,8 +116,8 @@ type ParseKeysByFallbackNs = _FallbackNamespace extend ? Keys[UnionFallbackNs] : Keys[_FallbackNamespace & string]; -type FilterKeysByContext = TOpt['context'] extends string - ? Keys extends `${infer Prefix}${_ContextSeparator}${TOpt['context']}${infer Suffix}` +type FilterKeysByContext = Context extends string + ? Keys extends `${infer Prefix}${_ContextSeparator}${Context}${infer Suffix}` ? `${Prefix}${Suffix}` : never : Keys; @@ -128,12 +128,13 @@ export type ParseKeys< KPrefix = undefined, Keys extends $Dictionary = KeysByTOptions, ActualNS extends Namespace = NsByTOptions, + const Context extends TOpt['context'] = TOpt['context'], > = $IsResourcesDefined extends true ? FilterKeysByContext< | ParseKeysByKeyPrefix], KPrefix> | ParseKeysByNamespaces | ParseKeysByFallbackNs, - TOpt + Context > : string; From 52419b7bbf4a323b377d6d9256d1c03b42a9b6cf Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Mon, 8 Apr 2024 17:55:10 +0200 Subject: [PATCH 07/14] release --- CHANGELOG.md | 4 ++++ i18next.js | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 235b2cb4c..6d86bad22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 23.11.0 + +- Fix typing performance regression [2166](https://github.com/i18next/i18next/pull/2166) + ## 23.10.1 - optimize getBestMatchFromCodes for https://github.com/i18next/i18next-browser-languageDetector/issues/281 diff --git a/i18next.js b/i18next.js index 8fa55353d..97af1f9cc 100644 --- a/i18next.js +++ b/i18next.js @@ -1200,7 +1200,6 @@ type: options.ordinal ? 'ordinal' : 'cardinal' }); } catch (err) { - this.logger.warn(err); return; } } From e8efbf02ee69798249b96a37bd195f9be20d66fc Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Mon, 8 Apr 2024 17:55:24 +0200 Subject: [PATCH 08/14] 23.11.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c841f043f..646e59cbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "i18next", - "version": "23.10.1", + "version": "23.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "i18next", - "version": "23.10.1", + "version": "23.11.0", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index 2e56cc6d6..186ecf328 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "i18next", - "version": "23.10.1", + "version": "23.11.0", "description": "i18next internationalization framework", "main": "./dist/cjs/i18next.js", "module": "./dist/esm/i18next.js", From 2c8d4932dc8b37570a6fdaae4986274118f5ec36 Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:39:14 +0200 Subject: [PATCH 09/14] types: remove const from ParseKeys Context type parameter and disable `skipLibCheck` (#2169) * chore(deps-dev): update typescript to v5.4.4 * types: remove const from `ParseKeys` `Context` type parameter and disable `skipLibCheck` --- package-lock.json | 14 +++++++------- package.json | 2 +- tsconfig.json | 19 +++++++++++++------ typescript/t.d.ts | 2 +- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 646e59cbc..0fc397592 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,7 +61,7 @@ "rimraf": "5.0.5", "rollup": "^4.3.0", "sinon": "17.0.1", - "typescript": "5.1.3", + "typescript": "5.4.4", "vitest": "1.1.0" } }, @@ -11278,9 +11278,9 @@ } }, "node_modules/typescript": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", - "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", + "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -20164,9 +20164,9 @@ } }, "typescript": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", - "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", + "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", "dev": true }, "ufo": { diff --git a/package.json b/package.json index 186ecf328..ccb2a74b6 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "rimraf": "5.0.5", "rollup": "^4.3.0", "sinon": "17.0.1", - "typescript": "5.1.3", + "typescript": "5.4.4", "vitest": "1.1.0" }, "scripts": { diff --git a/tsconfig.json b/tsconfig.json index 888054d6c..9d3a44596 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,24 @@ { "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": ["es6", "dom"], + "module": "ES6", + "target": "ES5", + "lib": ["ES6", "DOM"], "jsx": "react", - "moduleResolution": "node", + "moduleResolution": "Bundler", "forceConsistentCasingInFileNames": true, "strict": true, "noEmit": true, "baseUrl": ".", - "paths": { "i18next": ["./index.d.mts"] }, + "paths": { + "i18next": ["./index.d.mts"] + }, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "skipLibCheck": true + + /** + * setting this to `false` to throw an error when d.ts file trow an error + * @see https://github.com/i18next/i18next/issues/2168 + */ + "skipLibCheck": false } } diff --git a/typescript/t.d.ts b/typescript/t.d.ts index 6b8f38e02..6b02eea3a 100644 --- a/typescript/t.d.ts +++ b/typescript/t.d.ts @@ -128,7 +128,7 @@ export type ParseKeys< KPrefix = undefined, Keys extends $Dictionary = KeysByTOptions, ActualNS extends Namespace = NsByTOptions, - const Context extends TOpt['context'] = TOpt['context'], + Context extends TOpt['context'] = TOpt['context'], > = $IsResourcesDefined extends true ? FilterKeysByContext< | ParseKeysByKeyPrefix], KPrefix> From be7edc5a2bb9d4fc441d8f6b9331624c23794767 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Tue, 9 Apr 2024 19:40:18 +0200 Subject: [PATCH 10/14] release --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d86bad22..d9d5373d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 23.11.1 + +- types: remove const from ParseKeys Context type parameter and disable `skipLibCheck` [2169](https://github.com/i18next/i18next/pull/2169) + ## 23.11.0 - Fix typing performance regression [2166](https://github.com/i18next/i18next/pull/2166) From 2a2a6824ad5da5619bae9309bdbf05e0952e1d06 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Tue, 9 Apr 2024 19:40:34 +0200 Subject: [PATCH 11/14] 23.11.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fc397592..f297631d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "i18next", - "version": "23.11.0", + "version": "23.11.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "i18next", - "version": "23.11.0", + "version": "23.11.1", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index ccb2a74b6..5040ada7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "i18next", - "version": "23.11.0", + "version": "23.11.1", "description": "i18next internationalization framework", "main": "./dist/cjs/i18next.js", "module": "./dist/esm/i18next.js", From 677755c60039bf62cff444ae5e70c974b4ee7818 Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:28:24 +0200 Subject: [PATCH 12/14] test(types): add context + enum scenario (#2173) --- test/typescript/custom-types/t.test.ts | 53 ++++++++++++++++++++++---- tsconfig.json | 2 +- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/test/typescript/custom-types/t.test.ts b/test/typescript/custom-types/t.test.ts index 502f7405e..0c71a36a3 100644 --- a/test/typescript/custom-types/t.test.ts +++ b/test/typescript/custom-types/t.test.ts @@ -140,17 +140,56 @@ describe('t', () => { expectTypeOf(t('place', { ordinal: true, count: 4 })).toBeString(); }); - it('should work with context', () => { + describe('context', () => { const t = (() => '') as TFunction<'ctx'>; - expectTypeOf(t('dessert', { context: 'cake' })).toEqualTypeOf<'a nice cake'>(); + it('should work with basic usage', () => { + expectTypeOf(t('dessert', { context: 'cake' })).toEqualTypeOf<'a nice cake'>(); - // context + plural - expectTypeOf(t('dessert', { context: 'muffin', count: 3 })).toMatchTypeOf(); + // context + plural + expectTypeOf(t('dessert', { context: 'muffin', count: 3 })).toMatchTypeOf(); - // @ts-expect-error - // valid key with invalid context - assertType(t('foo', { context: 'cake' })); + // @ts-expect-error + // valid key with invalid context + assertType(t('foo', { context: 'cake' })); + }); + + it('should work with enum as a context value', () => { + enum Dessert { + CAKE = 'cake', + MUFFIN = 'muffin', + } + + const ctx = Dessert.CAKE; + + expectTypeOf(t('dessert', { context: ctx })).toMatchTypeOf(); + + enum DessertMissingValue { + COOKIE = 'cookie', + CAKE = 'cake', + MUFFIN = 'muffin', + ANOTHER = 'another', + } + + const ctxMissingValue = DessertMissingValue.ANOTHER; + + // @ts-expect-error Dessert.ANOTHER is not mapped so it must give a type error + expectTypeOf(t('dessert', { context: ctxMissingValue })).toMatchTypeOf(); + }); + + it('should work with string union as a context value', () => { + expectTypeOf( + t('dessert', { context: 'muffin' as 'muffin' | 'cake' }), + ).toMatchTypeOf(); + }); + + // @see https://github.com/i18next/i18next/issues/2172 + // it('should trow error with string union with missing context value', () => { + // expectTypeOf( + // // @ts-expect-error + // t('dessert', { context: 'muffin' as 'muffin' | 'cake' | 'pippo' }), + // ).toMatchTypeOf(); + // }); }); it('should work with false plural usage', () => { diff --git a/tsconfig.json b/tsconfig.json index 9d3a44596..ad1d02594 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "allowSyntheticDefaultImports": true, /** - * setting this to `false` to throw an error when d.ts file trow an error + * setting this to `false` to throw an error when d.ts file have invalid code * @see https://github.com/i18next/i18next/issues/2168 */ "skipLibCheck": false From ba49a6f1d80de7d3961c730411df7b3f1ba9c20d Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Sun, 14 Apr 2024 15:02:10 +0200 Subject: [PATCH 13/14] allow defaultValue in nested translation #2174 --- CHANGELOG.md | 4 ++++ i18next.js | 2 +- i18next.min.js | 2 +- src/Interpolator.js | 3 ++- .../translator.translate.combination.test.js | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9d5373d8..e4c4ba157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 23.11.2 + +- allow defaultValue in nested translation [2174](https://github.com/i18next/i18next/issues/2174) + ## 23.11.1 - types: remove const from ParseKeys Context type parameter and disable `skipLibCheck` [2169](https://github.com/i18next/i18next/pull/2169) diff --git a/i18next.js b/i18next.js index 97af1f9cc..77cc764e0 100644 --- a/i18next.js +++ b/i18next.js @@ -1421,7 +1421,7 @@ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e); return `${key}${sep}${optionsString}`; } - delete clonedOptions.defaultValue; + if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue; return key; } while (match = this.nestingRegexp.exec(str)) { diff --git a/i18next.min.js b/i18next.min.js index d6ce5f016..4c068dfbf 100644 --- a/i18next.min.js +++ b/i18next.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).i18next=e()}(this,(function(){"use strict";const t={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console&&console[t]&&console[t].apply(console,e)}};class e{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.init(t,e)}init(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=s.prefix||"i18next:",this.logger=e||t,this.options=s,this.debug=s.debug}log(){for(var t=arguments.length,e=new Array(t),s=0;s{this.observers[t]||(this.observers[t]=new Map);const s=this.observers[t].get(e)||0;this.observers[t].set(e,s+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i{let[e,i]=t;for(let t=0;t{let[i,n]=e;for(let e=0;e{t=s,e=i}));return s.resolve=t,s.reject=e,s}function o(t){return null==t?"":""+t}const r=/###/g;function a(t,e,s){function i(t){return t&&t.indexOf("###")>-1?t.replace(r,"."):t}function n(){return!t||"string"==typeof t}const o="string"!=typeof e?e:e.split(".");let a=0;for(;a":">",'"':""","'":"'","/":"/"};function g(t){return"string"==typeof t?t.replace(/[&<>"'\/]/g,(t=>c[t])):t}const d=[" ",",","?","!",";"],f=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const s=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,s),this.regExpQueue.push(t),s}}(20);function m(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!t)return;if(t[e])return t[e];const i=e.split(s);let n=t;for(let t=0;t-1&&r0?t.replace("_","-"):t}class v extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.indexOf(".")>-1?r=t.split("."):(r=[t,e],s&&(Array.isArray(s)?r.push(...s):"string"==typeof s&&n?r.push(...s.split(n)):r.push(s)));const a=u(this.data,r);return!a&&!e&&!s&&t.indexOf(".")>-1&&(t=r[0],e=r[1],s=r.slice(2).join(".")),a||!o||"string"!=typeof s?a:m(this.data&&this.data[t]&&this.data[t][e],s,n)}addResource(t,e,s,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];s&&(r=r.concat(o?s.split(o):s)),t.indexOf(".")>-1&&(r=t.split("."),i=e,e=r[1]),this.addNamespaces(e),l(this.data,r,i),n.silent||this.emit("added",t,e,s,i)}addResources(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(t,e,i,s[i],{silent:!0});i.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1,skipCopy:!1},r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),i=s,s=e,e=r[1]),this.addNamespaces(e);let a=u(this.data,r)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?h(a,s,n):a={...a,...s},l(this.data,r,a),o.silent||this.emit("added",t,e,s)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),"v1"===this.options.compatibilityAPI?{...this.getResource(t,e)}:this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var b={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,s,i,n){return t.forEach((t=>{this.processors[t]&&(e=this.processors[t].process(e,s,i,n))})),e}};const x={};class S extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;super(),i=t,n=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(n[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=s.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==t)return!1;const s=this.resolve(t,e);return s&&void 0!==s.res}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const i=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||function(t,e,s){e=e||"",s=s||"";const i=d.filter((t=>e.indexOf(t)<0&&s.indexOf(t)<0));if(0===i.length)return!0;const n=f.getRegExp(`(${i.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(s);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o}(t,s,i));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:n};const o=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(i)}return"string"==typeof n&&(n=[n]),{key:t,namespaces:n}}translate(t,e,s){if("object"!=typeof e&&this.options.overloadTranslationOptionHandler&&(e=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof e&&(e={...e}),e||(e={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);const i=void 0!==e.returnDetails?e.returnDetails:this.options.returnDetails,n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator,{key:o,namespaces:r}=this.extractFromKey(t[t.length-1],e),a=r[r.length-1],l=e.lng||this.language,u=e.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(u){const t=e.nsSeparator||this.options.nsSeparator;return i?{res:`${a}${t}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:`${a}${t}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:o}const h=this.resolve(t,e);let p=h&&h.res;const c=h&&h.usedKey||o,g=h&&h.exactUsedKey||o,d=Object.prototype.toString.apply(p),f=void 0!==e.joinArrays?e.joinArrays:this.options.joinArrays,m=!this.i18nFormat||this.i18nFormat.handleAsObject;if(m&&p&&("string"!=typeof p&&"boolean"!=typeof p&&"number"!=typeof p)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(d)<0&&("string"!=typeof f||"[object Array]"!==d)){if(!e.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(c,p,{...e,ns:r}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=t,h.usedParams=this.getUsedParamsDetails(e),h):t}if(n){const t="[object Array]"===d,s=t?[]:{},i=t?g:c;for(const t in p)if(Object.prototype.hasOwnProperty.call(p,t)){const o=`${i}${n}${t}`;s[t]=this.translate(o,{...e,joinArrays:!1,ns:r}),s[t]===o&&(s[t]=p[t])}p=s}}else if(m&&"string"==typeof f&&"[object Array]"===d)p=p.join(f),p&&(p=this.extendTranslation(p,t,e,s));else{let i=!1,r=!1;const u=void 0!==e.count&&"string"!=typeof e.count,c=S.hasDefaultValue(e),g=u?this.pluralResolver.getSuffix(l,e.count,e):"",d=e.ordinal&&u?this.pluralResolver.getSuffix(l,e.count,{ordinal:!1}):"",f=u&&!e.ordinal&&0===e.count&&this.pluralResolver.shouldUseIntlApi(),m=f&&e[`defaultValue${this.options.pluralSeparator}zero`]||e[`defaultValue${g}`]||e[`defaultValue${d}`]||e.defaultValue;!this.isValidLookup(p)&&c&&(i=!0,p=m),this.isValidLookup(p)||(r=!0,p=o);const y=(e.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:p,v=c&&m!==p&&this.options.updateMissing;if(r||i||v){if(this.logger.log(v?"updateKey":"missingKey",l,a,o,v?m:p),n){const t=this.resolve(o,{...e,keySeparator:!1});t&&t.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 t=[];const s=this.languageUtils.getFallbackCodes(this.options.fallbackLng,e.lng||this.language);if("fallback"===this.options.saveMissingTo&&s&&s[0])for(let e=0;e{const n=c&&i!==p?i:y;this.options.missingKeyHandler?this.options.missingKeyHandler(t,a,s,n,v,e):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(t,a,s,n,v,e),this.emit("missingKey",t,a,s,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&u?t.forEach((t=>{const s=this.pluralResolver.getSuffixes(t,e);f&&e[`defaultValue${this.options.pluralSeparator}zero`]&&s.indexOf(`${this.options.pluralSeparator}zero`)<0&&s.push(`${this.options.pluralSeparator}zero`),s.forEach((s=>{i([t],o+s,e[`defaultValue${s}`]||m)}))})):i(t,o,m))}p=this.extendTranslation(p,t,e,h,s),r&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${a}:${o}`),(r||i)&&this.options.parseMissingKeyHandler&&(p="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${o}`:o,i?p:void 0):this.options.parseMissingKeyHandler(p))}return i?(h.res=p,h.usedParams=this.getUsedParamsDetails(e),h):p}extendTranslation(t,e,s,i,n){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const r="string"==typeof t&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(r){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let l=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,s.lng||this.language,s),r){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&i&&i.res&&(s.lng=i.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,(function(){for(var t=arguments.length,i=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.forEach((t=>{if(this.isValidLookup(e))return;const a=this.extractFromKey(t,r),l=a.key;s=l;let u=a.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const h=void 0!==r.count&&"string"!=typeof r.count,p=h&&!r.ordinal&&0===r.count&&this.pluralResolver.shouldUseIntlApi(),c=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach((t=>{this.isValidLookup(e)||(o=t,!x[`${g[0]}-${t}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(x[`${g[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach((s=>{if(this.isValidLookup(e))return;n=s;const o=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(o,l,s,t,r);else{let t;h&&(t=this.pluralResolver.getSuffix(s,r.count,r));const e=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(o.push(l+t),r.ordinal&&0===t.indexOf(i)&&o.push(l+t.replace(i,this.options.pluralSeparator)),p&&o.push(l+e)),c){const s=`${l}${this.options.contextSeparator}${r.context}`;o.push(s),h&&(o.push(s+t),r.ordinal&&0===t.indexOf(i)&&o.push(s+t.replace(i,this.options.pluralSeparator)),p&&o.push(s+e))}}let a;for(;a=o.pop();)this.isValidLookup(e)||(i=a,e=this.getResource(s,t,a,r))})))}))})),{res:e,usedKey:s,exactUsedKey:i,usedLng:n,usedNS:o}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,e,s,i):this.resourceStore.getResource(t,e,s,i)}getUsedParamsDetails(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&"string"!=typeof t.replace;let i=s?t.replace:t;if(s&&void 0!==t.count&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const t of e)delete i[t]}return i}static hasDefaultValue(t){const e="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e===s.substring(0,12)&&void 0!==t[s])return!0;return!1}}function k(t){return t.charAt(0).toUpperCase()+t.slice(1)}class O{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=s.create("languageUtils")}getScriptPartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if("string"==typeof t&&t.indexOf("-")>-1){const e=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map((t=>t.toLowerCase())):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase())),e.indexOf(s[2].toLowerCase())>-1&&(s[2]=k(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const s=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(s)||(e=s)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),"string"==typeof t&&(t=[t]),"[object Array]"===Object.prototype.toString.apply(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes(e||this.options.fallbackLng||[],t),i=[],n=t=>{t&&(this.isSupportedCode(t)?i.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return"string"==typeof t&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):"string"==typeof t&&n(this.formatLanguageCode(t)),s.forEach((t=>{i.indexOf(t)<0&&n(this.formatLanguageCode(t))})),i}}let L=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],w={1:function(t){return Number(t>1)},2:function(t){return Number(1!=t)},3:function(t){return 0},4:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},5:function(t){return Number(0==t?0:1==t?1:2==t?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5)},6:function(t){return Number(1==t?0:t>=2&&t<=4?1:2)},7:function(t){return Number(1==t?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},8:function(t){return Number(1==t?0:2==t?1:8!=t&&11!=t?2:3)},9:function(t){return Number(t>=2)},10:function(t){return Number(1==t?0:2==t?1:t<7?2:t<11?3:4)},11:function(t){return Number(1==t||11==t?0:2==t||12==t?1:t>2&&t<20?2:3)},12:function(t){return Number(t%10!=1||t%100==11)},13:function(t){return Number(0!==t)},14:function(t){return Number(1==t?0:2==t?1:3==t?2:3)},15:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2)},16:function(t){return Number(t%10==1&&t%100!=11?0:0!==t?1:2)},17:function(t){return Number(1==t||t%10==1&&t%100!=11?0:1)},18:function(t){return Number(0==t?0:1==t?1:2)},19:function(t){return Number(1==t?0:0==t||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3)},20:function(t){return Number(1==t?0:0==t||t%100>0&&t%100<20?1:2)},21:function(t){return Number(t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0)},22:function(t){return Number(1==t?0:2==t?1:(t<0||t>10)&&t%10==0?2:3)}};const N=["v1","v2","v3"],$=["v4"],R={zero:0,one:1,two:2,few:3,many:4,other:5};class C{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=t,this.options=e,this.logger=s.create("pluralResolver"),this.options.compatibilityJSON&&!$.includes(this.options.compatibilityJSON)||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=function(){const t={};return L.forEach((e=>{e.lngs.forEach((s=>{t[s]={numbers:e.nr,plurals:w[e.fc]}}))})),t}()}addRule(t,e){this.rules[t]=e}getRule(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(y("dev"===t?"en":t),{type:e.ordinal?"ordinal":"cardinal"})}catch(t){return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(t,s).map((t=>`${e}${t}`))}getSuffixes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(((t,e)=>R[t]-R[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):s.numbers.map((s=>this.getSuffix(t,s,e))):[]}getSuffix(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(e)}`:this.getSuffixRetroCompatible(i,e):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,e){const s=t.noAbs?t.plurals(e):t.plurals(Math.abs(e));let i=t.numbers[s];this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]&&(2===i?i="plural":1===i&&(i=""));const n=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?`_plural_${i.toString()}`:n():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]?n():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!N.includes(this.options.compatibilityJSON)}}function P(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=function(t,e,s){const i=u(t,s);return void 0!==i?i:u(e,s)}(t,e,s);return!o&&n&&"string"==typeof s&&(o=m(t,s,i),void 0===o&&(o=m(e,s,i))),o}class j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(t=>t),this.init(t)}init(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const e=t.interpolation;this.escape=void 0!==e.escape?e.escape:g,this.escapeValue=void 0===e.escapeValue||e.escapeValue,this.useRawValueToEscape=void 0!==e.useRawValueToEscape&&e.useRawValueToEscape,this.prefix=e.prefix?p(e.prefix):e.prefixEscaped||"{{",this.suffix=e.suffix?p(e.suffix):e.suffixEscaped||"}}",this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||",",this.unescapePrefix=e.unescapeSuffix?"":e.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":e.unescapeSuffix||"",this.nestingPrefix=e.nestingPrefix?p(e.nestingPrefix):e.nestingPrefixEscaped||p("$t("),this.nestingSuffix=e.nestingSuffix?p(e.nestingSuffix):e.nestingSuffixEscaped||p(")"),this.nestingOptionsSeparator=e.nestingOptionsSeparator?e.nestingOptionsSeparator:e.nestingOptionsSeparator||",",this.maxReplaces=e.maxReplaces?e.maxReplaces:1e3,this.alwaysFormat=void 0!==e.alwaysFormat&&e.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t&&t.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,e,s,i){let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(t){return t.replace(/\$/g,"$$$$")}const h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=P(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,s,{...i,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format(P(e,l,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,s,{...i,...e,interpolationkey:o})};this.resetRegExp();const p=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,c=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>u(t)},{regex:this.regexp,safeValue:t=>this.escapeValue?u(this.escape(t)):u(t)}].forEach((e=>{for(a=0;n=e.regex.exec(t);){const s=n[1].trim();if(r=h(s),void 0===r)if("function"==typeof p){const e=p(t,n,i);r="string"==typeof e?e:""}else if(i&&Object.prototype.hasOwnProperty.call(i,s))r="";else{if(c){r=n[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),r=""}else"string"==typeof r||this.useRawValueToEscape||(r=o(r));const l=e.safeValue(r);if(t=t.replace(n[0],l),c?(e.regex.lastIndex+=r.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),t}nest(t,e){let s,i,n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(t,e){const s=this.nestingOptionsSeparator;if(t.indexOf(s)<0)return t;const i=t.split(new RegExp(`${s}[ ]*{`));let o=`{${i[1]}`;t=i[0],o=this.interpolate(o,n);const r=o.match(/'/g),a=o.match(/"/g);(r&&r.length%2==0&&!a||a.length%2!=0)&&(o=o.replace(/'/g,'"'));try{n=JSON.parse(o),e&&(n={...e,...n})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${s}${o}`}return delete n.defaultValue,t}for(;s=this.nestingRegexp.exec(t);){let l=[];n={...r},n=n.replace&&"string"!=typeof n.replace?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;let u=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){const t=s[1].split(this.formatSeparator).map((t=>t.trim()));s[1]=t.shift(),l=t,u=!0}if(i=e(a.call(this,s[1].trim(),n),n),i&&s[0]===t&&"string"!=typeof i)return i;"string"!=typeof i&&(i=o(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=l.reduce(((t,e)=>this.format(t,e,r.lng,{...r,interpolationkey:s[1].trim()})),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}function E(t){const e={};return function(s,i,n){const o=i+JSON.stringify(n);let r=e[o];return r||(r=t(y(i),n),e[o]=r),r(s)}}class I{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("formatter"),this.options=t,this.formats={number:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e});return t=>s.format(t)})),currency:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>s.format(t)})),datetime:E(((t,e)=>{const s=new Intl.DateTimeFormat(t,{...e});return t=>s.format(t)})),relativetime:E(((t,e)=>{const s=new Intl.RelativeTimeFormat(t,{...e});return t=>s.format(t,e.range||"day")})),list:E(((t,e)=>{const s=new Intl.ListFormat(t,{...e});return t=>s.format(t)}))},this.init(t)}init(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||","}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=E(e)}format(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.split(this.formatSeparator).reduce(((t,e)=>{const{formatName:n,formatOptions:o}=function(t){let e=t.toLowerCase().trim();const s={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const n=i[1].substring(0,i[1].length-1);"currency"===e&&n.indexOf(":")<0?s.currency||(s.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?s.range||(s.range=n.trim()):n.split(";").forEach((t=>{if(!t)return;const[e,...i]=t.split(":"),n=i.join(":").trim().replace(/^'+|'+$/g,"");s[e.trim()]||(s[e.trim()]=n),"false"===n&&(s[e.trim()]=!1),"true"===n&&(s[e.trim()]=!0),isNaN(n)||(s[e.trim()]=parseInt(n,10))}))}return{formatName:e,formatOptions:s}}(e);if(this.formats[n]){let e=t;try{const r=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},a=r.locale||r.lng||i.locale||i.lng||s;e=this.formats[n](t,a,{...o,...i,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class F extends i{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=n,this.logger=s.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(i,n.backend,n)}queueLoad(t,e,s,i){const n={},o={},r={},a={};return t.forEach((t=>{let i=!0;e.forEach((e=>{const r=`${t}|${e}`;!s.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,i=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),i||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,s){const i=t.split("|"),n=i[0],o=i[1];e&&this.emit("failedLoading",n,o,e),s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2;const r={};this.queue.forEach((s=>{!function(t,e,s,i){const{obj:n,k:o}=a(t,e,Object);n[o]=n[o]||[],i&&(n[o]=n[o].concat(s)),i||n[o].push(s)}(s.loaded,[n],o),function(t,e){void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)}(s,t),e&&s.errors.push(e),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((t=>{r[t]||(r[t]={});const e=s.loaded[t];e.length&&e.forEach((e=>{void 0===r[t][e]&&(r[t][e]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((t=>!t.done))}read(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:s,tried:i,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&i{this.read.call(this,t,e,s,i+1,2*n,o)}),n):o(r,a)},a=this.backend[s].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const s=a(t,e);s&&"function"==typeof s.then?s.then((t=>r(null,t))).catch(r):r(null,s)}catch(t){r(t)}}prepareLoading(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof t&&(t=this.languageUtils.toResolveHierarchy(t)),"string"==typeof e&&(e=[e]);const n=this.queueLoad(t,e,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,s){this.prepareLoading(t,e,{},s)}reload(t,e,s){this.prepareLoading(t,e,{reload:!0},s)}loadOne(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=t.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${e}loading namespace ${n} for language ${i} failed`,s),!s&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${i}`,o),this.loaded(t,s,o)}))}saveMissing(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(e))this.logger.warn(`did not save key "${s}" as the namespace "${e}" 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!!!");else if(null!=s&&""!==s){if(this.backend&&this.backend.create){const a={...o,isUpdate:n},l=this.backend.create.bind(this.backend);if(l.length<6)try{let n;n=5===l.length?l(t,e,s,i,a):l(t,e,s,i),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else l(t,e,s,i,r,a)}t&&t[0]&&this.store.addResource(t[0],e,s,i)}}}function V(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let e={};if("object"==typeof t[1]&&(e=t[1]),"string"==typeof t[1]&&(e.defaultValue=t[1]),"string"==typeof t[2]&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const s=t[3]||t[2];Object.keys(s).forEach((t=>{e[t]=s[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function A(t){return"string"==typeof t.ns&&(t.ns=[t.ns]),"string"==typeof t.fallbackLng&&(t.fallbackLng=[t.fallbackLng]),"string"==typeof t.fallbackNS&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function D(){}class U extends i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;var i;if(super(),this.options=A(t),this.services={},this.logger=s,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,"function"==typeof e&&(i=e,e={}),!e.defaultNS&&!1!==e.defaultNS&&e.ns&&("string"==typeof e.ns?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const o=V();function r(t){return t?"function"==typeof t?new t:t:null}if(this.options={...o,...this.options,...A(e)},"v1"!==this.options.compatibilityAPI&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),!this.options.isClone){let e;this.modules.logger?s.init(r(this.modules.logger),this.options):s.init(null,this.options),this.modules.formatter?e=this.modules.formatter:"undefined"!=typeof Intl&&(e=I);const i=new O(this.options);this.store=new v(this.options.resources,this.options);const n=this.services;n.logger=s,n.resourceStore=this.store,n.languageUtils=i,n.pluralResolver=new C(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!e||this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format||(n.formatter=r(e),n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new j(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new F(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on("*",(function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n1?s-1:0),n=1;n{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,i||(i=D),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[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]=function(){return t.store[e](...arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=function(){return t.store[e](...arguments),t}}));const a=n(),l=()=>{const t=(t,e)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(e),i(t,e)};if(this.languages&&"v1"!==this.options.compatibilityAPI&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),a}loadResources(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s="string"==typeof t?t:this.language;if("function"==typeof t&&(e=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return e();const t=[],i=e=>{if(!e)return;if("cimode"===e)return;this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};if(s)i(s);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>i(t)))}this.options.preload&&this.options.preload.forEach((t=>i(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),e(t)}))}else e(null)}reloadResources(t,e,s){const i=n();return t||(t=this.languages),e||(e=this.options.ns),s||(s=D),this.services.backendConnector.reload(t,e,(t=>{i.resolve(),s(t)})),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&b.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1))for(let t=0;t-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}}changeLanguage(t,e){var s=this;this.isLanguageChangingTo=t;const i=n();this.emit("languageChanging",t);const o=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},r=(t,n)=>{n?(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve((function(){return s.t(...arguments)})),e&&e(t,(function(){return s.t(...arguments)}))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s="string"==typeof e?e:this.services.languageUtils.getBestMatchFromCodes(e);s&&(this.language||o(s),this.translator.language||this.translator.changeLanguage(s),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(s)),this.loadResources(s,(t=>{r(t,s)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),i}getFixedT(t,e,s){var i=this;const n=function(t,e){let o;if("object"!=typeof e){for(var r=arguments.length,a=new Array(r>2?r-2:0),l=2;l`${o.keyPrefix}${u}${t}`)):o.keyPrefix?`${o.keyPrefix}${u}${t}`:t,i.t(h,o)};return"string"==typeof t?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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=e.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(t,e)=>{const s=this.services.backendConnector.state[`${t}|${e}`];return-1===s||2===s};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!!this.hasResourceBundle(s,t)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,t)||i&&!o(n,t)))}loadNamespaces(t,e){const s=n();return this.options.ns?("string"==typeof t&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}loadLanguages(t,e){const s=n();"string"==typeof t&&(t=[t]);const i=this.options.preload||[],o=t.filter((t=>i.indexOf(t)<0));return o.length?(this.options.preload=i.concat(o),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const e=this.services&&this.services.languageUtils||new O(V());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){return new U(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},n=new U(i);void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t));return["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s&&(n.store=new v(this.store.data,i),n.services.resourceStore=n.store),n.translator=new S(n.services,i),n.translator.on("*",(function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{};this.init(t,e)}init(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=s.prefix||"i18next:",this.logger=e||t,this.options=s,this.debug=s.debug}log(){for(var t=arguments.length,e=new Array(t),s=0;s{this.observers[t]||(this.observers[t]=new Map);const s=this.observers[t].get(e)||0;this.observers[t].set(e,s+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i{let[e,i]=t;for(let t=0;t{let[i,n]=e;for(let e=0;e{t=s,e=i}));return s.resolve=t,s.reject=e,s}function o(t){return null==t?"":""+t}const r=/###/g;function a(t,e,s){function i(t){return t&&t.indexOf("###")>-1?t.replace(r,"."):t}function n(){return!t||"string"==typeof t}const o="string"!=typeof e?e:e.split(".");let a=0;for(;a":">",'"':""","'":"'","/":"/"};function g(t){return"string"==typeof t?t.replace(/[&<>"'\/]/g,(t=>c[t])):t}const d=[" ",",","?","!",";"],f=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const s=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,s),this.regExpQueue.push(t),s}}(20);function m(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!t)return;if(t[e])return t[e];const i=e.split(s);let n=t;for(let t=0;t-1&&r0?t.replace("_","-"):t}class v extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let r;t.indexOf(".")>-1?r=t.split("."):(r=[t,e],s&&(Array.isArray(s)?r.push(...s):"string"==typeof s&&n?r.push(...s.split(n)):r.push(s)));const a=u(this.data,r);return!a&&!e&&!s&&t.indexOf(".")>-1&&(t=r[0],e=r[1],s=r.slice(2).join(".")),a||!o||"string"!=typeof s?a:m(this.data&&this.data[t]&&this.data[t][e],s,n)}addResource(t,e,s,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];s&&(r=r.concat(o?s.split(o):s)),t.indexOf(".")>-1&&(r=t.split("."),i=e,e=r[1]),this.addNamespaces(e),l(this.data,r,i),n.silent||this.emit("added",t,e,s,i)}addResources(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(t,e,i,s[i],{silent:!0});i.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1,skipCopy:!1},r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),i=s,s=e,e=r[1]),this.addNamespaces(e);let a=u(this.data,r)||{};o.skipCopy||(s=JSON.parse(JSON.stringify(s))),i?h(a,s,n):a={...a,...s},l(this.data,r,a),o.silent||this.emit("added",t,e,s)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),"v1"===this.options.compatibilityAPI?{...this.getResource(t,e)}:this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var b={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,s,i,n){return t.forEach((t=>{this.processors[t]&&(e=this.processors[t].process(e,s,i,n))})),e}};const x={};class S extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;super(),i=t,n=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(n[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=s.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==t)return!1;const s=this.resolve(t,e);return s&&void 0!==s.res}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const i=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||function(t,e,s){e=e||"",s=s||"";const i=d.filter((t=>e.indexOf(t)<0&&s.indexOf(t)<0));if(0===i.length)return!0;const n=f.getRegExp(`(${i.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(s);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o}(t,s,i));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:n};const o=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(i)}return"string"==typeof n&&(n=[n]),{key:t,namespaces:n}}translate(t,e,s){if("object"!=typeof e&&this.options.overloadTranslationOptionHandler&&(e=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof e&&(e={...e}),e||(e={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);const i=void 0!==e.returnDetails?e.returnDetails:this.options.returnDetails,n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator,{key:o,namespaces:r}=this.extractFromKey(t[t.length-1],e),a=r[r.length-1],l=e.lng||this.language,u=e.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(u){const t=e.nsSeparator||this.options.nsSeparator;return i?{res:`${a}${t}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:`${a}${t}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a,usedParams:this.getUsedParamsDetails(e)}:o}const h=this.resolve(t,e);let p=h&&h.res;const c=h&&h.usedKey||o,g=h&&h.exactUsedKey||o,d=Object.prototype.toString.apply(p),f=void 0!==e.joinArrays?e.joinArrays:this.options.joinArrays,m=!this.i18nFormat||this.i18nFormat.handleAsObject;if(m&&p&&("string"!=typeof p&&"boolean"!=typeof p&&"number"!=typeof p)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(d)<0&&("string"!=typeof f||"[object Array]"!==d)){if(!e.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(c,p,{...e,ns:r}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=t,h.usedParams=this.getUsedParamsDetails(e),h):t}if(n){const t="[object Array]"===d,s=t?[]:{},i=t?g:c;for(const t in p)if(Object.prototype.hasOwnProperty.call(p,t)){const o=`${i}${n}${t}`;s[t]=this.translate(o,{...e,joinArrays:!1,ns:r}),s[t]===o&&(s[t]=p[t])}p=s}}else if(m&&"string"==typeof f&&"[object Array]"===d)p=p.join(f),p&&(p=this.extendTranslation(p,t,e,s));else{let i=!1,r=!1;const u=void 0!==e.count&&"string"!=typeof e.count,c=S.hasDefaultValue(e),g=u?this.pluralResolver.getSuffix(l,e.count,e):"",d=e.ordinal&&u?this.pluralResolver.getSuffix(l,e.count,{ordinal:!1}):"",f=u&&!e.ordinal&&0===e.count&&this.pluralResolver.shouldUseIntlApi(),m=f&&e[`defaultValue${this.options.pluralSeparator}zero`]||e[`defaultValue${g}`]||e[`defaultValue${d}`]||e.defaultValue;!this.isValidLookup(p)&&c&&(i=!0,p=m),this.isValidLookup(p)||(r=!0,p=o);const y=(e.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:p,v=c&&m!==p&&this.options.updateMissing;if(r||i||v){if(this.logger.log(v?"updateKey":"missingKey",l,a,o,v?m:p),n){const t=this.resolve(o,{...e,keySeparator:!1});t&&t.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 t=[];const s=this.languageUtils.getFallbackCodes(this.options.fallbackLng,e.lng||this.language);if("fallback"===this.options.saveMissingTo&&s&&s[0])for(let e=0;e{const n=c&&i!==p?i:y;this.options.missingKeyHandler?this.options.missingKeyHandler(t,a,s,n,v,e):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(t,a,s,n,v,e),this.emit("missingKey",t,a,s,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&u?t.forEach((t=>{const s=this.pluralResolver.getSuffixes(t,e);f&&e[`defaultValue${this.options.pluralSeparator}zero`]&&s.indexOf(`${this.options.pluralSeparator}zero`)<0&&s.push(`${this.options.pluralSeparator}zero`),s.forEach((s=>{i([t],o+s,e[`defaultValue${s}`]||m)}))})):i(t,o,m))}p=this.extendTranslation(p,t,e,h,s),r&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${a}:${o}`),(r||i)&&this.options.parseMissingKeyHandler&&(p="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${o}`:o,i?p:void 0):this.options.parseMissingKeyHandler(p))}return i?(h.res=p,h.usedParams=this.getUsedParamsDetails(e),h):p}extendTranslation(t,e,s,i,n){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const r="string"==typeof t&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(r){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let l=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,s.lng||this.language,s),r){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&i&&i.res&&(s.lng=i.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,(function(){for(var t=arguments.length,i=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.forEach((t=>{if(this.isValidLookup(e))return;const a=this.extractFromKey(t,r),l=a.key;s=l;let u=a.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const h=void 0!==r.count&&"string"!=typeof r.count,p=h&&!r.ordinal&&0===r.count&&this.pluralResolver.shouldUseIntlApi(),c=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach((t=>{this.isValidLookup(e)||(o=t,!x[`${g[0]}-${t}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(x[`${g[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach((s=>{if(this.isValidLookup(e))return;n=s;const o=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(o,l,s,t,r);else{let t;h&&(t=this.pluralResolver.getSuffix(s,r.count,r));const e=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(o.push(l+t),r.ordinal&&0===t.indexOf(i)&&o.push(l+t.replace(i,this.options.pluralSeparator)),p&&o.push(l+e)),c){const s=`${l}${this.options.contextSeparator}${r.context}`;o.push(s),h&&(o.push(s+t),r.ordinal&&0===t.indexOf(i)&&o.push(s+t.replace(i,this.options.pluralSeparator)),p&&o.push(s+e))}}let a;for(;a=o.pop();)this.isValidLookup(e)||(i=a,e=this.getResource(s,t,a,r))})))}))})),{res:e,usedKey:s,exactUsedKey:i,usedLng:n,usedNS:o}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,e,s,i):this.resourceStore.getResource(t,e,s,i)}getUsedParamsDetails(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&"string"!=typeof t.replace;let i=s?t.replace:t;if(s&&void 0!==t.count&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!s){i={...i};for(const t of e)delete i[t]}return i}static hasDefaultValue(t){const e="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e===s.substring(0,12)&&void 0!==t[s])return!0;return!1}}function k(t){return t.charAt(0).toUpperCase()+t.slice(1)}class O{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=s.create("languageUtils")}getScriptPartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=y(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if("string"==typeof t&&t.indexOf("-")>-1){const e=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map((t=>t.toLowerCase())):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=k(s[1].toLowerCase())),e.indexOf(s[2].toLowerCase())>-1&&(s[2]=k(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const s=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(s)||(e=s)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),"string"==typeof t&&(t=[t]),"[object Array]"===Object.prototype.toString.apply(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes(e||this.options.fallbackLng||[],t),i=[],n=t=>{t&&(this.isSupportedCode(t)?i.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return"string"==typeof t&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):"string"==typeof t&&n(this.formatLanguageCode(t)),s.forEach((t=>{i.indexOf(t)<0&&n(this.formatLanguageCode(t))})),i}}let L=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],w={1:function(t){return Number(t>1)},2:function(t){return Number(1!=t)},3:function(t){return 0},4:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},5:function(t){return Number(0==t?0:1==t?1:2==t?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5)},6:function(t){return Number(1==t?0:t>=2&&t<=4?1:2)},7:function(t){return Number(1==t?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},8:function(t){return Number(1==t?0:2==t?1:8!=t&&11!=t?2:3)},9:function(t){return Number(t>=2)},10:function(t){return Number(1==t?0:2==t?1:t<7?2:t<11?3:4)},11:function(t){return Number(1==t||11==t?0:2==t||12==t?1:t>2&&t<20?2:3)},12:function(t){return Number(t%10!=1||t%100==11)},13:function(t){return Number(0!==t)},14:function(t){return Number(1==t?0:2==t?1:3==t?2:3)},15:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2)},16:function(t){return Number(t%10==1&&t%100!=11?0:0!==t?1:2)},17:function(t){return Number(1==t||t%10==1&&t%100!=11?0:1)},18:function(t){return Number(0==t?0:1==t?1:2)},19:function(t){return Number(1==t?0:0==t||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3)},20:function(t){return Number(1==t?0:0==t||t%100>0&&t%100<20?1:2)},21:function(t){return Number(t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0)},22:function(t){return Number(1==t?0:2==t?1:(t<0||t>10)&&t%10==0?2:3)}};const N=["v1","v2","v3"],$=["v4"],R={zero:0,one:1,two:2,few:3,many:4,other:5};class C{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=t,this.options=e,this.logger=s.create("pluralResolver"),this.options.compatibilityJSON&&!$.includes(this.options.compatibilityJSON)||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=function(){const t={};return L.forEach((e=>{e.lngs.forEach((s=>{t[s]={numbers:e.nr,plurals:w[e.fc]}}))})),t}()}addRule(t,e){this.rules[t]=e}getRule(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(y("dev"===t?"en":t),{type:e.ordinal?"ordinal":"cardinal"})}catch(t){return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(t,s).map((t=>`${e}${t}`))}getSuffixes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(((t,e)=>R[t]-R[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):s.numbers.map((s=>this.getSuffix(t,s,e))):[]}getSuffix(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(e)}`:this.getSuffixRetroCompatible(i,e):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,e){const s=t.noAbs?t.plurals(e):t.plurals(Math.abs(e));let i=t.numbers[s];this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]&&(2===i?i="plural":1===i&&(i=""));const n=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?`_plural_${i.toString()}`:n():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]?n():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!N.includes(this.options.compatibilityJSON)}}function P(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=function(t,e,s){const i=u(t,s);return void 0!==i?i:u(e,s)}(t,e,s);return!o&&n&&"string"==typeof s&&(o=m(t,s,i),void 0===o&&(o=m(e,s,i))),o}class j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(t=>t),this.init(t)}init(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const e=t.interpolation;this.escape=void 0!==e.escape?e.escape:g,this.escapeValue=void 0===e.escapeValue||e.escapeValue,this.useRawValueToEscape=void 0!==e.useRawValueToEscape&&e.useRawValueToEscape,this.prefix=e.prefix?p(e.prefix):e.prefixEscaped||"{{",this.suffix=e.suffix?p(e.suffix):e.suffixEscaped||"}}",this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||",",this.unescapePrefix=e.unescapeSuffix?"":e.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":e.unescapeSuffix||"",this.nestingPrefix=e.nestingPrefix?p(e.nestingPrefix):e.nestingPrefixEscaped||p("$t("),this.nestingSuffix=e.nestingSuffix?p(e.nestingSuffix):e.nestingSuffixEscaped||p(")"),this.nestingOptionsSeparator=e.nestingOptionsSeparator?e.nestingOptionsSeparator:e.nestingOptionsSeparator||",",this.maxReplaces=e.maxReplaces?e.maxReplaces:1e3,this.alwaysFormat=void 0!==e.alwaysFormat&&e.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t&&t.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,e,s,i){let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(t){return t.replace(/\$/g,"$$$$")}const h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=P(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,s,{...i,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format(P(e,l,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,s,{...i,...e,interpolationkey:o})};this.resetRegExp();const p=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,c=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>u(t)},{regex:this.regexp,safeValue:t=>this.escapeValue?u(this.escape(t)):u(t)}].forEach((e=>{for(a=0;n=e.regex.exec(t);){const s=n[1].trim();if(r=h(s),void 0===r)if("function"==typeof p){const e=p(t,n,i);r="string"==typeof e?e:""}else if(i&&Object.prototype.hasOwnProperty.call(i,s))r="";else{if(c){r=n[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),r=""}else"string"==typeof r||this.useRawValueToEscape||(r=o(r));const l=e.safeValue(r);if(t=t.replace(n[0],l),c?(e.regex.lastIndex+=r.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),t}nest(t,e){let s,i,n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(t,e){const s=this.nestingOptionsSeparator;if(t.indexOf(s)<0)return t;const i=t.split(new RegExp(`${s}[ ]*{`));let o=`{${i[1]}`;t=i[0],o=this.interpolate(o,n);const r=o.match(/'/g),a=o.match(/"/g);(r&&r.length%2==0&&!a||a.length%2!=0)&&(o=o.replace(/'/g,'"'));try{n=JSON.parse(o),e&&(n={...e,...n})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${s}${o}`}return n.defaultValue&&n.defaultValue.indexOf(this.prefix)>-1&&delete n.defaultValue,t}for(;s=this.nestingRegexp.exec(t);){let l=[];n={...r},n=n.replace&&"string"!=typeof n.replace?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;let u=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){const t=s[1].split(this.formatSeparator).map((t=>t.trim()));s[1]=t.shift(),l=t,u=!0}if(i=e(a.call(this,s[1].trim(),n),n),i&&s[0]===t&&"string"!=typeof i)return i;"string"!=typeof i&&(i=o(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=l.reduce(((t,e)=>this.format(t,e,r.lng,{...r,interpolationkey:s[1].trim()})),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}function E(t){const e={};return function(s,i,n){const o=i+JSON.stringify(n);let r=e[o];return r||(r=t(y(i),n),e[o]=r),r(s)}}class I{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("formatter"),this.options=t,this.formats={number:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e});return t=>s.format(t)})),currency:E(((t,e)=>{const s=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>s.format(t)})),datetime:E(((t,e)=>{const s=new Intl.DateTimeFormat(t,{...e});return t=>s.format(t)})),relativetime:E(((t,e)=>{const s=new Intl.RelativeTimeFormat(t,{...e});return t=>s.format(t,e.range||"day")})),list:E(((t,e)=>{const s=new Intl.ListFormat(t,{...e});return t=>s.format(t)}))},this.init(t)}init(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||","}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=E(e)}format(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.split(this.formatSeparator).reduce(((t,e)=>{const{formatName:n,formatOptions:o}=function(t){let e=t.toLowerCase().trim();const s={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const n=i[1].substring(0,i[1].length-1);"currency"===e&&n.indexOf(":")<0?s.currency||(s.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?s.range||(s.range=n.trim()):n.split(";").forEach((t=>{if(!t)return;const[e,...i]=t.split(":"),n=i.join(":").trim().replace(/^'+|'+$/g,"");s[e.trim()]||(s[e.trim()]=n),"false"===n&&(s[e.trim()]=!1),"true"===n&&(s[e.trim()]=!0),isNaN(n)||(s[e.trim()]=parseInt(n,10))}))}return{formatName:e,formatOptions:s}}(e);if(this.formats[n]){let e=t;try{const r=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},a=r.locale||r.lng||i.locale||i.lng||s;e=this.formats[n](t,a,{...o,...i,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class F extends i{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=n,this.logger=s.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(i,n.backend,n)}queueLoad(t,e,s,i){const n={},o={},r={},a={};return t.forEach((t=>{let i=!0;e.forEach((e=>{const r=`${t}|${e}`;!s.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,i=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),i||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,s){const i=t.split("|"),n=i[0],o=i[1];e&&this.emit("failedLoading",n,o,e),s&&this.store.addResourceBundle(n,o,s,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2;const r={};this.queue.forEach((s=>{!function(t,e,s,i){const{obj:n,k:o}=a(t,e,Object);n[o]=n[o]||[],i&&(n[o]=n[o].concat(s)),i||n[o].push(s)}(s.loaded,[n],o),function(t,e){void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)}(s,t),e&&s.errors.push(e),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((t=>{r[t]||(r[t]={});const e=s.loaded[t];e.length&&e.forEach((e=>{void 0===r[t][e]&&(r[t][e]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",r),this.queue=this.queue.filter((t=>!t.done))}read(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:s,tried:i,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&i{this.read.call(this,t,e,s,i+1,2*n,o)}),n):o(r,a)},a=this.backend[s].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const s=a(t,e);s&&"function"==typeof s.then?s.then((t=>r(null,t))).catch(r):r(null,s)}catch(t){r(t)}}prepareLoading(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof t&&(t=this.languageUtils.toResolveHierarchy(t)),"string"==typeof e&&(e=[e]);const n=this.queueLoad(t,e,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,s){this.prepareLoading(t,e,{},s)}reload(t,e,s){this.prepareLoading(t,e,{reload:!0},s)}loadOne(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=t.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${e}loading namespace ${n} for language ${i} failed`,s),!s&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${i}`,o),this.loaded(t,s,o)}))}saveMissing(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(e))this.logger.warn(`did not save key "${s}" as the namespace "${e}" 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!!!");else if(null!=s&&""!==s){if(this.backend&&this.backend.create){const a={...o,isUpdate:n},l=this.backend.create.bind(this.backend);if(l.length<6)try{let n;n=5===l.length?l(t,e,s,i,a):l(t,e,s,i),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else l(t,e,s,i,r,a)}t&&t[0]&&this.store.addResource(t[0],e,s,i)}}}function V(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let e={};if("object"==typeof t[1]&&(e=t[1]),"string"==typeof t[1]&&(e.defaultValue=t[1]),"string"==typeof t[2]&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const s=t[3]||t[2];Object.keys(s).forEach((t=>{e[t]=s[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function A(t){return"string"==typeof t.ns&&(t.ns=[t.ns]),"string"==typeof t.fallbackLng&&(t.fallbackLng=[t.fallbackLng]),"string"==typeof t.fallbackNS&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function D(){}class U extends i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;var i;if(super(),this.options=A(t),this.services={},this.logger=s,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,"function"==typeof e&&(i=e,e={}),!e.defaultNS&&!1!==e.defaultNS&&e.ns&&("string"==typeof e.ns?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const o=V();function r(t){return t?"function"==typeof t?new t:t:null}if(this.options={...o,...this.options,...A(e)},"v1"!==this.options.compatibilityAPI&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),!this.options.isClone){let e;this.modules.logger?s.init(r(this.modules.logger),this.options):s.init(null,this.options),this.modules.formatter?e=this.modules.formatter:"undefined"!=typeof Intl&&(e=I);const i=new O(this.options);this.store=new v(this.options.resources,this.options);const n=this.services;n.logger=s,n.resourceStore=this.store,n.languageUtils=i,n.pluralResolver=new C(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!e||this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format||(n.formatter=r(e),n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new j(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new F(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on("*",(function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n1?s-1:0),n=1;n{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,i||(i=D),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[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]=function(){return t.store[e](...arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=function(){return t.store[e](...arguments),t}}));const a=n(),l=()=>{const t=(t,e)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(e),i(t,e)};if(this.languages&&"v1"!==this.options.compatibilityAPI&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),a}loadResources(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s="string"==typeof t?t:this.language;if("function"==typeof t&&(e=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return e();const t=[],i=e=>{if(!e)return;if("cimode"===e)return;this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};if(s)i(s);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>i(t)))}this.options.preload&&this.options.preload.forEach((t=>i(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),e(t)}))}else e(null)}reloadResources(t,e,s){const i=n();return t||(t=this.languages),e||(e=this.options.ns),s||(s=D),this.services.backendConnector.reload(t,e,(t=>{i.resolve(),s(t)})),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&b.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1))for(let t=0;t-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}}changeLanguage(t,e){var s=this;this.isLanguageChangingTo=t;const i=n();this.emit("languageChanging",t);const o=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},r=(t,n)=>{n?(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve((function(){return s.t(...arguments)})),e&&e(t,(function(){return s.t(...arguments)}))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s="string"==typeof e?e:this.services.languageUtils.getBestMatchFromCodes(e);s&&(this.language||o(s),this.translator.language||this.translator.changeLanguage(s),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(s)),this.loadResources(s,(t=>{r(t,s)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),i}getFixedT(t,e,s){var i=this;const n=function(t,e){let o;if("object"!=typeof e){for(var r=arguments.length,a=new Array(r>2?r-2:0),l=2;l`${o.keyPrefix}${u}${t}`)):o.keyPrefix?`${o.keyPrefix}${u}${t}`:t,i.t(h,o)};return"string"==typeof t?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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=e.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(t,e)=>{const s=this.services.backendConnector.state[`${t}|${e}`];return-1===s||2===s};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!!this.hasResourceBundle(s,t)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,t)||i&&!o(n,t)))}loadNamespaces(t,e){const s=n();return this.options.ns?("string"==typeof t&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}loadLanguages(t,e){const s=n();"string"==typeof t&&(t=[t]);const i=this.options.preload||[],o=t.filter((t=>i.indexOf(t)<0));return o.length?(this.options.preload=i.concat(o),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const e=this.services&&this.services.languageUtils||new O(V());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){return new U(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},n=new U(i);void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t));return["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s&&(n.store=new v(this.store.data,i),n.services.resourceStore=n.store),n.translator=new S(n.services,i),n.translator.on("*",(function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i -1) + delete clonedOptions.defaultValue; return key; } diff --git a/test/runtime/translator/translator.translate.combination.test.js b/test/runtime/translator/translator.translate.combination.test.js index 65f425c6d..1d76d9a4e 100644 --- a/test/runtime/translator/translator.translate.combination.test.js +++ b/test/runtime/translator/translator.translate.combination.test.js @@ -41,6 +41,12 @@ describe('Translator', () => { friend_female_zero: 'no girlfriend', friend_female_one: 'a girlfriend', friend_female_other: '{{count}} girlfriends', + + message: + 'Something went wrong: $t(error_code.{{error_type}}, {"defaultValue": "Unknown error"})', + error_code: { + it_error: 'it went wrong', + }, }, }, }); @@ -114,6 +120,15 @@ describe('Translator', () => { args: ['noKeyFoundTestingDefault_1', { defaultValue: '{{val}} bar', val: '$t(foo)' }], expected: 'foo bar', }, + + { + args: ['message', { error_type: 'it_error' }], + expected: 'Something went wrong: it went wrong', + }, + { + args: ['message', { error_type: 'other_error' }], + expected: 'Something went wrong: Unknown error', + }, ]; tests.forEach((test) => { From c9e2bf5a1eeff27dd017eb068314377b0990d081 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Sun, 14 Apr 2024 15:02:24 +0200 Subject: [PATCH 14/14] 23.11.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f297631d1..5753ebf9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "i18next", - "version": "23.11.1", + "version": "23.11.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "i18next", - "version": "23.11.1", + "version": "23.11.2", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index 5040ada7d..0b499a5a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "i18next", - "version": "23.11.1", + "version": "23.11.2", "description": "i18next internationalization framework", "main": "./dist/cjs/i18next.js", "module": "./dist/esm/i18next.js",