@bleedingdev/modern-js-plugin-i18n 3.5.0-ultramodern.4 → 3.5.0-ultramodern.41
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/cjs/cli/index.js +2 -1
- package/dist/cjs/cli/locales.js +15 -15
- package/dist/cjs/runtime/Link.js +8 -89
- package/dist/cjs/runtime/context.js +18 -82
- package/dist/cjs/runtime/contextHelpers.js +137 -0
- package/dist/cjs/runtime/core.js +29 -132
- package/dist/cjs/runtime/i18n/backend/defaults.node.js +7 -7
- package/dist/cjs/runtime/i18n/detection/cache.js +150 -0
- package/dist/cjs/runtime/i18n/detection/detector.js +100 -0
- package/dist/cjs/runtime/i18n/detection/index.js +8 -263
- package/dist/cjs/runtime/i18n/detection/initOptions.js +69 -0
- package/dist/cjs/runtime/i18n/detection/language.js +62 -0
- package/dist/cjs/runtime/i18n/detection/path.js +49 -0
- package/dist/cjs/runtime/i18n/detection/priority.js +66 -0
- package/dist/cjs/runtime/i18n/detection/ssr.js +70 -0
- package/dist/cjs/runtime/i18n/detection/types.js +18 -0
- package/dist/cjs/runtime/i18n/instance.js +7 -7
- package/dist/cjs/runtime/linkHelpers.js +148 -0
- package/dist/cjs/runtime/pluginSetup.js +102 -0
- package/dist/cjs/runtime/providerComposition.js +114 -0
- package/dist/cjs/runtime/reactI18next.js +43 -0
- package/dist/cjs/runtime/utils.js +1 -9
- package/dist/cjs/server/apiPrefix.js +72 -0
- package/dist/cjs/server/detectorOptions.js +97 -0
- package/dist/cjs/server/index.js +17 -144
- package/dist/cjs/server/redirectPolicy.js +96 -0
- package/dist/cjs/shared/detection.js +2 -104
- package/dist/cjs/shared/localisedUrls/config.js +49 -0
- package/dist/cjs/shared/localisedUrls/index.js +91 -0
- package/dist/cjs/shared/localisedUrls/normalise.js +87 -0
- package/dist/cjs/shared/localisedUrls/pathname.js +68 -0
- package/dist/cjs/shared/localisedUrls/patterns.js +130 -0
- package/dist/cjs/shared/localisedUrls/redirect.js +95 -0
- package/dist/cjs/shared/localisedUrls/resolve.js +88 -0
- package/dist/cjs/shared/localisedUrls/routes.js +129 -0
- package/dist/cjs/shared/localisedUrls/types.js +18 -0
- package/dist/cjs/shared/localisedUrls.js +28 -294
- package/dist/cjs/shared/utils.js +2 -8
- package/dist/esm/cli/index.mjs +2 -1
- package/dist/esm/cli/locales.mjs +13 -13
- package/dist/esm/runtime/Link.mjs +1 -82
- package/dist/esm/runtime/context.mjs +18 -82
- package/dist/esm/runtime/contextHelpers.mjs +84 -0
- package/dist/esm/runtime/core.mjs +30 -133
- package/dist/esm/runtime/i18n/backend/defaults.node.mjs +5 -5
- package/dist/esm/runtime/i18n/detection/cache.mjs +103 -0
- package/dist/esm/runtime/i18n/detection/detector.mjs +62 -0
- package/dist/esm/runtime/i18n/detection/index.mjs +4 -260
- package/dist/esm/runtime/i18n/detection/initOptions.mjs +28 -0
- package/dist/esm/runtime/i18n/detection/language.mjs +21 -0
- package/dist/esm/runtime/i18n/detection/path.mjs +11 -0
- package/dist/esm/runtime/i18n/detection/priority.mjs +28 -0
- package/dist/esm/runtime/i18n/detection/ssr.mjs +26 -0
- package/dist/esm/runtime/i18n/detection/types.mjs +0 -0
- package/dist/esm/runtime/i18n/instance.mjs +8 -5
- package/dist/esm/runtime/linkHelpers.mjs +98 -0
- package/dist/esm/runtime/pluginSetup.mjs +64 -0
- package/dist/esm/runtime/providerComposition.mjs +76 -0
- package/dist/esm/runtime/reactI18next.mjs +5 -0
- package/dist/esm/runtime/utils.mjs +2 -10
- package/dist/esm/server/apiPrefix.mjs +31 -0
- package/dist/esm/server/detectorOptions.mjs +59 -0
- package/dist/esm/server/index.mjs +8 -135
- package/dist/esm/server/redirectPolicy.mjs +46 -0
- package/dist/esm/shared/detection.mjs +1 -71
- package/dist/esm/shared/localisedUrls/config.mjs +11 -0
- package/dist/esm/shared/localisedUrls/index.mjs +7 -0
- package/dist/esm/shared/localisedUrls/normalise.mjs +37 -0
- package/dist/esm/shared/localisedUrls/pathname.mjs +24 -0
- package/dist/esm/shared/localisedUrls/patterns.mjs +86 -0
- package/dist/esm/shared/localisedUrls/redirect.mjs +48 -0
- package/dist/esm/shared/localisedUrls/resolve.mjs +47 -0
- package/dist/esm/shared/localisedUrls/routes.mjs +88 -0
- package/dist/esm/shared/localisedUrls/types.mjs +0 -0
- package/dist/esm/shared/localisedUrls.mjs +1 -283
- package/dist/esm/shared/utils.mjs +1 -1
- package/dist/esm-node/cli/index.mjs +2 -1
- package/dist/esm-node/cli/locales.mjs +13 -13
- package/dist/esm-node/runtime/Link.mjs +1 -82
- package/dist/esm-node/runtime/context.mjs +18 -82
- package/dist/esm-node/runtime/contextHelpers.mjs +85 -0
- package/dist/esm-node/runtime/core.mjs +30 -133
- package/dist/esm-node/runtime/i18n/backend/defaults.node.mjs +5 -5
- package/dist/esm-node/runtime/i18n/detection/cache.mjs +104 -0
- package/dist/esm-node/runtime/i18n/detection/detector.mjs +63 -0
- package/dist/esm-node/runtime/i18n/detection/index.mjs +4 -260
- package/dist/esm-node/runtime/i18n/detection/initOptions.mjs +29 -0
- package/dist/esm-node/runtime/i18n/detection/language.mjs +22 -0
- package/dist/esm-node/runtime/i18n/detection/path.mjs +12 -0
- package/dist/esm-node/runtime/i18n/detection/priority.mjs +29 -0
- package/dist/esm-node/runtime/i18n/detection/ssr.mjs +27 -0
- package/dist/esm-node/runtime/i18n/detection/types.mjs +1 -0
- package/dist/esm-node/runtime/i18n/instance.mjs +8 -5
- package/dist/esm-node/runtime/linkHelpers.mjs +99 -0
- package/dist/esm-node/runtime/pluginSetup.mjs +65 -0
- package/dist/esm-node/runtime/providerComposition.mjs +77 -0
- package/dist/esm-node/runtime/reactI18next.mjs +6 -0
- package/dist/esm-node/runtime/utils.mjs +2 -10
- package/dist/esm-node/server/apiPrefix.mjs +32 -0
- package/dist/esm-node/server/detectorOptions.mjs +60 -0
- package/dist/esm-node/server/index.mjs +8 -135
- package/dist/esm-node/server/redirectPolicy.mjs +47 -0
- package/dist/esm-node/shared/detection.mjs +1 -71
- package/dist/esm-node/shared/localisedUrls/config.mjs +12 -0
- package/dist/esm-node/shared/localisedUrls/index.mjs +8 -0
- package/dist/esm-node/shared/localisedUrls/normalise.mjs +38 -0
- package/dist/esm-node/shared/localisedUrls/pathname.mjs +25 -0
- package/dist/esm-node/shared/localisedUrls/patterns.mjs +87 -0
- package/dist/esm-node/shared/localisedUrls/redirect.mjs +49 -0
- package/dist/esm-node/shared/localisedUrls/resolve.mjs +48 -0
- package/dist/esm-node/shared/localisedUrls/routes.mjs +89 -0
- package/dist/esm-node/shared/localisedUrls/types.mjs +1 -0
- package/dist/esm-node/shared/localisedUrls.mjs +1 -283
- package/dist/esm-node/shared/utils.mjs +1 -1
- package/dist/types/cli/locales.d.ts +1 -1
- package/dist/types/runtime/Link.d.ts +3 -7
- package/dist/types/runtime/context.d.ts +6 -5
- package/dist/types/runtime/contextHelpers.d.ts +28 -0
- package/dist/types/runtime/core.d.ts +3 -7
- package/dist/types/runtime/hooks.d.ts +5 -0
- package/dist/types/runtime/i18n/backend/middleware.common.d.ts +2 -1
- package/dist/types/runtime/i18n/detection/cache.d.ts +14 -0
- package/dist/types/runtime/i18n/detection/detector.d.ts +8 -0
- package/dist/types/runtime/i18n/detection/index.d.ts +5 -50
- package/dist/types/runtime/i18n/detection/initOptions.d.ts +10 -0
- package/dist/types/runtime/i18n/detection/language.d.ts +11 -0
- package/dist/types/runtime/i18n/detection/middleware.d.ts +4 -4
- package/dist/types/runtime/i18n/detection/middleware.node.d.ts +4 -4
- package/dist/types/runtime/i18n/detection/path.d.ts +5 -0
- package/dist/types/runtime/i18n/detection/priority.d.ts +10 -0
- package/dist/types/runtime/i18n/detection/ssr.d.ts +9 -0
- package/dist/types/runtime/i18n/detection/types.d.ts +32 -0
- package/dist/types/runtime/i18n/instance.d.ts +28 -26
- package/dist/types/runtime/i18n/react-i18next.d.ts +1 -6
- package/dist/types/runtime/i18n/utils.d.ts +14 -5
- package/dist/types/runtime/linkHelpers.d.ts +17 -0
- package/dist/types/runtime/pluginSetup.d.ts +32 -0
- package/dist/types/runtime/providerComposition.d.ts +16 -0
- package/dist/types/runtime/reactI18next.d.ts +7 -0
- package/dist/types/runtime/routerAdapter.d.ts +7 -6
- package/dist/types/runtime/utils.d.ts +7 -2
- package/dist/types/server/apiPrefix.d.ts +7 -0
- package/dist/types/server/detectorOptions.d.ts +21 -0
- package/dist/types/server/index.d.ts +1 -6
- package/dist/types/server/redirectPolicy.d.ts +22 -0
- package/dist/types/shared/detection.d.ts +1 -11
- package/dist/types/shared/localisedUrls/config.d.ts +9 -0
- package/dist/types/shared/localisedUrls/index.d.ts +9 -0
- package/dist/types/shared/localisedUrls/normalise.d.ts +10 -0
- package/dist/types/shared/localisedUrls/pathname.d.ts +4 -0
- package/dist/types/shared/localisedUrls/patterns.d.ts +5 -0
- package/dist/types/shared/localisedUrls/redirect.d.ts +11 -0
- package/dist/types/shared/localisedUrls/resolve.d.ts +7 -0
- package/dist/types/shared/localisedUrls/routes.d.ts +3 -0
- package/dist/types/shared/localisedUrls/types.d.ts +14 -0
- package/dist/types/shared/localisedUrls.d.ts +2 -36
- package/dist/types/shared/utils.d.ts +0 -2
- package/package.json +16 -18
- package/rstest.config.mts +1 -0
- package/src/cli/index.ts +5 -4
- package/src/cli/locales.ts +3 -3
- package/src/runtime/Link.tsx +11 -138
- package/src/runtime/context.tsx +45 -199
- package/src/runtime/contextHelpers.ts +232 -0
- package/src/runtime/core.tsx +43 -274
- package/src/runtime/hooks.ts +13 -2
- package/src/runtime/i18n/backend/defaults.node.ts +2 -2
- package/src/runtime/i18n/backend/middleware.common.ts +5 -4
- package/src/runtime/i18n/detection/cache.ts +189 -0
- package/src/runtime/i18n/detection/detector.ts +166 -0
- package/src/runtime/i18n/detection/index.ts +10 -641
- package/src/runtime/i18n/detection/initOptions.ts +74 -0
- package/src/runtime/i18n/detection/language.ts +64 -0
- package/src/runtime/i18n/detection/middleware.node.ts +26 -7
- package/src/runtime/i18n/detection/middleware.ts +15 -7
- package/src/runtime/i18n/detection/path.ts +41 -0
- package/src/runtime/i18n/detection/priority.ts +82 -0
- package/src/runtime/i18n/detection/ssr.ts +47 -0
- package/src/runtime/i18n/detection/types.ts +41 -0
- package/src/runtime/i18n/instance.ts +56 -31
- package/src/runtime/i18n/react-i18next.ts +1 -6
- package/src/runtime/i18n/utils.ts +18 -9
- package/src/runtime/linkHelpers.ts +174 -0
- package/src/runtime/pluginSetup.ts +189 -0
- package/src/runtime/providerComposition.tsx +144 -0
- package/src/runtime/reactI18next.ts +20 -0
- package/src/runtime/routerAdapter.tsx +6 -6
- package/src/runtime/utils.ts +13 -35
- package/src/server/apiPrefix.ts +67 -0
- package/src/server/detectorOptions.ts +105 -0
- package/src/server/index.ts +14 -319
- package/src/server/redirectPolicy.ts +127 -0
- package/src/shared/detection.ts +1 -1
- package/src/shared/localisedUrls/config.ts +18 -0
- package/src/shared/localisedUrls/index.ts +24 -0
- package/src/shared/localisedUrls/normalise.ts +67 -0
- package/src/shared/localisedUrls/pathname.ts +60 -0
- package/src/shared/localisedUrls/patterns.ts +160 -0
- package/src/shared/localisedUrls/redirect.ts +91 -0
- package/src/shared/localisedUrls/resolve.ts +135 -0
- package/src/shared/localisedUrls/routes.ts +226 -0
- package/src/shared/localisedUrls/types.ts +18 -0
- package/src/shared/localisedUrls.ts +26 -623
- package/src/shared/utils.ts +2 -2
- package/tests/fixtures/localised-routes.golden.json +156 -0
- package/tests/link.test.tsx +111 -0
- package/tests/linkTypes.test.ts +15 -4
- package/tests/localisedUrlRewriteMatrix.fork.test.ts +147 -0
- package/tests/localisedUrls.test.ts +129 -2
- package/tests/reactI18nextRuntimeBoundary.test.ts +6 -3
- package/tests/redirectPolicy.test.ts +43 -0
- package/tests/routerAdapter.test.tsx +85 -0
- package/tests/type-fixture/fixture-globals.d.ts +11 -0
- package/tests/type-fixture/tsconfig.json +1 -0
package/dist/cjs/cli/index.js
CHANGED
|
@@ -64,7 +64,8 @@ const i18nPlugin = (options = {})=>({
|
|
|
64
64
|
backend: backendOptions,
|
|
65
65
|
...extendedConfig
|
|
66
66
|
};
|
|
67
|
-
const
|
|
67
|
+
const { reactI18next } = extendedConfig;
|
|
68
|
+
const runtimePluginPath = customPlugin?.runtime?.path || (false === reactI18next ? `@${metaName}/plugin-i18n/runtime/no-react-i18next` : `@${metaName}/plugin-i18n/runtime`);
|
|
68
69
|
plugins.push({
|
|
69
70
|
name: customPlugin?.runtime?.name || 'i18n',
|
|
70
71
|
path: runtimePluginPath,
|
package/dist/cjs/cli/locales.js
CHANGED
|
@@ -40,19 +40,19 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
applyDetectedBackendPaths: ()=>applyDetectedBackendPaths,
|
|
41
41
|
detectLocalesDirectory: ()=>detectLocalesDirectory
|
|
42
42
|
});
|
|
43
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
44
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
45
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
46
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
43
47
|
const server_core_namespaceObject = require("@modern-js/server-core");
|
|
44
|
-
const external_fs_namespaceObject = require("fs");
|
|
45
|
-
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
46
|
-
const external_path_namespaceObject = require("path");
|
|
47
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
48
48
|
const LOCALES_RESOURCE_PATTERN = '{{lng}}/{{ns}}.json';
|
|
49
49
|
function hasJsonFiles(dirPath) {
|
|
50
50
|
try {
|
|
51
|
-
if (!
|
|
52
|
-
const entries =
|
|
51
|
+
if (!external_node_fs_default().existsSync(dirPath) || !external_node_fs_default().statSync(dirPath).isDirectory()) return false;
|
|
52
|
+
const entries = external_node_fs_default().readdirSync(dirPath);
|
|
53
53
|
for (const entry of entries){
|
|
54
|
-
const entryPath =
|
|
55
|
-
const stat =
|
|
54
|
+
const entryPath = external_node_path_default().join(dirPath, entry);
|
|
55
|
+
const stat = external_node_fs_default().statSync(entryPath);
|
|
56
56
|
if (stat.isFile() && entry.endsWith('.json')) return true;
|
|
57
57
|
if (stat.isDirectory() && hasJsonFiles(entryPath)) return true;
|
|
58
58
|
}
|
|
@@ -62,7 +62,7 @@ function hasJsonFiles(dirPath) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function toPosixPath(filePath) {
|
|
65
|
-
return filePath.split(
|
|
65
|
+
return filePath.split(external_node_path_default().sep).join(external_node_path_default().posix.sep);
|
|
66
66
|
}
|
|
67
67
|
function getPublicDirOutputPath(publicDir) {
|
|
68
68
|
return (0, server_core_namespaceObject.normalizePublicDirPath)(publicDir);
|
|
@@ -89,20 +89,20 @@ function detectLocalesDirectory(appDirectory, normalizedConfig) {
|
|
|
89
89
|
const publicDirPrefixes = (0, server_core_namespaceObject.getPublicDirRoutePrefixes)(normalizedConfig?.server?.publicDir);
|
|
90
90
|
for(let index = 0; index < publicDirs.length; index++){
|
|
91
91
|
const publicDir = publicDirs[index];
|
|
92
|
-
if (
|
|
93
|
-
const publicDirPath =
|
|
92
|
+
if (external_node_path_default().isAbsolute(publicDir)) continue;
|
|
93
|
+
const publicDirPath = external_node_path_default().join(appDirectory, publicDir);
|
|
94
94
|
const publicDirPrefix = publicDirPrefixes[index] || `/${(0, server_core_namespaceObject.normalizePublicDirPath)(publicDir)}`;
|
|
95
95
|
const publicDirOutputPath = getPublicDirOutputPath(publicDir);
|
|
96
|
-
if ('locales' ===
|
|
97
|
-
const localesPath =
|
|
96
|
+
if ('locales' === external_node_path_default().basename((0, server_core_namespaceObject.normalizePublicDirPath)(publicDir)) && hasJsonFiles(publicDirPath)) return buildDetectedLocalesDirectory(publicDirPrefix, `./${publicDirOutputPath}`);
|
|
97
|
+
const localesPath = external_node_path_default().join(publicDirPath, 'locales');
|
|
98
98
|
if (hasJsonFiles(localesPath)) return buildDetectedLocalesDirectory(`${publicDirPrefix}/locales`, `./${publicDirOutputPath}/locales`);
|
|
99
99
|
}
|
|
100
|
-
const configPublicPath =
|
|
100
|
+
const configPublicPath = external_node_path_default().join(appDirectory, 'config', 'public', 'locales');
|
|
101
101
|
if (hasJsonFiles(configPublicPath)) return buildDetectedLocalesDirectory('/locales', './public/locales', [
|
|
102
102
|
'./config/public/locales',
|
|
103
103
|
'./public/locales'
|
|
104
104
|
]);
|
|
105
|
-
const rootLocalesPath =
|
|
105
|
+
const rootLocalesPath = external_node_path_default().join(appDirectory, 'locales');
|
|
106
106
|
if (hasJsonFiles(rootLocalesPath)) return buildDetectedLocalesDirectory('/locales', './locales');
|
|
107
107
|
}
|
|
108
108
|
function applyDetectedBackendPaths(backendOptions, detectedLocales) {
|
package/dist/cjs/runtime/Link.js
CHANGED
|
@@ -30,97 +30,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
Link: ()=>Link,
|
|
32
32
|
default: ()=>runtime_Link,
|
|
33
|
-
interpolateRouteParams: ()=>interpolateRouteParams
|
|
33
|
+
interpolateRouteParams: ()=>external_linkHelpers_js_namespaceObject.interpolateRouteParams
|
|
34
34
|
});
|
|
35
35
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
36
36
|
const external_react_namespaceObject = require("react");
|
|
37
37
|
const external_context_js_namespaceObject = require("./context.js");
|
|
38
|
+
const external_linkHelpers_js_namespaceObject = require("./linkHelpers.js");
|
|
38
39
|
const external_localizedPaths_js_namespaceObject = require("./localizedPaths.js");
|
|
39
40
|
const external_routerAdapter_js_namespaceObject = require("./routerAdapter.js");
|
|
40
41
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
41
42
|
const EXTERNAL_TARGET_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
42
|
-
const warnedTargets = new Set();
|
|
43
|
-
const warnOnce = (key, message)=>{
|
|
44
|
-
if ('development' !== process.env.NODE_ENV || warnedTargets.has(key)) return;
|
|
45
|
-
warnedTargets.add(key);
|
|
46
|
-
console.warn(message);
|
|
47
|
-
};
|
|
48
|
-
const interpolateRouteParams = (pathname, params)=>{
|
|
49
|
-
if (!/[$:*{]/.test(pathname)) return pathname;
|
|
50
|
-
const resolveParam = (name)=>{
|
|
51
|
-
const value = params?.[name];
|
|
52
|
-
return void 0 === value ? void 0 : String(value);
|
|
53
|
-
};
|
|
54
|
-
const segments = pathname.split('/').map((segment)=>{
|
|
55
|
-
if (!segment) return segment;
|
|
56
|
-
if (segment.startsWith('{-$') && segment.endsWith('}')) {
|
|
57
|
-
const value = resolveParam(segment.slice(3, -1));
|
|
58
|
-
return void 0 === value ? null : encodeURIComponent(value);
|
|
59
|
-
}
|
|
60
|
-
if ('$' === segment || '*' === segment) {
|
|
61
|
-
const value = resolveParam('_splat') ?? resolveParam('*');
|
|
62
|
-
return void 0 === value ? null : value.split('/').map(encodeURIComponent).join('/');
|
|
63
|
-
}
|
|
64
|
-
if (segment.startsWith('$')) {
|
|
65
|
-
const value = resolveParam(segment.slice(1));
|
|
66
|
-
if (void 0 === value) {
|
|
67
|
-
warnOnce(`missing-param:${pathname}:${segment}`, `[plugin-i18n] <Link to="${pathname}"> is missing required param "${segment.slice(1)}".`);
|
|
68
|
-
return segment;
|
|
69
|
-
}
|
|
70
|
-
return encodeURIComponent(value);
|
|
71
|
-
}
|
|
72
|
-
if (segment.startsWith(':')) {
|
|
73
|
-
const optional = segment.endsWith('?');
|
|
74
|
-
const name = segment.slice(1, optional ? -1 : void 0);
|
|
75
|
-
const value = resolveParam(name);
|
|
76
|
-
if (void 0 === value) {
|
|
77
|
-
if (optional) return null;
|
|
78
|
-
warnOnce(`missing-param:${pathname}:${segment}`, `[plugin-i18n] <Link to="${pathname}"> is missing required param "${name}".`);
|
|
79
|
-
return segment;
|
|
80
|
-
}
|
|
81
|
-
return encodeURIComponent(value);
|
|
82
|
-
}
|
|
83
|
-
return segment;
|
|
84
|
-
}).filter((segment)=>null !== segment);
|
|
85
|
-
return segments.join('/') || '/';
|
|
86
|
-
};
|
|
87
|
-
const normalizeSearch = (search, searchFromTo)=>{
|
|
88
|
-
if (search && 'object' == typeof search) {
|
|
89
|
-
const entries = Object.entries(search).filter(([, value])=>null != value);
|
|
90
|
-
const searchObject = Object.fromEntries(entries.map(([key, value])=>[
|
|
91
|
-
key,
|
|
92
|
-
String(value)
|
|
93
|
-
]));
|
|
94
|
-
const params = new URLSearchParams(searchObject);
|
|
95
|
-
const serialized = params.toString();
|
|
96
|
-
return {
|
|
97
|
-
searchString: serialized ? `?${serialized}` : '',
|
|
98
|
-
searchObject
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const raw = 'string' == typeof search && search ? search : searchFromTo;
|
|
102
|
-
if (!raw) return {
|
|
103
|
-
searchString: '',
|
|
104
|
-
searchObject: void 0
|
|
105
|
-
};
|
|
106
|
-
const searchString = raw.startsWith('?') ? raw : `?${raw}`;
|
|
107
|
-
const searchObject = {};
|
|
108
|
-
new URLSearchParams(searchString).forEach((value, key)=>{
|
|
109
|
-
searchObject[key] = value;
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
searchString,
|
|
113
|
-
searchObject
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
const splitActiveProps = (active, activeProps)=>{
|
|
117
|
-
if (!active || !activeProps) return {};
|
|
118
|
-
return activeProps;
|
|
119
|
-
};
|
|
120
|
-
const mergeClassNames = (...values)=>{
|
|
121
|
-
const classNames = values.filter((value)=>'string' == typeof value && value.length > 0);
|
|
122
|
-
return classNames.length > 0 ? classNames.join(' ') : void 0;
|
|
123
|
-
};
|
|
124
43
|
const Link = (props)=>{
|
|
125
44
|
const { to, params, children, hash: hashProp, search: searchProp, hashScrollIntoView, activeOptions, activeProps, prefetch, preload, ...rest } = props;
|
|
126
45
|
const adapter = (0, external_routerAdapter_js_namespaceObject.useI18nRouterAdapter)();
|
|
@@ -134,12 +53,12 @@ const Link = (props)=>{
|
|
|
134
53
|
const target = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
135
54
|
if (isExternal || isBareHash) return null;
|
|
136
55
|
const { pathname, search: searchFromTo, hash: hashFromTo } = (0, external_utils_js_namespaceObject.splitUrlTarget)(to);
|
|
137
|
-
const interpolated = interpolateRouteParams(pathname || '/', params);
|
|
56
|
+
const interpolated = (0, external_linkHelpers_js_namespaceObject.interpolateRouteParams)(pathname || '/', params);
|
|
138
57
|
const firstSegment = interpolated.split('/').filter(Boolean)[0];
|
|
139
|
-
if (firstSegment && supportedLanguages.includes(firstSegment)) warnOnce(`lang-prefix:${to}`, `[plugin-i18n] <Link to="${to}"> starts with a language prefix. Write language-agnostic canonical paths; the Link localizes them automatically.`);
|
|
58
|
+
if (firstSegment && supportedLanguages.includes(firstSegment)) (0, external_linkHelpers_js_namespaceObject.warnOnce)(`lang-prefix:${to}`, `[plugin-i18n] <Link to="${to}"> starts with a language prefix. Write language-agnostic canonical paths; the Link localizes them automatically.`);
|
|
140
59
|
const localizedPathname = (0, external_utils_js_namespaceObject.buildLocalizedUrl)(interpolated, language, supportedLanguages, localisedUrls);
|
|
141
60
|
const hash = hashProp ?? (hashFromTo ? hashFromTo.slice(1) : '');
|
|
142
|
-
const { searchString, searchObject } = normalizeSearch(searchProp, searchFromTo);
|
|
61
|
+
const { searchString, searchObject } = (0, external_linkHelpers_js_namespaceObject.normalizeSearch)(searchProp, searchFromTo);
|
|
143
62
|
return {
|
|
144
63
|
canonicalPathname: interpolated,
|
|
145
64
|
localizedPathname,
|
|
@@ -174,7 +93,7 @@ const Link = (props)=>{
|
|
|
174
93
|
supportedLanguages,
|
|
175
94
|
localisedUrls
|
|
176
95
|
]);
|
|
177
|
-
const resolvedActiveProps = splitActiveProps(isActive, activeProps);
|
|
96
|
+
const resolvedActiveProps = (0, external_linkHelpers_js_namespaceObject.splitActiveProps)(isActive, activeProps);
|
|
178
97
|
const activeAttributes = isActive ? {
|
|
179
98
|
'data-status': 'active',
|
|
180
99
|
'aria-current': rest['aria-current'] ?? resolvedActiveProps['aria-current'] ?? 'page'
|
|
@@ -196,7 +115,7 @@ const Link = (props)=>{
|
|
|
196
115
|
...anchorProps,
|
|
197
116
|
...activeRest,
|
|
198
117
|
...activeAttributes,
|
|
199
|
-
className: mergeClassNames(rest.className, activeClassName),
|
|
118
|
+
className: (0, external_linkHelpers_js_namespaceObject.mergeClassNames)(rest.className, activeClassName),
|
|
200
119
|
style: {
|
|
201
120
|
...rest.style,
|
|
202
121
|
...activeStyle
|
|
@@ -205,7 +124,7 @@ const Link = (props)=>{
|
|
|
205
124
|
});
|
|
206
125
|
}
|
|
207
126
|
const { className: activeClassName, style: activeStyle, ...activeRest } = resolvedActiveProps;
|
|
208
|
-
const mergedClassName = mergeClassNames(rest.className, activeClassName);
|
|
127
|
+
const mergedClassName = (0, external_linkHelpers_js_namespaceObject.mergeClassNames)(rest.className, activeClassName);
|
|
209
128
|
const mergedStyle = {
|
|
210
129
|
...rest.style,
|
|
211
130
|
...activeStyle
|
|
@@ -32,11 +32,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
useModernI18n: ()=>useModernI18n
|
|
33
33
|
});
|
|
34
34
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
35
|
-
const runtime_namespaceObject = require("@modern-js/runtime");
|
|
36
35
|
const external_react_namespaceObject = require("react");
|
|
37
|
-
const
|
|
36
|
+
const external_contextHelpers_js_namespaceObject = require("./contextHelpers.js");
|
|
38
37
|
const external_routerAdapter_js_namespaceObject = require("./routerAdapter.js");
|
|
39
|
-
const external_utils_js_namespaceObject = require("./utils.js");
|
|
40
38
|
const modernI18nContextKey = Symbol.for('@modern-js/plugin-i18n/runtime/ModernI18nContext');
|
|
41
39
|
const getModernI18nContext = ()=>{
|
|
42
40
|
const globalStore = globalThis;
|
|
@@ -50,14 +48,10 @@ const ModernI18nProvider = ({ children, value })=>/*#__PURE__*/ (0, jsx_runtime_
|
|
|
50
48
|
});
|
|
51
49
|
const useModernI18n = ()=>{
|
|
52
50
|
const context = (0, external_react_namespaceObject.useContext)(ModernI18nContext);
|
|
53
|
-
if (!context) throw new Error('useModernI18n must be used within
|
|
51
|
+
if (!context) throw new Error('useModernI18n must be used within ModernI18nProvider');
|
|
54
52
|
const { language: contextLanguage, i18nInstance, languages, localePathRedirect, ignoreRedirectRoutes, localisedUrls, updateLanguage } = context;
|
|
55
53
|
const { navigate, location, hasRouter } = (0, external_routerAdapter_js_namespaceObject.useI18nRouterAdapter)();
|
|
56
|
-
const pathLanguage = (0, external_react_namespaceObject.useMemo)(()=>
|
|
57
|
-
if (!localePathRedirect || !location?.pathname) return;
|
|
58
|
-
const detected = (0, external_utils_js_namespaceObject.detectLanguageFromPath)(location.pathname, languages || [], localePathRedirect);
|
|
59
|
-
return detected.detected ? detected.language : void 0;
|
|
60
|
-
}, [
|
|
54
|
+
const pathLanguage = (0, external_react_namespaceObject.useMemo)(()=>(0, external_contextHelpers_js_namespaceObject.getPathLanguage)(location?.pathname, languages, localePathRedirect), [
|
|
61
55
|
languages,
|
|
62
56
|
localePathRedirect,
|
|
63
57
|
location?.pathname
|
|
@@ -68,56 +62,24 @@ const useModernI18n = ()=>{
|
|
|
68
62
|
updateLanguage?.(pathLanguage);
|
|
69
63
|
i18nInstance?.setLang?.(pathLanguage);
|
|
70
64
|
i18nInstance?.changeLanguage?.(pathLanguage);
|
|
71
|
-
|
|
72
|
-
const detectionOptions = i18nInstance.options?.detection;
|
|
73
|
-
(0, index_js_namespaceObject.cacheUserLanguage)(i18nInstance, pathLanguage, detectionOptions);
|
|
74
|
-
}
|
|
65
|
+
(0, external_contextHelpers_js_namespaceObject.cacheI18nLanguage)(i18nInstance, pathLanguage);
|
|
75
66
|
}, [
|
|
76
67
|
contextLanguage,
|
|
77
68
|
i18nInstance,
|
|
78
69
|
pathLanguage,
|
|
79
70
|
updateLanguage
|
|
80
71
|
]);
|
|
81
|
-
const changeLanguage = (0, external_react_namespaceObject.useCallback)(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const entryPath = (0, external_utils_js_namespaceObject.getEntryPath)();
|
|
93
|
-
const relativePath = currentPath.replace(entryPath, '');
|
|
94
|
-
const pathLanguage = (0, external_utils_js_namespaceObject.detectLanguageFromPath)(currentPath, languages || [], localePathRedirect);
|
|
95
|
-
if (pathLanguage.detected && pathLanguage.language === newLang) return;
|
|
96
|
-
if (!(0, external_utils_js_namespaceObject.shouldIgnoreRedirect)(relativePath, languages || [], ignoreRedirectRoutes)) {
|
|
97
|
-
const newPath = (0, external_utils_js_namespaceObject.buildLocalizedUrl)(relativePath, newLang, languages || [], localisedUrls);
|
|
98
|
-
const newUrl = entryPath + newPath + location.search + location.hash;
|
|
99
|
-
await navigate(newUrl, {
|
|
100
|
-
replace: true
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
} else if (localePathRedirect && (0, runtime_namespaceObject.isBrowser)() && !hasRouter) {
|
|
104
|
-
const currentPath = window.location.pathname;
|
|
105
|
-
const entryPath = (0, external_utils_js_namespaceObject.getEntryPath)();
|
|
106
|
-
const relativePath = currentPath.replace(entryPath, '');
|
|
107
|
-
const pathLanguage = (0, external_utils_js_namespaceObject.detectLanguageFromPath)(currentPath, languages || [], localePathRedirect);
|
|
108
|
-
if (pathLanguage.detected && pathLanguage.language === newLang) return;
|
|
109
|
-
if (!(0, external_utils_js_namespaceObject.shouldIgnoreRedirect)(relativePath, languages || [], ignoreRedirectRoutes)) {
|
|
110
|
-
const newPath = (0, external_utils_js_namespaceObject.buildLocalizedUrl)(relativePath, newLang, languages || [], localisedUrls);
|
|
111
|
-
const newUrl = entryPath + newPath + window.location.search + window.location.hash;
|
|
112
|
-
window.history.pushState(null, '', newUrl);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (updateLanguage) updateLanguage(newLang);
|
|
116
|
-
} catch (error) {
|
|
117
|
-
console.error('Failed to change language:', error);
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
}, [
|
|
72
|
+
const changeLanguage = (0, external_react_namespaceObject.useCallback)((newLang)=>(0, external_contextHelpers_js_namespaceObject.changeModernI18nLanguage)(newLang, {
|
|
73
|
+
i18nInstance,
|
|
74
|
+
updateLanguage,
|
|
75
|
+
localePathRedirect,
|
|
76
|
+
ignoreRedirectRoutes,
|
|
77
|
+
localisedUrls,
|
|
78
|
+
languages,
|
|
79
|
+
hasRouter,
|
|
80
|
+
navigate,
|
|
81
|
+
location
|
|
82
|
+
}), [
|
|
121
83
|
i18nInstance,
|
|
122
84
|
updateLanguage,
|
|
123
85
|
localePathRedirect,
|
|
@@ -128,40 +90,14 @@ const useModernI18n = ()=>{
|
|
|
128
90
|
navigate,
|
|
129
91
|
location
|
|
130
92
|
]);
|
|
131
|
-
const t = (0, external_react_namespaceObject.useCallback)((key, ...args)=>
|
|
132
|
-
if ('function' != typeof i18nInstance.t) throw new Error('i18nInstance.t is required');
|
|
133
|
-
return i18nInstance.t(key, ...args);
|
|
134
|
-
}, [
|
|
93
|
+
const t = (0, external_react_namespaceObject.useCallback)((key, ...args)=>(0, external_contextHelpers_js_namespaceObject.translateI18n)(i18nInstance, key, ...args), [
|
|
135
94
|
currentLanguage,
|
|
136
95
|
i18nInstance
|
|
137
96
|
]);
|
|
138
|
-
const isLanguageSupported = (0, external_react_namespaceObject.useCallback)((lang)=>languages
|
|
97
|
+
const isLanguageSupported = (0, external_react_namespaceObject.useCallback)((lang)=>(0, external_contextHelpers_js_namespaceObject.isI18nLanguageSupported)(languages, lang), [
|
|
139
98
|
languages
|
|
140
99
|
]);
|
|
141
|
-
const isResourcesReady = (0, external_react_namespaceObject.useMemo)(()=>
|
|
142
|
-
if (!i18nInstance?.isInitialized) return false;
|
|
143
|
-
const backend = i18nInstance?.services?.backend;
|
|
144
|
-
if (backend && 'function' == typeof backend.isLoading) {
|
|
145
|
-
const loadingResources = backend.getLoadingResources();
|
|
146
|
-
const isCurrentLanguageLoading = loadingResources.some(({ language })=>language === currentLanguage);
|
|
147
|
-
if (isCurrentLanguageLoading) return false;
|
|
148
|
-
}
|
|
149
|
-
const store = i18nInstance.store;
|
|
150
|
-
if (!store?.data) return false;
|
|
151
|
-
const langData = store.data[currentLanguage];
|
|
152
|
-
if (!langData || 'object' != typeof langData) return false;
|
|
153
|
-
const options = i18nInstance.options;
|
|
154
|
-
const namespaces = options?.ns || options?.defaultNS || [
|
|
155
|
-
'translation'
|
|
156
|
-
];
|
|
157
|
-
const requiredNamespaces = Array.isArray(namespaces) ? namespaces : [
|
|
158
|
-
namespaces
|
|
159
|
-
];
|
|
160
|
-
return requiredNamespaces.every((ns)=>{
|
|
161
|
-
const nsData = langData[ns];
|
|
162
|
-
return nsData && 'object' == typeof nsData && Object.keys(nsData).length > 0;
|
|
163
|
-
});
|
|
164
|
-
}, [
|
|
100
|
+
const isResourcesReady = (0, external_react_namespaceObject.useMemo)(()=>(0, external_contextHelpers_js_namespaceObject.isI18nResourcesReady)(i18nInstance, currentLanguage), [
|
|
165
101
|
currentLanguage,
|
|
166
102
|
i18nInstance
|
|
167
103
|
]);
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
cacheI18nLanguage: ()=>cacheI18nLanguage,
|
|
32
|
+
changeModernI18nLanguage: ()=>changeModernI18nLanguage,
|
|
33
|
+
getPathLanguage: ()=>getPathLanguage,
|
|
34
|
+
isI18nLanguageSupported: ()=>isI18nLanguageSupported,
|
|
35
|
+
isI18nResourcesReady: ()=>isI18nResourcesReady,
|
|
36
|
+
translateI18n: ()=>translateI18n
|
|
37
|
+
});
|
|
38
|
+
const runtime_namespaceObject = require("@modern-js/runtime");
|
|
39
|
+
const index_js_namespaceObject = require("./i18n/detection/index.js");
|
|
40
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
41
|
+
function getPathLanguage(pathname, languages, localePathRedirect) {
|
|
42
|
+
if (!localePathRedirect || !pathname) return;
|
|
43
|
+
const detected = (0, external_utils_js_namespaceObject.detectLanguageFromPath)(pathname, languages || [], localePathRedirect);
|
|
44
|
+
return detected.detected ? detected.language : void 0;
|
|
45
|
+
}
|
|
46
|
+
function cacheI18nLanguage(i18nInstance, language) {
|
|
47
|
+
if ((0, runtime_namespaceObject.isBrowser)()) {
|
|
48
|
+
const detectionOptions = i18nInstance.options?.detection;
|
|
49
|
+
(0, index_js_namespaceObject.cacheUserLanguage)(i18nInstance, language, detectionOptions);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function changeModernI18nLanguage(newLang, options) {
|
|
53
|
+
const { i18nInstance, updateLanguage, localePathRedirect, ignoreRedirectRoutes, localisedUrls, languages, hasRouter, navigate, location } = options;
|
|
54
|
+
try {
|
|
55
|
+
if (!newLang || 'string' != typeof newLang) throw new Error('Language must be non-empty string');
|
|
56
|
+
await i18nInstance?.setLang?.(newLang);
|
|
57
|
+
await i18nInstance?.changeLanguage?.(newLang);
|
|
58
|
+
cacheI18nLanguage(i18nInstance, newLang);
|
|
59
|
+
if (localePathRedirect && (0, runtime_namespaceObject.isBrowser)() && hasRouter && navigate && location) {
|
|
60
|
+
const currentPath = location.pathname;
|
|
61
|
+
const entryPath = (0, external_utils_js_namespaceObject.getEntryPath)();
|
|
62
|
+
const relativePath = currentPath.replace(entryPath, '');
|
|
63
|
+
const pathLanguage = (0, external_utils_js_namespaceObject.detectLanguageFromPath)(currentPath, languages || [], localePathRedirect);
|
|
64
|
+
if (pathLanguage.detected && pathLanguage.language === newLang) return void updateLanguage?.(newLang);
|
|
65
|
+
if (!(0, external_utils_js_namespaceObject.shouldIgnoreRedirect)(relativePath, languages || [], ignoreRedirectRoutes)) {
|
|
66
|
+
const newPath = (0, external_utils_js_namespaceObject.buildLocalizedUrl)(relativePath, newLang, languages || [], localisedUrls);
|
|
67
|
+
const newUrl = entryPath + newPath + location.search + location.hash;
|
|
68
|
+
await navigate(newUrl, {
|
|
69
|
+
replace: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
} else if (localePathRedirect && (0, runtime_namespaceObject.isBrowser)() && !hasRouter) {
|
|
73
|
+
const currentPath = window.location.pathname;
|
|
74
|
+
const entryPath = (0, external_utils_js_namespaceObject.getEntryPath)();
|
|
75
|
+
const relativePath = currentPath.replace(entryPath, '');
|
|
76
|
+
const pathLanguage = (0, external_utils_js_namespaceObject.detectLanguageFromPath)(currentPath, languages || [], localePathRedirect);
|
|
77
|
+
if (pathLanguage.detected && pathLanguage.language === newLang) return void updateLanguage?.(newLang);
|
|
78
|
+
if (!(0, external_utils_js_namespaceObject.shouldIgnoreRedirect)(relativePath, languages || [], ignoreRedirectRoutes)) {
|
|
79
|
+
const newPath = (0, external_utils_js_namespaceObject.buildLocalizedUrl)(relativePath, newLang, languages || [], localisedUrls);
|
|
80
|
+
const newUrl = entryPath + newPath + window.location.search + window.location.hash;
|
|
81
|
+
window.history.pushState(null, '', newUrl);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (updateLanguage) updateLanguage(newLang);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error('Failed change language:', error);
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function translateI18n(i18nInstance, key, ...args) {
|
|
91
|
+
if ('function' != typeof i18nInstance.t) throw new Error('i18nInstance.t required');
|
|
92
|
+
return i18nInstance.t(key, ...args);
|
|
93
|
+
}
|
|
94
|
+
function isI18nLanguageSupported(languages, lang) {
|
|
95
|
+
return languages?.includes(lang) || false;
|
|
96
|
+
}
|
|
97
|
+
function isI18nResourcesReady(i18nInstance, currentLanguage) {
|
|
98
|
+
if (!i18nInstance?.isInitialized) return false;
|
|
99
|
+
const backend = i18nInstance?.services?.backend;
|
|
100
|
+
if (backend && 'function' == typeof backend.isLoading) {
|
|
101
|
+
const loadingResources = backend.getLoadingResources();
|
|
102
|
+
const isCurrentLanguageLoading = loadingResources.some(({ language })=>language === currentLanguage);
|
|
103
|
+
if (isCurrentLanguageLoading) return false;
|
|
104
|
+
}
|
|
105
|
+
const store = i18nInstance.store;
|
|
106
|
+
if (!store?.data) return false;
|
|
107
|
+
const langData = store.data[currentLanguage];
|
|
108
|
+
if (!langData || 'object' != typeof langData) return false;
|
|
109
|
+
const options = i18nInstance.options;
|
|
110
|
+
const namespaces = options?.ns || options?.defaultNS || [
|
|
111
|
+
'translation'
|
|
112
|
+
];
|
|
113
|
+
const requiredNamespaces = Array.isArray(namespaces) ? namespaces : [
|
|
114
|
+
namespaces
|
|
115
|
+
];
|
|
116
|
+
return requiredNamespaces.every((ns)=>{
|
|
117
|
+
const nsData = langData[ns];
|
|
118
|
+
return nsData && 'object' == typeof nsData && Object.keys(nsData).length > 0;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.cacheI18nLanguage = __webpack_exports__.cacheI18nLanguage;
|
|
122
|
+
exports.changeModernI18nLanguage = __webpack_exports__.changeModernI18nLanguage;
|
|
123
|
+
exports.getPathLanguage = __webpack_exports__.getPathLanguage;
|
|
124
|
+
exports.isI18nLanguageSupported = __webpack_exports__.isI18nLanguageSupported;
|
|
125
|
+
exports.isI18nResourcesReady = __webpack_exports__.isI18nResourcesReady;
|
|
126
|
+
exports.translateI18n = __webpack_exports__.translateI18n;
|
|
127
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
128
|
+
"cacheI18nLanguage",
|
|
129
|
+
"changeModernI18nLanguage",
|
|
130
|
+
"getPathLanguage",
|
|
131
|
+
"isI18nLanguageSupported",
|
|
132
|
+
"isI18nResourcesReady",
|
|
133
|
+
"translateI18n"
|
|
134
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
135
|
+
Object.defineProperty(exports, '__esModule', {
|
|
136
|
+
value: true
|
|
137
|
+
});
|