@prosopo/locale 3.2.6 → 3.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +20 -20
  2. package/.turbo/turbo-build$colon$tsc.log +5 -5
  3. package/.turbo/turbo-build.log +22 -19
  4. package/CHANGELOG.md +25 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  7. package/dist/cjs/i18SharedOptions.cjs +8 -10
  8. package/dist/cjs/i18nBackend.cjs +29 -29
  9. package/dist/cjs/i18nFrontend.cjs +55 -55
  10. package/dist/cjs/i18nMiddleware.cjs +7 -6
  11. package/dist/cjs/index.cjs +13 -14
  12. package/dist/cjs/loadI18next.cjs +25 -27
  13. package/dist/cjs/locales/en/translation.cjs +487 -0
  14. package/dist/cjs/translationKey.cjs +14 -22
  15. package/dist/cjs/translations.cjs +39 -39
  16. package/dist/cjs/useTranslation.cjs +10 -6
  17. package/dist/cjs/util.cjs +6 -6
  18. package/dist/i18SharedOptions.js +9 -11
  19. package/dist/i18nBackend.js +25 -28
  20. package/dist/i18nFrontend.d.ts +1 -1
  21. package/dist/i18nFrontend.d.ts.map +1 -1
  22. package/dist/i18nFrontend.js +46 -51
  23. package/dist/i18nFrontend.js.map +1 -1
  24. package/dist/i18nMiddleware.d.ts +2 -1
  25. package/dist/i18nMiddleware.d.ts.map +1 -1
  26. package/dist/i18nMiddleware.js +5 -6
  27. package/dist/i18nMiddleware.js.map +1 -1
  28. package/dist/index.js +5 -12
  29. package/dist/loadI18next.d.ts +1 -1
  30. package/dist/loadI18next.d.ts.map +1 -1
  31. package/dist/loadI18next.js +25 -28
  32. package/dist/loadI18next.js.map +1 -1
  33. package/dist/locales/en/translation.js +473 -0
  34. package/dist/translationKey.js +15 -23
  35. package/dist/translations.js +37 -40
  36. package/dist/useTranslation.js +10 -8
  37. package/dist/util.js +7 -8
  38. package/package.json +6 -6
  39. package/src/i18nFrontend.ts +8 -0
  40. package/src/i18nMiddleware.ts +6 -1
  41. package/src/loadI18next.ts +25 -5
  42. package/tsconfig.tsbuildinfo +1 -1
  43. package/.turbo/turbo-typecheck.log +0 -4
  44. package/dist/cjs/locales/en/translation.json.cjs +0 -47
  45. package/dist/locales/en/translation.json.js +0 -47
@@ -1,31 +1,31 @@
1
1
 
2
- > @prosopo/locale@3.2.6 build:cjs
2
+ > @prosopo/locale@3.2.8 build:cjs
3
3
  > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
4
 
5
5
  ViteCommonJSConfig: .
6
6
  { tsConfigPaths: [] }
7
7
  { externals: [] }
8
- vite v6.4.1 building SSR bundle for production...
8
+ The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
9
+ vite v8.1.5 building ssr environment for production...
9
10
  Bundle build started
10
- transforming...
11
- Build end
12
- ✓ 11 modules transformed.
13
- Entry module "src/i18nBackend.ts" is using named and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
14
- Entry module "src/i18nFrontend.ts" is using named and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
15
- Entry module "src/locales/en/translation.json" is using named and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
11
+ 
12
+ ✓ 12 modules transformed.
16
13
  rendering chunks...
