@prosopo/locale 3.1.21 → 3.1.22

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 (76) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/i18SharedOptions.js +10 -8
  3. package/dist/i18nBackend.js +26 -24
  4. package/dist/i18nFrontend.js +47 -43
  5. package/dist/i18nMiddleware.js +5 -4
  6. package/dist/index.js +15 -7
  7. package/dist/loadI18next.js +26 -29
  8. package/dist/locales/ar/translation.json +441 -441
  9. package/dist/locales/az/translation.json +441 -441
  10. package/dist/locales/cs/translation.json +441 -441
  11. package/dist/locales/de/translation.json +441 -441
  12. package/dist/locales/el/translation.json +441 -441
  13. package/dist/locales/en/translation.json +441 -441
  14. package/dist/locales/es/translation.json +441 -441
  15. package/dist/locales/fi/translation.json +441 -441
  16. package/dist/locales/fr/translation.json +441 -441
  17. package/dist/locales/hi/translation.json +441 -441
  18. package/dist/locales/hu/translation.json +441 -441
  19. package/dist/locales/id/translation.json +441 -441
  20. package/dist/locales/it/translation.json +441 -441
  21. package/dist/locales/ja/translation.json +441 -441
  22. package/dist/locales/jv/translation.json +441 -441
  23. package/dist/locales/ko/translation.json +441 -441
  24. package/dist/locales/ml/translation.json +441 -441
  25. package/dist/locales/ms/translation.json +441 -441
  26. package/dist/locales/nl/translation.json +441 -441
  27. package/dist/locales/no/translation.json +441 -441
  28. package/dist/locales/pl/translation.json +441 -441
  29. package/dist/locales/pt/translation.json +441 -441
  30. package/dist/locales/pt-BR/translation.json +441 -441
  31. package/dist/locales/ro/translation.json +441 -441
  32. package/dist/locales/ru/translation.json +441 -441
  33. package/dist/locales/sr/translation.json +441 -441
  34. package/dist/locales/sv/translation.json +441 -441
  35. package/dist/locales/th/translation.json +441 -441
  36. package/dist/locales/tr/translation.json +441 -441
  37. package/dist/locales/uk/translation.json +441 -441
  38. package/dist/locales/vi/translation.json +441 -441
  39. package/dist/locales/zh-CN/translation.json +441 -441
  40. package/dist/translationKey.js +21 -15
  41. package/dist/translations.js +40 -35
  42. package/dist/useTranslation.js +7 -6
  43. package/dist/util.js +8 -7
  44. package/package.json +2 -2
  45. package/coverage/base.css +0 -224
  46. package/coverage/block-navigation.js +0 -87
  47. package/coverage/clover.xml +0 -260
  48. package/coverage/coverage-final.json +0 -11
  49. package/coverage/favicon.png +0 -0
  50. package/coverage/i18SharedOptions.ts.html +0 -151
  51. package/coverage/i18nBackend.ts.html +0 -244
  52. package/coverage/i18nFrontend.ts.html +0 -328
  53. package/coverage/i18nMiddleware.ts.html +0 -160
  54. package/coverage/index.html +0 -251
  55. package/coverage/index.ts.html +0 -151
  56. package/coverage/loadI18next.ts.html +0 -232
  57. package/coverage/prettify.css +0 -1
  58. package/coverage/prettify.js +0 -2
  59. package/coverage/sort-arrow-sprite.png +0 -0
  60. package/coverage/sorter.js +0 -210
  61. package/coverage/translationKey.ts.html +0 -229
  62. package/coverage/translations.ts.html +0 -247
  63. package/coverage/useTranslation.ts.html +0 -181
  64. package/coverage/util.ts.html +0 -160
  65. package/dist/i18SharedOptions.js.map +0 -1
  66. package/dist/i18nBackend.js.map +0 -1
  67. package/dist/i18nFrontend.js.map +0 -1
  68. package/dist/i18nMiddleware.js.map +0 -1
  69. package/dist/index.js.map +0 -1
  70. package/dist/loadI18next.js.map +0 -1
  71. package/dist/tests/locales.unit.test.js +0 -49
  72. package/dist/tests/locales.unit.test.js.map +0 -1
  73. package/dist/translationKey.js.map +0 -1
  74. package/dist/translations.js.map +0 -1
  75. package/dist/useTranslation.js.map +0 -1
  76. package/dist/util.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @prosopo/locale
2
2
 
3
+ ## 3.1.22
4
+ ### Patch Changes
5
+
6
+ - 8ce9205: Change engine requirements
7
+ - b6e98b2: Run npm audit
8
+ - Updated dependencies [8ce9205]
9
+ - Updated dependencies [df79c03]
10
+ - Updated dependencies [b6e98b2]
11
+ - @prosopo/config@3.1.22
12
+
3
13
  ## 3.1.21
4
14
  ### Patch Changes
5
15
 
