@prosopo/locale 3.1.21 → 3.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/i18SharedOptions.js +10 -8
- package/dist/i18nBackend.js +26 -24
- package/dist/i18nFrontend.js +47 -43
- package/dist/i18nMiddleware.js +5 -4
- package/dist/index.js +15 -7
- package/dist/loadI18next.js +26 -29
- package/dist/locales/ar/translation.json +441 -441
- package/dist/locales/az/translation.json +441 -441
- package/dist/locales/cs/translation.json +441 -441
- package/dist/locales/de/translation.json +441 -441
- package/dist/locales/el/translation.json +441 -441
- package/dist/locales/en/translation.json +441 -441
- package/dist/locales/es/translation.json +441 -441
- package/dist/locales/fi/translation.json +441 -441
- package/dist/locales/fr/translation.json +441 -441
- package/dist/locales/hi/translation.json +441 -441
- package/dist/locales/hu/translation.json +441 -441
- package/dist/locales/id/translation.json +441 -441
- package/dist/locales/it/translation.json +441 -441
- package/dist/locales/ja/translation.json +441 -441
- package/dist/locales/jv/translation.json +441 -441
- package/dist/locales/ko/translation.json +441 -441
- package/dist/locales/ml/translation.json +441 -441
- package/dist/locales/ms/translation.json +441 -441
- package/dist/locales/nl/translation.json +441 -441
- package/dist/locales/no/translation.json +441 -441
- package/dist/locales/pl/translation.json +441 -441
- package/dist/locales/pt/translation.json +441 -441
- package/dist/locales/pt-BR/translation.json +441 -441
- package/dist/locales/ro/translation.json +441 -441
- package/dist/locales/ru/translation.json +441 -441
- package/dist/locales/sr/translation.json +441 -441
- package/dist/locales/sv/translation.json +441 -441
- package/dist/locales/th/translation.json +441 -441
- package/dist/locales/tr/translation.json +441 -441
- package/dist/locales/uk/translation.json +441 -441
- package/dist/locales/vi/translation.json +441 -441
- package/dist/locales/zh-CN/translation.json +441 -441
- package/dist/translationKey.js +21 -15
- package/dist/translations.js +40 -35
- package/dist/useTranslation.js +7 -6
- package/dist/util.js +8 -7
- package/package.json +4 -4
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -260
- package/coverage/coverage-final.json +0 -11
- package/coverage/favicon.png +0 -0
- package/coverage/i18SharedOptions.ts.html +0 -151
- package/coverage/i18nBackend.ts.html +0 -244
- package/coverage/i18nFrontend.ts.html +0 -328
- package/coverage/i18nMiddleware.ts.html +0 -160
- package/coverage/index.html +0 -251
- package/coverage/index.ts.html +0 -151
- package/coverage/loadI18next.ts.html +0 -232
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/translationKey.ts.html +0 -229
- package/coverage/translations.ts.html +0 -247
- package/coverage/useTranslation.ts.html +0 -181
- package/coverage/util.ts.html +0 -160
- package/dist/i18SharedOptions.js.map +0 -1
- package/dist/i18nBackend.js.map +0 -1
- package/dist/i18nFrontend.js.map +0 -1
- package/dist/i18nMiddleware.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/loadI18next.js.map +0 -1
- package/dist/tests/locales.unit.test.js +0 -49
- package/dist/tests/locales.unit.test.js.map +0 -1
- package/dist/translationKey.js.map +0 -1
- package/dist/translations.js.map +0 -1
- package/dist/useTranslation.js.map +0 -1
- package/dist/util.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @prosopo/locale
|
|
2
2
|
|
|
3
|
+
## 3.1.25
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- 93d92a7: little bump for publish all
|
|
7
|
+
|
|
8
|
+
## 3.1.24
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 8ee8434: bump node engines to 24 and npm version to 11
|
|
12
|
+
- cfee479: make @prosopo/config a dev dep
|
|
13
|
+
|
|
14
|
+
## 3.1.23
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- e926831: mega mini bump for all to trigger publish all
|
|
18
|
+
- Updated dependencies [e926831]
|
|
19
|
+
- @prosopo/config@3.1.23
|
|
20
|
+
|
|
21
|
+
## 3.1.22
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 8ce9205: Change engine requirements
|
|
25
|
+
- b6e98b2: Run npm audit
|
|
26
|
+
- Updated dependencies [8ce9205]
|
|
27
|
+
- Updated dependencies [df79c03]
|
|
28
|
+
- Updated dependencies [b6e98b2]
|
|
29
|
+
- @prosopo/config@3.1.22
|
|
30
|
+
|
|
3
31
|
## 3.1.21
|
|
4
32
|
### Patch Changes
|
|
5
33
|
|
package/dist/i18SharedOptions.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
package/dist/i18nBackend.js
CHANGED
|
@@ -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
|
|
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(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
30
|
-
|
|
29
|
+
export {
|
|
30
|
+
initializeI18n as default,
|
|
31
|
+
initializeI18n
|
|
32
|
+
};
|
package/dist/i18nFrontend.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
18
|
+
const filename = import.meta.url.split("/").pop();
|
|
19
|
+
return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
55
|
-
|
|
56
|
+
export {
|
|
57
|
+
initializeI18n as default,
|
|
58
|
+
initializeI18n
|
|
59
|
+
};
|
package/dist/i18nMiddleware.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
4
|
+
const i18n = await loadI18next(true);
|
|
5
|
+
return handle(i18n, { ...options });
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export {
|
|
8
|
+
i18nMiddleware as default
|
|
9
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
};
|
package/dist/loadI18next.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
let i18nInstance;
|
|
2
2
|
async function loadI18next(backend) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
32
|
-
|
|
27
|
+
export {
|
|
28
|
+
loadI18next as default
|
|
29
|
+
};
|