17
- dist/cjs/useTranslation.cjs  0.30 kB
18
- dist/cjs/i18nMiddleware.cjs  0.31 kB
19
- dist/cjs/util.cjs  0.35 kB
20
- dist/cjs/i18SharedOptions.cjs  0.51 kB
21
- dist/cjs/index.cjs  0.72 kB
22
- dist/cjs/translationKey.cjs  0.73 kB
23
- dist/cjs/loadI18next.cjs  0.78 kB
24
- dist/cjs/translations.cjs  0.83 kB
25
- dist/cjs/i18nBackend.cjs  1.41 kB
26
- dist/cjs/i18nFrontend.cjs  2.79 kB
27
- dist/cjs/locales/en/translation.json.cjs 15.40 kB
28
- ✓ built in 292ms
14
+ computing gzip size...
15
+ dist/cjs/util.cjs 0.28 kB │ gzip: 0.17 kB
16
+ dist/cjs/useTranslation.cjs 0.35 kB │ gzip: 0.20 kB
17
+ dist/cjs/i18nMiddleware.cjs 0.36 kB │ gzip: 0.21 kB
18
+ dist/cjs/i18SharedOptions.cjs 0.42 kB │ gzip: 0.27 kB
19
+ dist/cjs/translationKey.cjs 0.64 kB │ gzip: 0.36 kB
20
+ dist/cjs/index.cjs 0.83 kB │ gzip: 0.27 kB
21
+ dist/cjs/translations.cjs 0.86 kB │ gzip: 0.46 kB
22
+ dist/cjs/loadI18next.cjs 0.90 kB │ gzip: 0.37 kB
23
+ dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
24
+ dist/cjs/i18nBackend.cjs 1.36 kB │ gzip: 0.58 kB
25
+ dist/cjs/i18nFrontend.cjs 2.35 kB │ gzip: 0.84 kB
26
+ dist/cjs/locales/en/translation.cjs 15.72 kB │ gzip: 5.59 kB
27
+
28
+ ✓ built in 83ms
29
29
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ar/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ar/translation.json
30
30
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/az/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/az/translation.json
31
31
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/cs/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/cs/translation.json
@@ -1,14 +1,14 @@
1
1
 
2
- > @prosopo/locale@3.2.6 build:tsc
2
+ > @prosopo/locale@3.2.8 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 3:09:18 PM - Projects in this build:
5
+ 8:58:35 PM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * tsconfig.json
8
8
 
9
- 3:09:18 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
9
+ 8:58:36 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
10
10
 
11
- 3:09:18 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
11
+ 8:58:36 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
12
12
 
13
- 3:09:18 PM - Building project '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json'...
13
+ 8:58:36 PM - Building project '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json'...
14
14
 
@@ -1,39 +1,42 @@
1
1
 
2
- > @prosopo/locale@3.2.6 build
2
+ > @prosopo/locale@3.2.8 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/locale@3.2.6 build:cross-env
6
+ > @prosopo/locale@3.2.8 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
10
10
  { tsConfigPaths: [] }
11
11
  { externals: [] }
12
- vite v6.4.1 building SSR bundle for production...
12
+ The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
13
+ vite v8.1.5 building ssr environment for production...
13
14
  Bundle build started
14
- transforming...
15
- Build end
16
- ✓ 11 modules transformed.
15
+ 
16
+ ✓ 12 modules transformed.
17
17
  rendering chunks...
