@prosopo/locale 3.2.7 → 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.
- package/.turbo/turbo-build$colon$cjs.log +20 -20
- package/.turbo/turbo-build$colon$tsc.log +5 -5
- package/.turbo/turbo-build.log +22 -19
- package/CHANGELOG.md +6 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/i18SharedOptions.cjs +8 -10
- package/dist/cjs/i18nBackend.cjs +29 -29
- package/dist/cjs/i18nFrontend.cjs +54 -61
- package/dist/cjs/i18nMiddleware.cjs +7 -6
- package/dist/cjs/index.cjs +13 -14
- package/dist/cjs/loadI18next.cjs +23 -33
- package/dist/cjs/locales/en/translation.cjs +487 -0
- package/dist/cjs/translationKey.cjs +14 -22
- package/dist/cjs/translations.cjs +39 -39
- package/dist/cjs/useTranslation.cjs +10 -6
- package/dist/cjs/util.cjs +6 -6
- package/dist/i18SharedOptions.js +9 -11
- package/dist/i18nBackend.js +25 -28
- package/dist/i18nFrontend.js +45 -57
- package/dist/i18nMiddleware.d.ts +2 -1
- package/dist/i18nMiddleware.d.ts.map +1 -1
- package/dist/i18nMiddleware.js +5 -6
- package/dist/i18nMiddleware.js.map +1 -1
- package/dist/index.js +5 -12
- package/dist/loadI18next.js +23 -34
- package/dist/locales/en/translation.js +473 -0
- package/dist/translationKey.js +15 -23
- package/dist/translations.js +37 -40
- package/dist/useTranslation.js +10 -8
- package/dist/util.js +7 -8
- package/package.json +6 -6
- package/src/i18nMiddleware.ts +6 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-typecheck.log +0 -4
- package/dist/cjs/locales/en/translation.json.cjs +0 -47
- package/dist/locales/en/translation.json.js +0 -47
package/dist/i18nBackend.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { isServerSide } from "./util.js";
|
|
3
|
+
import { i18nSharedOptions } from "./i18SharedOptions.js";
|
|
4
|
+
import { LanguageDetector } from "i18next-http-middleware";
|
|
2
5
|
import i18n from "i18next";
|
|
6
|
+
import path from "node:path";
|
|
3
7
|
import FSBackend from "i18next-fs-backend/cjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { isServerSide } from "./util.js";
|
|
7
|
-
const loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace(
|
|
8
|
-
"file://",
|
|
9
|
-
""
|
|
10
|
-
);
|
|
8
|
+
//#region src/i18nBackend.ts
|
|
9
|
+
var loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace("file://", "");
|
|
11
10
|
function initializeI18n(i18nLoadedCallback) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
if (!i18n.isInitialized && isServerSide()) {
|
|
12
|
+
const lngDetector = new LanguageDetector(null, { order: [
|
|
13
|
+
"header",
|
|
14
|
+
"query",
|
|
15
|
+
"cookie"
|
|
16
|
+
] });
|
|
17
|
+
i18n.use(FSBackend).use(lngDetector).init({
|
|
18
|
+
...i18nSharedOptions,
|
|
19
|
+
ns: ["translation"],
|
|
20
|
+
backend: { loadPath }
|
|
21
|
+
});
|
|
22
|
+
i18n.on("loaded", () => {
|
|
23
|
+
i18nLoadedCallback?.(i18n);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return i18n;
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
initializeI18n
|
|
32
|
-
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { initializeI18n as default, initializeI18n };
|
package/dist/i18nFrontend.js
CHANGED
|
@@ -1,66 +1,54 @@
|
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { i18nSharedOptions } from "./i18SharedOptions.js";
|
|
3
|
+
import { initReactI18next } from "react-i18next";
|
|
1
4
|
import i18n from "i18next";
|
|
2
5
|
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
|
|
3
6
|
import ChainedBackend from "i18next-chained-backend";
|
|
4
7
|
import HttpBackend from "i18next-http-backend";
|
|
5
8
|
import resourcesToBackend from "i18next-resources-to-backend";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
//#region src/i18nFrontend.ts
|
|
10
|
+
var reactOptions = {
|
|
11
|
+
react: { useSuspense: true },
|
|
12
|
+
detection: {
|
|
13
|
+
order: [
|
|
14
|
+
"navigator",
|
|
15
|
+
"htmlTag",
|
|
16
|
+
"path",
|
|
17
|
+
"subdomain"
|
|
18
|
+
],
|
|
19
|
+
caches: ["localStorage", "cookie"]
|
|
20
|
+
}
|
|
16
21
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
var getLoadPath = (language, namespace) => {
|
|
23
|
+
const filename = import.meta.url.split("/").pop();
|
|
24
|
+
return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
|
|
20
25
|
};
|
|
21
26
|
function initializeI18n(i18nLoadedCallback, lng) {
|
|
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
|
-
backendOptions: [
|
|
50
|
-
{
|
|
51
|
-
loadPath: getLoadPath("{{lng}}", "{{ns}}")
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
...reactOptions
|
|
56
|
-
});
|
|
57
|
-
i18n.on("loaded", () => {
|
|
58
|
-
i18nLoadedCallback?.(i18n);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return i18n;
|
|
27
|
+
if (!i18n.isInitialized) {
|
|
28
|
+
i18n.use(ChainedBackend).use(new I18nextBrowserLanguageDetector(null, {
|
|
29
|
+
order: [
|
|
30
|
+
"cookie",
|
|
31
|
+
"localStorage",
|
|
32
|
+
"navigator"
|
|
33
|
+
],
|
|
34
|
+
lookupQuerystring: "lng",
|
|
35
|
+
lookupCookie: "i18next",
|
|
36
|
+
lookupLocalStorage: "i18nextLng",
|
|
37
|
+
caches: ["localStorage", "cookie"]
|
|
38
|
+
})).use(initReactI18next).init({
|
|
39
|
+
...i18nSharedOptions,
|
|
40
|
+
...lng ? { lng } : {},
|
|
41
|
+
backend: {
|
|
42
|
+
backends: [HttpBackend, resourcesToBackend((language, namespace) => import(getLoadPath(language, namespace)))],
|
|
43
|
+
backendOptions: [{ loadPath: getLoadPath("{{lng}}", "{{ns}}") }]
|
|
44
|
+
},
|
|
45
|
+
...reactOptions
|
|
46
|
+
});
|
|
47
|
+
i18n.on("loaded", () => {
|
|
48
|
+
i18nLoadedCallback?.(i18n);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return i18n;
|
|
62
52
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
initializeI18n
|
|
66
|
-
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { initializeI18n as default, initializeI18n };
|
package/dist/i18nMiddleware.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handle } from "i18next-http-middleware";
|
|
2
|
+
type HandleOptions = NonNullable<Parameters<typeof handle>[1]>;
|
|
2
3
|
declare function i18nMiddleware(options: HandleOptions): Promise<ReturnType<typeof handle>>;
|
|
3
4
|
export default i18nMiddleware;
|
|
4
5
|
//# sourceMappingURL=i18nMiddleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nMiddleware.d.ts","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"i18nMiddleware.d.ts","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAMjD,KAAK,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,iBAAe,cAAc,CAC5B,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAGpC;AAED,eAAe,cAAc,CAAC"}
|
package/dist/i18nMiddleware.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { handle } from "i18next-http-middleware";
|
|
2
1
|
import loadI18next from "./loadI18next.js";
|
|
2
|
+
import { handle } from "i18next-http-middleware";
|
|
3
|
+
//#region src/i18nMiddleware.ts
|
|
3
4
|
async function i18nMiddleware(options) {
|
|
4
|
-
|
|
5
|
-
return handle(i18n, { ...options });
|
|
5
|
+
return handle(await loadI18next(true), { ...options });
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { i18nMiddleware as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nMiddleware.js","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,
|
|
1
|
+
{"version":3,"file":"i18nMiddleware.js","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAO3C,KAAK,UAAU,cAAc,CAC5B,OAAsB;IAEtB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,eAAe,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import loadI18next from "./loadI18next.js";
|
|
3
|
+
import i18nMiddleware from "./i18nMiddleware.js";
|
|
3
4
|
import { LanguageSchema, Languages } from "./translations.js";
|
|
4
5
|
import { isClientSide } from "./util.js";
|
|
5
6
|
import { TranslationKeysSchema } from "./translationKey.js";
|
|
6
|
-
import
|
|
7
|
-
export {
|
|
8
|
-
LanguageSchema,
|
|
9
|
-
Languages,
|
|
10
|
-
TranslationKeysSchema,
|
|
11
|
-
default2 as i18nMiddleware,
|
|
12
|
-
isClientSide,
|
|
13
|
-
default3 as loadI18next,
|
|
14
|
-
default4 as useTranslation
|
|
15
|
-
};
|
|
7
|
+
import useTranslation from "./useTranslation.js";
|
|
8
|
+
export { LanguageSchema, Languages, TranslationKeysSchema, i18nMiddleware, isClientSide, loadI18next, useTranslation };
|
package/dist/loadI18next.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return instance;
|
|
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;
|
|
7
6
|
};
|
|
8
7
|
async function loadI18next(backend, lng) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} else {
|
|
26
|
-
void reconcileLanguage(i18nInstance, lng).then(resolve);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
} catch (e) {
|
|
31
|
-
reject(e);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
try {
|
|
10
|
+
if (backend) import("./i18nBackend.js").then(({ default: initializeI18n }) => {
|
|
11
|
+
if (!i18nInstance) i18nInstance = initializeI18n(resolve);
|
|
12
|
+
else resolve(i18nInstance);
|
|
13
|
+
});
|
|
14
|
+
else import("./i18nFrontend.js").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
|
+
});
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { loadI18next as default };
|