@@ -1,9 +1,11 @@
1
- import { LanguageSchema, Languages } from "./translations.js";
2
- export const i18nSharedOptions = {
3
- debug: process.env.PROSOPO_LOG_LEVEL === "debug",
4
- fallbackLng: LanguageSchema.enum.en,
5
- namespace: "translation",
6
- supportedLngs: Object.values(Languages),
7
- nonExplicitSupportedLngs: false,
1
+ import { Languages, LanguageSchema } from "./translations.js";
2
+ const i18nSharedOptions = {
3
+ debug: process.env.PROSOPO_LOG_LEVEL === "debug",
4
+ fallbackLng: LanguageSchema.enum.en,
5
+ namespace: "translation",
6
+ supportedLngs: Object.values(Languages),
7
+ nonExplicitSupportedLngs: false
8
+ };
9
+ export {
10
+ i18nSharedOptions
8
11
  };
9
- //# sourceMappingURL=i18SharedOptions.js.map
@@ -1,30 +1,32 @@
1
1
  import path from "node:path";
2
2
  import i18n from "i18next";
3
3
  import FSBackend from "i18next-fs-backend/cjs";
4
- import { LanguageDetector as MiddlewareLanguageDetector } from "i18next-http-middleware";
4
+ import { LanguageDetector } from "i18next-http-middleware";
5
5
  import { i18nSharedOptions } from "./i18SharedOptions.js";
6
6
  import { isServerSide } from "./util.js";
7
- const loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace("file://", "");
8
- export function initializeI18n(i18nLoadedCallback) {
9
- if (!i18n.isInitialized && isServerSide()) {
10
- const lngDetector = new MiddlewareLanguageDetector(null, {
11
- order: ["header", "query", "cookie"],
12
- });
13
- i18n
14
- .use(FSBackend)
15
- .use(lngDetector)
16
- .init({
17
- ...i18nSharedOptions,
18
- ns: ["translation"],
19
- backend: {
20
- loadPath,
21
- },
22
- });
23
- i18n.on("loaded", () => {
24
- i18nLoadedCallback?.(i18n);
25
- });
26
- }
27
- return i18n;
7
+ const loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace(
8
+ "file://",
9
+ ""
10
+ );
11
+ function initializeI18n(i18nLoadedCallback) {
12
+ if (!i18n.isInitialized && isServerSide()) {
13
+ const lngDetector = new LanguageDetector(null, {
14
+ order: ["header", "query", "cookie"]
15
+ });
16
+ i18n.use(FSBackend).use(lngDetector).init({
17
+ ...i18nSharedOptions,
18
+ ns: ["translation"],
19
+ backend: {
20
+ loadPath
21
+ }
22
+ });
23
+ i18n.on("loaded", () => {
24
+ i18nLoadedCallback?.(i18n);
25
+ });
26
+ }
27
+ return i18n;
28
28
  }
29
- export default initializeI18n;
30
- //# sourceMappingURL=i18nBackend.js.map
29
+ export {
30
+ initializeI18n as default,
31
+ initializeI18n
32
+ };
@@ -6,50 +6,54 @@ import resourcesToBackend from "i18next-resources-to-backend";
6
6
  import { initReactI18next } from "react-i18next";
7
7
  import { i18nSharedOptions } from "./i18SharedOptions.js";
8
8
  const reactOptions = {
9
- react: {
10
- useSuspense: true,
11
- },
12
- detection: {
13
- order: ["navigator", "htmlTag", "path", "subdomain"],
14
- caches: ["localStorage", "cookie"],
15
- },
9
+ react: {
10
+ useSuspense: true
11
+ },
12
+ detection: {
13
+ order: ["navigator", "htmlTag", "path", "subdomain"],
14
+ caches: ["localStorage", "cookie"]
15
+ }
16
16
  };
17
17
  const getLoadPath = (language, namespace) => {
18
- const filename = import.meta.url.split("/").pop();
19
- return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
18
+ const filename = import.meta.url.split("/").pop();
19
+ return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
20
20
  };
21
- export function initializeI18n(i18nLoadedCallback) {
22
- if (!i18n.isInitialized) {
23
- i18n
24
- .use(ChainedBackend)
25
- .use(new I18nextBrowserLanguageDetector(null, {
26
- order: ["cookie", "localStorage", "navigator"],
27
- lookupQuerystring: "lng",
28
- lookupCookie: "i18next",
29
- lookupLocalStorage: "i18nextLng",
30
- caches: ["localStorage", "cookie"],
31
- }))
32
- .use(initReactI18next)
33
- .init({
34
- ...i18nSharedOptions,
35
- backend: {
36
- backends: [
37
- HttpBackend,
38
- resourcesToBackend((language, namespace) => import(getLoadPath(language, namespace))),
39
- ],
40
- backendOptions: [
41
- {
42
- loadPath: getLoadPath("{{lng}}", "{{ns}}"),
43
- },
44
- ],
45
- },
46
- ...reactOptions,
47
- });
48
- i18n.on("loaded", () => {
49
- i18nLoadedCallback?.(i18n);
50
- });
51
- }
52
- return i18n;
21
+ function initializeI18n(i18nLoadedCallback) {
22
+ if (!i18n.isInitialized) {
23
+ i18n.use(ChainedBackend).use(
24
+ new I18nextBrowserLanguageDetector(null, {
25
+ order: ["cookie", "localStorage", "navigator"],
26
+ lookupQuerystring: "lng",
27
+ lookupCookie: "i18next",
28
+ lookupLocalStorage: "i18nextLng",
29
+ caches: ["localStorage", "cookie"]
30
+ })
31
+ ).use(initReactI18next).init({
32
+ ...i18nSharedOptions,
33
+ backend: {
34
+ backends: [
35
+ HttpBackend,
36
+ // if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
37
+ // 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 )
38
+ resourcesToBackend(
39
+ (language, namespace) => import(getLoadPath(language, namespace))
40
+ )
41
+ ],
42
+ backendOptions: [
43
+ {
44
+ loadPath: getLoadPath("{{lng}}", "{{ns}}")
45
+ }
46
+ ]
47
+ },
48
+ ...reactOptions
49
+ });
50
+ i18n.on("loaded", () => {
51
+ i18nLoadedCallback?.(i18n);
52
+ });
53
+ }
54
+ return i18n;
53
55
  }
54
- export default initializeI18n;
55
- //# sourceMappingURL=i18nFrontend.js.map
56
+ export {
57
+ initializeI18n as default,
58
+ initializeI18n
59
+ };
@@ -1,8 +1,9 @@
1
1
  import { handle } from "i18next-http-middleware";
2
2
  import loadI18next from "./loadI18next.js";
3
3
  async function i18nMiddleware(options) {
4
- const i18n = await loadI18next(true);
5
- return handle(i18n, { ...options });
4
+ const i18n = await loadI18next(true);
5
+ return handle(i18n, { ...options });
6
6
  }
7
- export default i18nMiddleware;
8
- //# sourceMappingURL=i18nMiddleware.js.map
7
+ export {
8
+ i18nMiddleware as default
9
+ };
package/dist/index.js CHANGED
@@ -1,7 +1,15 @@
1
- export { default as i18nMiddleware } from "./i18nMiddleware.js";
2
- export { default as loadI18next } from "./loadI18next.js";
3
- export { Languages, LanguageSchema } from "./translations.js";
4
- export { isClientSide } from "./util.js";
5
- export { TranslationKeysSchema } from "./translationKey.js";
6
- export { default as useTranslation } from "./useTranslation.js";
7
- //# sourceMappingURL=index.js.map
1
+ import { default as default2 } from "./i18nMiddleware.js";
2
+ import { default as default3 } from "./loadI18next.js";
3
+ import { LanguageSchema, Languages } from "./translations.js";
4
+ import { isClientSide } from "./util.js";
5
+ import { TranslationKeysSchema } from "./translationKey.js";
6
+ import { default as default4 } from "./useTranslation.js";
7
+ export {
8
+ LanguageSchema,
9
+ Languages,
10
+ TranslationKeysSchema,
11
+ default2 as i18nMiddleware,
12
+ isClientSide,
13
+ default3 as loadI18next,
14
+ default4 as useTranslation
15
+ };
@@ -1,32 +1,29 @@
1
1
  let i18nInstance;
2
2
  async function loadI18next(backend) {
3
- return new Promise((resolve, reject) => {
4
- try {
5
- if (backend) {
6
- import("./i18nBackend.js").then(({ default: initializeI18n }) => {
7
- if (!i18nInstance) {
8
- i18nInstance = initializeI18n(resolve);
9
- }
10
- else {
11
- resolve(i18nInstance);
12
- }
13
- });
14
- }
15
- else {
16
- import("./i18nFrontend.js").then(({ default: initializeI18n }) => {
17
- if (!i18nInstance) {
18
- i18nInstance = initializeI18n(resolve);
19
- }
20
- else {
21
- resolve(i18nInstance);
22
- }
23
- });
24
- }
25
- }
26
- catch (e) {
27
- reject(e);
28
- }
29
- });
3
+ return new Promise((resolve, reject) => {
4
+ try {
5
+ if (backend) {
6
+ import("./i18nBackend.js").then(({ default: initializeI18n }) => {
7
+ if (!i18nInstance) {
8
+ i18nInstance = initializeI18n(resolve);
9
+ } else {
10
+ resolve(i18nInstance);
11
+ }
12
+ });
13
+ } else {
14
+ import("./i18nFrontend.js").then(({ default: initializeI18n }) => {
15
+ if (!i18nInstance) {
16
+ i18nInstance = initializeI18n(resolve);
17
+ } else {
18
+ resolve(i18nInstance);
19
+ }
20
+ });
21
+ }
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ });
30
26
  }
31
- export default loadI18next;
32
- //# sourceMappingURL=loadI18next.js.map
27
+ export {
28
+ loadI18next as default
29
+ };