18
- dist/util.js  0.23 kB
19
- dist/i18nMiddleware.js  0.26 kB
20
- dist/useTranslation.js  0.29 kB
21
- dist/i18SharedOptions.js  0.39 kB
22
- dist/index.js  0.51 kB
23
- dist/translationKey.js  0.61 kB
24
- dist/translations.js  0.71 kB
25
- dist/loadI18next.js  0.71 kB
26
- dist/i18nBackend.js  0.88 kB
27
- dist/i18nFrontend.js  2.03 kB
28
- dist/locales/en/translation.json.js 15.07 kB
29
- ✓ built in 274ms
18
+ computing gzip size...
19
+ dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
20
+ dist/util.js 0.25 kB │ gzip: 0.16 kB
21
+ dist/i18nMiddleware.js 0.27 kB │ gzip: 0.18 kB
22
+ dist/useTranslation.js 0.30 kB │ gzip: 0.19 kB
23
+ dist/i18SharedOptions.js 0.37 kB │ gzip: 0.26 kB
24
+ dist/index.js 0.47 kB │ gzip: 0.20 kB
25
+ dist/translationKey.js 0.61 kB │ gzip: 0.36 kB
26
+ dist/translations.js 0.70 kB │ gzip: 0.39 kB
27
+ dist/loadI18next.js 0.84 kB │ gzip: 0.36 kB
28
+ dist/i18nBackend.js 0.91 kB │ gzip: 0.49 kB
29
+ dist/i18nFrontend.js 1.65 kB │ gzip: 0.74 kB
30
+ dist/locales/en/translation.js 15.49 kB │ gzip: 5.56 kB
31
+
32
+ ✓ built in 117ms
30
33
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ar/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ar/translation.json
31
34
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/az/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/az/translation.json
35
+ [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/cs/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/cs/translation.json
32
36
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/de/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/de/translation.json
33
37
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/el/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/el/translation.json
34
38
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/en/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/en/translation.json
35
39
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/es/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/es/translation.json
36
- [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/cs/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/cs/translation.json
37
40
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/fi/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/fi/translation.json
38
41
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/fr/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/fr/translation.json
39
42
  [copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/hi/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/hi/translation.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @prosopo/locale
2
2
 
3
+ ## 3.2.8
4
+ ### Patch Changes
5
+
6
+ - 0e1171c: chore(deps): combined dependabot bumps (lodash, webpack-dev-server, sharp, i18next-http-middleware, actions/setup-node and transitive security updates)
7
+ - e14fce6: chore(deps): bump vite to 6.4.3 and mongoose to 8.24.1, and adjust types for the mongoose 8.24 Document/ObjectId changes
8
+
9
+ ## 3.2.7
10
+ ### Patch Changes
11
+
12
+ - b500d56: fix(widget): enforce single language across widget, kill browser/config race
13
+
14
+ `WidgetFactory.getCaptchaRenderer()` booted the i18n singleton with the
15
+ browser-detected language before the site-owner `renderOptions.language` /
16
+ `data-language` had been resolved, and each widget then called
17
+ `i18n.changeLanguage(config.language)` from a post-mount effect. Any child
18
+ component that read `useTranslation()` between first render and the async
19
+ `changeLanguage` resolution rendered in the browser language, then re-rendered
20
+ in the site-owner language — the multi-language flash customers reported.
21
+
22
+ Resolve the site-owner language in `WidgetFactory.createWidget()` before the
23
+ lazy renderer load and thread it into `loadI18next(false, lng)`, so the
24
+ singleton boots (or reconciles via `changeLanguage` + await) with the correct
25
+ language before React mounts. Site-owner language wins; falls back to browser
26
+ detection only when no `language` / `data-language` is set.
27
+
3
28
  ## 3.2.6
4
29
  ### Patch Changes
5
30
 
@@ -0,0 +1,3 @@
1
+ import "node:module";
2
+ //#endregion
3
+ export {};
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const translations = require("./translations.cjs");
4
- const logLevel = typeof process !== "undefined" ? process.env?.PROSOPO_LOG_LEVEL : void 0;
5
- const i18nSharedOptions = {
6
- debug: logLevel === "debug",
7
- fallbackLng: translations.LanguageSchema.enum.en,
8
- namespace: "translation",
9
- supportedLngs: Object.values(translations.Languages),
10
- nonExplicitSupportedLngs: false
1
+ const require_translations = require("./translations.cjs");
2
+ var i18nSharedOptions = {
3
+ debug: (typeof process !== "undefined" ? process.env?.PROSOPO_LOG_LEVEL : void 0) === "debug",
4
+ fallbackLng: require_translations.LanguageSchema.enum.en,
5
+ namespace: "translation",
6
+ supportedLngs: Object.values(require_translations.Languages),
7
+ nonExplicitSupportedLngs: false
11
8
  };
9
+ //#endregion
12
10
  exports.i18nSharedOptions = i18nSharedOptions;
@@ -1,33 +1,33 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const path = require("node:path");
4
- const i18n = require("i18next");
5
- const FSBackend = require("i18next-fs-backend/cjs");
6
- const i18nextHttpMiddleware = require("i18next-http-middleware");
7
- const i18SharedOptions = require("./i18SharedOptions.cjs");
8
- const util = require("./util.cjs");
9
- var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
10
- const loadPath = `${path.dirname(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("i18nBackend.cjs", document.baseURI).href)}/locales/{{lng}}/{{ns}}.json`.replace(
11
- "file://",
12
- ""
13
- );
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_util = require("./util.cjs");
3
+ const require_i18SharedOptions = require("./i18SharedOptions.cjs");
4
+ let i18next_http_middleware = require("i18next-http-middleware");
5
+ let i18next = require("i18next");
6
+ i18next = require_runtime.__toESM(i18next, 1);
7
+ let node_path = require("node:path");
8
+ node_path = require_runtime.__toESM(node_path, 1);
9
+ let i18next_fs_backend_cjs = require("i18next-fs-backend/cjs");
10
+ i18next_fs_backend_cjs = require_runtime.__toESM(i18next_fs_backend_cjs, 1);
11
+ //#region src/i18nBackend.ts
12
+ var loadPath = `${node_path.default.dirname(require("url").pathToFileURL(__filename).href)}/locales/{{lng}}/{{ns}}.json`.replace("file://", "");
14
13
  function initializeI18n(i18nLoadedCallback) {
15
- if (!i18n.isInitialized && util.isServerSide()) {
16
- const lngDetector = new i18nextHttpMiddleware.LanguageDetector(null, {
17
- order: ["header", "query", "cookie"]
18
- });
19
- i18n.use(FSBackend).use(lngDetector).init({
20
- ...i18SharedOptions.i18nSharedOptions,
21
- ns: ["translation"],
22
- backend: {
23
- loadPath
24
- }
25
- });
26
- i18n.on("loaded", () => {
27
- i18nLoadedCallback?.(i18n);
28
- });
29
- }
30
- return i18n;
14
+ if (!i18next.default.isInitialized && require_util.isServerSide()) {
15
+ const lngDetector = new i18next_http_middleware.LanguageDetector(null, { order: [
16
+ "header",
17
+ "query",
18
+ "cookie"
19
+ ] });
20
+ i18next.default.use(i18next_fs_backend_cjs.default).use(lngDetector).init({
21
+ ...require_i18SharedOptions.i18nSharedOptions,
22
+ ns: ["translation"],
23
+ backend: { loadPath }
24
+ });
25
+ i18next.default.on("loaded", () => {
26
+ i18nLoadedCallback?.(i18next.default);
27
+ });
28
+ }
29
+ return i18next.default;
31
30
  }
31
+ //#endregion
32
32
  exports.default = initializeI18n;
33
33
  exports.initializeI18n = initializeI18n;
@@ -1,60 +1,60 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const i18n = require("i18next");
4
- const I18nextBrowserLanguageDetector = require("i18next-browser-languagedetector");
5
- const ChainedBackend = require("i18next-chained-backend");
6
- const HttpBackend = require("i18next-http-backend");
7
- const resourcesToBackend = require("i18next-resources-to-backend");
8
- const reactI18next = require("react-i18next");
9
- const i18SharedOptions = require("./i18SharedOptions.cjs");
10
- var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
11
- const reactOptions = {
12
- react: {
13
- useSuspense: true
14
- },
15
- detection: {
16
- order: ["navigator", "htmlTag", "path", "subdomain"],
17
- caches: ["localStorage", "cookie"]
18
- }
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_i18SharedOptions = require("./i18SharedOptions.cjs");
3
+ let react_i18next = require("react-i18next");
4
+ let i18next = require("i18next");
5
+ i18next = require_runtime.__toESM(i18next, 1);
6
+ let i18next_browser_languagedetector = require("i18next-browser-languagedetector");
7
+ i18next_browser_languagedetector = require_runtime.__toESM(i18next_browser_languagedetector, 1);
8
+ let i18next_chained_backend = require("i18next-chained-backend");
9
+ i18next_chained_backend = require_runtime.__toESM(i18next_chained_backend, 1);
10
+ let i18next_http_backend = require("i18next-http-backend");
11
+ i18next_http_backend = require_runtime.__toESM(i18next_http_backend, 1);
12
+ let i18next_resources_to_backend = require("i18next-resources-to-backend");
13
+ i18next_resources_to_backend = require_runtime.__toESM(i18next_resources_to_backend, 1);
14
+ //#region src/i18nFrontend.ts
15
+ var reactOptions = {
16
+ react: { useSuspense: true },
17
+ detection: {
18
+ order: [
19
+ "navigator",
20
+ "htmlTag",
21
+ "path",
22
+ "subdomain"
23
+ ],
24
+ caches: ["localStorage", "cookie"]
25
+ }
19
26
  };
20
- const getLoadPath = (language, namespace) => {
21
- const filename = (typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("i18nFrontend.cjs", document.baseURI).href).split("/").pop();
22
- return `${(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("i18nFrontend.cjs", document.baseURI).href).replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
27
+ var getLoadPath = (language, namespace) => {
28
+ const filename = require("url").pathToFileURL(__filename).href.split("/").pop();
29
+ return `${require("url").pathToFileURL(__filename).href.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
23
30
  };
24
- function initializeI18n(i18nLoadedCallback) {
25
- if (!i18n.isInitialized) {
26
- i18n.use(ChainedBackend).use(
27
- new I18nextBrowserLanguageDetector(null, {
28
- order: ["cookie", "localStorage", "navigator"],
29
- lookupQuerystring: "lng",
30
- lookupCookie: "i18next",
31
- lookupLocalStorage: "i18nextLng",
32
- caches: ["localStorage", "cookie"]
33
- })
34
- ).use(reactI18next.initReactI18next).init({
35
- ...i18SharedOptions.i18nSharedOptions,
36
- backend: {
37
- backends: [
38
- HttpBackend,
39
- // if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
40
- // with dynamic import, you have to use the "default" key of the module ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#importing_defaults )
41
- resourcesToBackend(
42
- (language, namespace) => import(getLoadPath(language, namespace))
43
- )
44
- ],
45
- backendOptions: [
46
- {
47
- loadPath: getLoadPath("{{lng}}", "{{ns}}")
48
- }
49
- ]
50
- },
51
- ...reactOptions
52
- });
53
- i18n.on("loaded", () => {
54
- i18nLoadedCallback?.(i18n);
55
- });
56
- }
57
- return i18n;
31
+ function initializeI18n(i18nLoadedCallback, lng) {
32
+ if (!i18next.default.isInitialized) {
33
+ i18next.default.use(i18next_chained_backend.default).use(new i18next_browser_languagedetector.default(null, {
34
+ order: [
35
+ "cookie",
36
+ "localStorage",
37
+ "navigator"
38
+ ],
39
+ lookupQuerystring: "lng",
40
+ lookupCookie: "i18next",
41
+ lookupLocalStorage: "i18nextLng",
42
+ caches: ["localStorage", "cookie"]
43
+ })).use(react_i18next.initReactI18next).init({
44
+ ...require_i18SharedOptions.i18nSharedOptions,
45
+ ...lng ? { lng } : {},
46
+ backend: {
47
+ backends: [i18next_http_backend.default, (0, i18next_resources_to_backend.default)((language, namespace) => import(getLoadPath(language, namespace)))],
48
+ backendOptions: [{ loadPath: getLoadPath("{{lng}}", "{{ns}}") }]
49
+ },
50
+ ...reactOptions
51
+ });
52
+ i18next.default.on("loaded", () => {
53
+ i18nLoadedCallback?.(i18next.default);
54
+ });
55
+ }
56
+ return i18next.default;
58
57
  }
58
+ //#endregion
59
59
  exports.default = initializeI18n;
60
60
  exports.initializeI18n = initializeI18n;
@@ -1,8 +1,9 @@
1
- "use strict";
2
- const i18nextHttpMiddleware = require("i18next-http-middleware");
3
- const loadI18next = require("./loadI18next.cjs");
1
+ const require_loadI18next = require("./loadI18next.cjs");
2
+ let i18next_http_middleware = require("i18next-http-middleware");
3
+ //#region src/i18nMiddleware.ts
4
4
  async function i18nMiddleware(options) {
5
- const i18n = await loadI18next(true);
6
- return i18nextHttpMiddleware.handle(i18n, { ...options });
5
+ const i18n = await require_loadI18next.default(true);
6
+ return (0, i18next_http_middleware.handle)(i18n, { ...options });
7
7
  }
8
- module.exports = i18nMiddleware;
8
+ //#endregion
9
+ exports.default = i18nMiddleware;
@@ -1,15 +1,14 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const i18nMiddleware = require("./i18nMiddleware.cjs");
4
- const loadI18next = require("./loadI18next.cjs");
5
- const translations = require("./translations.cjs");
6
- const util = require("./util.cjs");
7
- const translationKey = require("./translationKey.cjs");
8
- const useTranslation = require("./useTranslation.cjs");
9
- exports.i18nMiddleware = i18nMiddleware;
10
- exports.loadI18next = loadI18next;
11
- exports.LanguageSchema = translations.LanguageSchema;
12
- exports.Languages = translations.Languages;
13
- exports.isClientSide = util.isClientSide;
14
- exports.TranslationKeysSchema = translationKey.TranslationKeysSchema;
15
- exports.useTranslation = useTranslation;
2
+ const require_loadI18next = require("./loadI18next.cjs");
3
+ const require_i18nMiddleware = require("./i18nMiddleware.cjs");
4
+ const require_translations = require("./translations.cjs");
5
+ const require_util = require("./util.cjs");
6
+ const require_translationKey = require("./translationKey.cjs");
7
+ const require_useTranslation = require("./useTranslation.cjs");
8
+ exports.LanguageSchema = require_translations.LanguageSchema;
9
+ exports.Languages = require_translations.Languages;
10
+ exports.TranslationKeysSchema = require_translationKey.TranslationKeysSchema;
11
+ exports.i18nMiddleware = require_i18nMiddleware.default;
12
+ exports.isClientSide = require_util.isClientSide;
13
+ exports.loadI18next = require_loadI18next.default;
14
+ exports.useTranslation = require_useTranslation.default;
@@ -1,28 +1,26 @@
1
- "use strict";
2
- let i18nInstance;
3
- async function loadI18next(backend) {
4
- return new Promise((resolve, reject) => {
5
- try {
6
- if (backend) {
7
- Promise.resolve().then(() => require("./i18nBackend.cjs")).then(({ default: initializeI18n }) => {
8
- if (!i18nInstance) {
9
- i18nInstance = initializeI18n(resolve);
10
- } else {
11
- resolve(i18nInstance);
12
- }
13
- });
14
- } else {
15
- Promise.resolve().then(() => require("./i18nFrontend.cjs")).then(({ default: initializeI18n }) => {
16
- if (!i18nInstance) {
17
- i18nInstance = initializeI18n(resolve);
18
- } else {
19
- resolve(i18nInstance);
20
- }
21
- });
22
- }
23
- } catch (e) {
24
- reject(e);
25
- }
26
- });
1
+ //#region src/loadI18next.ts
2
+ var i18nInstance;
3
+ var reconcileLanguage = async (instance, lng) => {
4
+ if (lng && instance.language !== lng) await instance.changeLanguage(lng);
5
+ return instance;
6
+ };
7
+ async function loadI18next(backend, lng) {
8
+ return new Promise((resolve, reject) => {
9
+ try {
10
+ if (backend) Promise.resolve().then(() => require("./i18nBackend.cjs")).then(({ default: initializeI18n }) => {
11
+ if (!i18nInstance) i18nInstance = initializeI18n(resolve);
12
+ else resolve(i18nInstance);
13
+ });
14
+ else Promise.resolve().then(() => require("./i18nFrontend.cjs")).then(({ default: initializeI18n }) => {
15
+ if (!i18nInstance) i18nInstance = initializeI18n((instance) => {
16
+ reconcileLanguage(instance, lng).then(resolve);
17
+ }, lng);
18
+ else reconcileLanguage(i18nInstance, lng).then(resolve);
19
+ });
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ });
27
24
  }
28
- module.exports = loadI18next;
25
+ //#endregion
26
+ exports.default = loadI18next;