@prosopo/locale 2.3.2 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/i18nBackend.d.ts +3 -0
- package/dist/i18nBackend.d.ts.map +1 -0
- package/dist/i18nBackend.js +30 -0
- package/dist/i18nBackend.js.map +1 -0
- package/dist/i18nFrontend.d.ts +3 -0
- package/dist/i18nFrontend.d.ts.map +1 -0
- package/dist/i18nFrontend.js +49 -0
- package/dist/i18nFrontend.js.map +1 -0
- package/dist/i18nMiddleware.d.ts +4 -0
- package/dist/i18nMiddleware.d.ts.map +1 -0
- package/dist/i18nMiddleware.js +8 -0
- package/dist/i18nMiddleware.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/loadI18next.d.ts +5 -0
- package/dist/loadI18next.d.ts.map +1 -0
- package/dist/loadI18next.js +21 -0
- package/dist/loadI18next.js.map +1 -0
- package/dist/locales/{de.json → de/translation.json} +2 -13
- package/dist/locales/{en.json → en/translation.json} +2 -13
- package/dist/locales/{es.json → es/translation.json} +2 -13
- package/dist/locales/{fr.json → fr/translation.json} +2 -13
- package/dist/locales/{it.json → it/translation.json} +2 -13
- package/dist/locales/{pt.json → pt/translation.json} +2 -13
- package/dist/locales/{pt-BR.json → pt-BR/translation.json} +2 -13
- package/dist/tests/locales.unit.test.js +1 -1
- package/dist/tests/locales.unit.test.js.map +1 -1
- package/dist/translationKey.d.ts +4 -0
- package/dist/translationKey.d.ts.map +1 -0
- package/dist/translationKey.js +21 -0
- package/dist/translationKey.js.map +1 -0
- package/dist/translations.d.ts +0 -2928
- package/dist/translations.d.ts.map +1 -1
- package/dist/translations.js +0 -16
- package/dist/translations.js.map +1 -1
- package/dist/useTranslation.d.ts +7 -0
- package/dist/useTranslation.d.ts.map +1 -0
- package/dist/useTranslation.js +8 -0
- package/dist/useTranslation.js.map +1 -0
- package/dist/util.d.ts +2 -4
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +5 -20
- package/dist/util.js.map +1 -1
- package/package.json +10 -6
- package/vite.cjs.config.ts +1 -1
- package/vite.test.config.ts +1 -1
- package/dist/node/i18nBackend.d.ts +0 -3
- package/dist/node/i18nBackend.d.ts.map +0 -1
- package/dist/node/i18nBackend.js +0 -16
- package/dist/node/i18nBackend.js.map +0 -1
- package/dist/node/i18nMiddleware.d.ts +0 -4
- package/dist/node/i18nMiddleware.d.ts.map +0 -1
- package/dist/node/i18nMiddleware.js +0 -7
- package/dist/node/i18nMiddleware.js.map +0 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js +0 -2
- package/dist/node/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"AAcA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,SAAS,wDAAyD,CAAC;AAEhF,eAAO,MAAM,cAAc,0DAAoB,CAAC"}
|
package/dist/translations.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import translationsDe from "./locales/de.json" with { type: "json" };
|
|
3
|
-
import translationsEn from "./locales/en.json" with { type: "json" };
|
|
4
|
-
import translationsEs from "./locales/es.json" with { type: "json" };
|
|
5
|
-
import translationsFr from "./locales/fr.json" with { type: "json" };
|
|
6
|
-
import translationsIt from "./locales/it.json" with { type: "json" };
|
|
7
|
-
import translationsPtBR from "./locales/pt-BR.json" with { type: "json" };
|
|
8
|
-
import translationsPt from "./locales/pt.json" with { type: "json" };
|
|
9
2
|
export const Languages = ["de", "en", "es", "fr", "it", "pt", "pt-BR"];
|
|
10
3
|
export const LanguageSchema = z.enum(Languages);
|
|
11
|
-
export const translations = {
|
|
12
|
-
[LanguageSchema.enum.de]: { translation: translationsDe },
|
|
13
|
-
[LanguageSchema.enum.en]: { translation: translationsEn },
|
|
14
|
-
[LanguageSchema.enum.es]: { translation: translationsEs },
|
|
15
|
-
[LanguageSchema.enum.fr]: { translation: translationsFr },
|
|
16
|
-
[LanguageSchema.enum.it]: { translation: translationsIt },
|
|
17
|
-
[LanguageSchema.enum.pt]: { translation: translationsPt },
|
|
18
|
-
[LanguageSchema.enum["pt-BR"]]: { translation: translationsPtBR },
|
|
19
|
-
};
|
|
20
4
|
//# sourceMappingURL=translations.js.map
|
package/dist/translations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.js","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.js","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"AAcA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAU,CAAC;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type UseTranslationOptions, type UseTranslationResponse } from "react-i18next";
|
|
2
|
+
import initializeI18n from "./i18nFrontend.js";
|
|
3
|
+
declare function useTranslation(options?: UseTranslationOptions<"translation">): UseTranslationResponse<"translation", any> & {
|
|
4
|
+
t: ReturnType<typeof initializeI18n>["t"];
|
|
5
|
+
};
|
|
6
|
+
export default useTranslation;
|
|
7
|
+
//# sourceMappingURL=useTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../src/useTranslation.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE3B,MAAM,eAAe,CAAC;AACvB,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,iBAAS,cAAc,CACtB,OAAO,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,GAE5C,sBAAsB,CAAC,aAAa,EAAE,GAAG,CAAC,GAAG;IAC/C,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;CAC1C,CAGA;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useTranslation as useTranslationDefault, } from "react-i18next";
|
|
2
|
+
import initializeI18n from "./i18nFrontend.js";
|
|
3
|
+
function useTranslation(options) {
|
|
4
|
+
const i18n = initializeI18n();
|
|
5
|
+
return useTranslationDefault("translation", { i18n, ...options });
|
|
6
|
+
}
|
|
7
|
+
export default useTranslation;
|
|
8
|
+
//# sourceMappingURL=useTranslation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.js","sourceRoot":"","sources":["../src/useTranslation.ts"],"names":[],"mappings":"AAcA,OAAO,EAGN,cAAc,IAAI,qBAAqB,GACvC,MAAM,eAAe,CAAC;AACvB,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,SAAS,cAAc,CACtB,OAA8C;IAK9C,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,OAAO,qBAAqB,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,eAAe,cAAc,CAAC"}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
export declare const TranslationKeysSchema: z.ZodEnum<[string, ...string[]]>;
|
|
4
|
-
export type TranslationKey = z.infer<typeof TranslationKeysSchema>;
|
|
1
|
+
export declare const isClientSide: () => boolean;
|
|
2
|
+
export declare const isServerSide: () => boolean;
|
|
5
3
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAcA,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,YAAY,QAAO,OAM/B,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,OAE/B,CAAC"}
|
package/dist/util.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import translationEn from "./locales/en.json" with { type: "json" };
|
|
3
|
-
export function isClientSide() {
|
|
1
|
+
export const isClientSide = () => {
|
|
4
2
|
return !!(typeof window !== "undefined" &&
|
|
5
3
|
window.document &&
|
|
6
4
|
window.document.createElement);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return Object.keys(obj).reduce((arr, key) => {
|
|
13
|
-
const value = obj[key];
|
|
14
|
-
if (value === undefined) {
|
|
15
|
-
throw new Error(`Undefined value for key ${key}`);
|
|
16
|
-
}
|
|
17
|
-
const children = getLeafFieldPath(value);
|
|
18
|
-
return arr.concat(children.map((child) => {
|
|
19
|
-
return `${key}.${child}`;
|
|
20
|
-
}));
|
|
21
|
-
}, []);
|
|
22
|
-
}
|
|
23
|
-
export const TranslationKeysSchema = z.enum(getLeafFieldPath(translationEn));
|
|
5
|
+
};
|
|
6
|
+
export const isServerSide = () => {
|
|
7
|
+
return !isClientSide();
|
|
8
|
+
};
|
|
24
9
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAcA,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,YAAY,GAAG,GAAY,EAAE;IACzC,OAAO,CAAC,CAAC,CACR,OAAO,MAAM,KAAK,WAAW;QAC7B,MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,QAAQ,CAAC,aAAa,CAC7B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAY,EAAE;IACzC,OAAO,CAAC,YAAY,EAAE,CAAC;AACxB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/locale",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Prosopo locale library",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,14 +24,18 @@
|
|
|
24
24
|
"author": "Prosopo Limited",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"i18next": "
|
|
29
|
-
"i18next-
|
|
30
|
-
"i18next-
|
|
27
|
+
"i18next": "24.2.2",
|
|
28
|
+
"i18next-browser-languagedetector": "8.0.2",
|
|
29
|
+
"i18next-chained-backend": "4.6.2",
|
|
30
|
+
"i18next-fs-backend": "2.6.0",
|
|
31
|
+
"i18next-http-backend": "3.0.2",
|
|
32
|
+
"i18next-http-middleware": "3.7.1",
|
|
33
|
+
"i18next-resources-to-backend": "1.2.1",
|
|
34
|
+
"react-i18next": "15.4.0",
|
|
31
35
|
"zod": "3.23.8"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
|
-
"@prosopo/config": "2.
|
|
38
|
+
"@prosopo/config": "2.4.2",
|
|
35
39
|
"@vitest/coverage-v8": "2.1.1",
|
|
36
40
|
"del-cli": "6.0.0",
|
|
37
41
|
"dotenv": "16.4.5",
|
package/vite.cjs.config.ts
CHANGED
package/vite.test.config.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18nBackend.d.ts","sourceRoot":"","sources":["../../src/node/i18nBackend.ts"],"names":[],"mappings":"AAcA,OAAO,IAA0B,MAAM,SAAS,CAAC;AAkBjD,eAAe,IAAI,CAAC"}
|
package/dist/node/i18nBackend.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import i18n from "i18next";
|
|
2
|
-
import Backend from "i18next-http-backend";
|
|
3
|
-
import { LanguageDetector as MiddlewareLanguageDetector } from "i18next-http-middleware";
|
|
4
|
-
import { translations as resources } from "../translations.js";
|
|
5
|
-
const commonOptions = {
|
|
6
|
-
debug: false,
|
|
7
|
-
fallbackLng: "en",
|
|
8
|
-
resources,
|
|
9
|
-
};
|
|
10
|
-
const nodeOptions = {};
|
|
11
|
-
i18n
|
|
12
|
-
.use(new Backend(undefined, { reloadInterval: false }))
|
|
13
|
-
.use(MiddlewareLanguageDetector)
|
|
14
|
-
.init({ ...commonOptions, ...nodeOptions });
|
|
15
|
-
export default i18n;
|
|
16
|
-
//# sourceMappingURL=i18nBackend.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18nBackend.js","sourceRoot":"","sources":["../../src/node/i18nBackend.ts"],"names":[],"mappings":"AAcA,OAAO,IAA0B,MAAM,SAAS,CAAC;AACjD,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,IAAI,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,aAAa,GAAgB;IAClC,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,IAAI;IACjB,SAAS;CACT,CAAC;AAEF,MAAM,WAAW,GAAgB,EAAE,CAAC;AAEpC,IAAI;KACF,GAAG,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;KACtD,GAAG,CAAC,0BAA0B,CAAC;KAC/B,IAAI,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;AAE7C,eAAe,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18nMiddleware.d.ts","sourceRoot":"","sources":["../../src/node/i18nMiddleware.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAIrE,iBAAS,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAGzE;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18nMiddleware.js","sourceRoot":"","sources":["../../src/node/i18nMiddleware.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,SAAS,cAAc,CAAC,OAAsB;IAE7C,OAAO,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,eAAe,cAAc,CAAC"}
|
package/dist/node/index.d.ts
DELETED
package/dist/node/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/node/index.js
DELETED
package/dist/node/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|