@bleedingdev/modern-js-plugin-i18n 3.9.0-ultramodern.8 → 3.9.3-ultramodern.1
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 +11 -0
- package/dist/cjs/cli/localisedRoutes.js +47 -0
- package/dist/cjs/runtime/context.js +6 -14
- package/dist/cjs/runtime/contexts.js +49 -0
- package/dist/cjs/runtime/core.js +12 -2
- package/dist/cjs/runtime/i18n/detection/middleware.js +1 -1
- package/dist/cjs/runtime/i18n/detection/middleware.node.js +10 -1
- package/dist/cjs/runtime/i18n/detection/priority.js +1 -1
- package/dist/cjs/runtime/navigation.js +48 -0
- package/dist/cjs/runtime/routerAdapter.js +3 -5
- package/dist/cjs/runtime/sharedContexts.js +43 -0
- package/dist/cjs/runtime/utils.js +6 -2
- package/dist/cjs/server/defaultUrlStrategy.js +48 -0
- package/dist/cjs/server/index.js +3 -2
- package/dist/cjs/server/mappedUrlStrategy.js +43 -0
- package/dist/cjs/server/redirectPolicy.js +13 -9
- package/dist/cjs/shared/detection.js +118 -2
- package/dist/cjs/shared/mappedUrlStrategy.js +63 -0
- package/dist/cjs/shared/urlStrategy.js +31 -1
- package/dist/esm/cli/index.mjs +11 -0
- package/dist/esm/cli/localisedRoutes.mjs +9 -0
- package/dist/esm/runtime/context.mjs +2 -10
- package/dist/esm/runtime/contexts.mjs +5 -0
- package/dist/esm/runtime/core.mjs +7 -3
- package/dist/esm/runtime/i18n/detection/middleware.mjs +1 -1
- package/dist/esm/runtime/i18n/detection/middleware.node.mjs +10 -1
- package/dist/esm/runtime/i18n/detection/priority.mjs +1 -1
- package/dist/esm/runtime/navigation.mjs +7 -0
- package/dist/esm/runtime/routerAdapter.mjs +2 -4
- package/dist/esm/runtime/sharedContexts.mjs +1 -0
- package/dist/esm/runtime/utils.mjs +6 -2
- package/dist/esm/server/defaultUrlStrategy.mjs +7 -0
- package/dist/esm/server/index.mjs +3 -2
- package/dist/esm/server/mappedUrlStrategy.mjs +1 -0
- package/dist/esm/server/redirectPolicy.mjs +6 -2
- package/dist/esm/shared/detection.mjs +85 -1
- package/dist/esm/shared/mappedUrlStrategy.mjs +19 -0
- package/dist/esm/shared/urlStrategy.mjs +7 -0
- package/dist/esm-node/cli/index.mjs +11 -0
- package/dist/esm-node/cli/localisedRoutes.mjs +10 -0
- package/dist/esm-node/runtime/context.mjs +2 -10
- package/dist/esm-node/runtime/contexts.mjs +6 -0
- package/dist/esm-node/runtime/core.mjs +7 -3
- package/dist/esm-node/runtime/i18n/detection/middleware.mjs +1 -1
- package/dist/esm-node/runtime/i18n/detection/middleware.node.mjs +10 -1
- package/dist/esm-node/runtime/i18n/detection/priority.mjs +1 -1
- package/dist/esm-node/runtime/navigation.mjs +8 -0
- package/dist/esm-node/runtime/routerAdapter.mjs +2 -4
- package/dist/esm-node/runtime/sharedContexts.mjs +2 -0
- package/dist/esm-node/runtime/utils.mjs +6 -2
- package/dist/esm-node/server/defaultUrlStrategy.mjs +8 -0
- package/dist/esm-node/server/index.mjs +3 -2
- package/dist/esm-node/server/mappedUrlStrategy.mjs +2 -0
- package/dist/esm-node/server/redirectPolicy.mjs +6 -2
- package/dist/esm-node/shared/detection.mjs +85 -1
- package/dist/esm-node/shared/mappedUrlStrategy.mjs +20 -0
- package/dist/esm-node/shared/urlStrategy.mjs +7 -0
- package/dist/types/cli/localisedRoutes.d.ts +19 -0
- package/dist/types/runtime/context.d.ts +2 -2
- package/dist/types/runtime/contexts.d.ts +6 -0
- package/dist/types/runtime/core.d.ts +2 -1
- package/dist/types/runtime/i18n/detection/middleware.d.ts +1 -1
- package/dist/types/runtime/i18n/detection/middleware.node.d.ts +1 -5
- package/dist/types/runtime/navigation.d.ts +10 -0
- package/dist/types/runtime/sharedContexts.d.ts +1 -0
- package/dist/types/runtime/utils.d.ts +1 -1
- package/dist/types/server/defaultUrlStrategy.d.ts +11 -0
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/mappedUrlStrategy.d.ts +7 -0
- package/dist/types/server/redirectPolicy.d.ts +1 -1
- package/dist/types/shared/detection.d.ts +11 -1
- package/dist/types/shared/mappedUrlStrategy.d.ts +27 -0
- package/dist/types/shared/type.d.ts +10 -0
- package/dist/types/shared/urlStrategy.d.ts +11 -0
- package/package.json +43 -24
- package/src/cli/index.ts +43 -1
- package/src/cli/localisedRoutes.ts +53 -0
- package/src/runtime/context.tsx +6 -31
- package/src/runtime/contexts.ts +16 -0
- package/src/runtime/core.tsx +30 -3
- package/src/runtime/i18n/detection/middleware.node.ts +25 -7
- package/src/runtime/i18n/detection/middleware.ts +2 -0
- package/src/runtime/i18n/detection/priority.ts +2 -0
- package/src/runtime/navigation.tsx +20 -0
- package/src/runtime/routerAdapter.tsx +2 -11
- package/src/runtime/sharedContexts.ts +8 -0
- package/src/runtime/utils.ts +13 -4
- package/src/server/defaultUrlStrategy.ts +27 -0
- package/src/server/index.ts +7 -12
- package/src/server/mappedUrlStrategy.ts +10 -0
- package/src/server/redirectPolicy.ts +19 -4
- package/src/shared/detection.ts +34 -10
- package/src/shared/mappedUrlStrategy.ts +59 -0
- package/src/shared/type.ts +10 -0
- package/src/shared/urlStrategy.ts +27 -0
- package/rslib.config.mts +0 -4
- package/rstest.config.mts +0 -46
- package/tests/backendDefaults.test.ts +0 -30
- package/tests/federatedI18nBoundaryResolver.test.tsx +0 -65
- package/tests/i18nUtils.test.ts +0 -60
- package/tests/link.test.tsx +0 -139
- package/tests/localisedUrls.test.ts +0 -176
- package/tests/reactI18nextRuntimeBoundary.test.ts +0 -117
- package/tests/redirectPolicy.test.ts +0 -54
- package/tests/routerAdapter.test.tsx +0 -221
- package/tsconfig.json +0 -15
package/dist/cjs/cli/index.js
CHANGED
|
@@ -32,8 +32,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
i18nPlugin: ()=>i18nPlugin
|
|
33
33
|
});
|
|
34
34
|
const server_core_namespaceObject = require("@modern-js/server-core");
|
|
35
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
36
|
+
const urlStrategy_js_namespaceObject = require("../shared/urlStrategy.js");
|
|
35
37
|
const utils_js_namespaceObject = require("../shared/utils.js");
|
|
36
38
|
const external_locales_js_namespaceObject = require("./locales.js");
|
|
39
|
+
const external_localisedRoutes_js_namespaceObject = require("./localisedRoutes.js");
|
|
37
40
|
require("../runtime/types.js");
|
|
38
41
|
const i18nPlugin = (options = {})=>({
|
|
39
42
|
name: '@modern-js/plugin-i18n',
|
|
@@ -63,6 +66,10 @@ const i18nPlugin = (options = {})=>({
|
|
|
63
66
|
backend: backendOptions,
|
|
64
67
|
...extendedConfig
|
|
65
68
|
};
|
|
69
|
+
if ((0, urlStrategy_js_namespaceObject.isUnusableI18nUrlStrategy)(config.urlStrategy)) {
|
|
70
|
+
delete config.urlStrategy;
|
|
71
|
+
utils_namespaceObject.logger.warn("[i18n] `urlStrategy` cannot be passed through `modern.config.ts`: the generated runtime registration carries plugin options as JSON, which drops its methods. Configure `localeDetection.localisedUrls` instead — the runtime and the server both derive the URL policy from it — or register a runtime plugin that supplies the strategy directly.");
|
|
72
|
+
}
|
|
66
73
|
const { reactI18next } = extendedConfig;
|
|
67
74
|
const runtimePluginPath = customPlugin?.runtime?.path || (false === reactI18next ? `@${metaName}/plugin-i18n/runtime/no-react-i18next` : `@${metaName}/plugin-i18n/runtime`);
|
|
68
75
|
plugins.push({
|
|
@@ -75,6 +82,10 @@ const i18nPlugin = (options = {})=>({
|
|
|
75
82
|
plugins
|
|
76
83
|
};
|
|
77
84
|
});
|
|
85
|
+
api.modifyFileSystemRoutes(({ entrypoint, routes })=>({
|
|
86
|
+
entrypoint,
|
|
87
|
+
routes: (0, external_localisedRoutes_js_namespaceObject.applyLocalisedRoutes)(routes, localeDetection ? (0, utils_js_namespaceObject.getLocaleDetectionOptions)(entrypoint.entryName, localeDetection) : void 0, entrypoint)
|
|
88
|
+
}));
|
|
78
89
|
api._internalServerPlugins(({ plugins })=>{
|
|
79
90
|
const { serverRoutes, metaName } = api.getAppContext();
|
|
80
91
|
const normalizedConfig = api.getNormalizedConfig();
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
applyLocalisedRoutes: ()=>applyLocalisedRoutes
|
|
32
|
+
});
|
|
33
|
+
const i18n_runtime_extensions_namespaceObject = require("@modern-js/i18n-runtime-extensions");
|
|
34
|
+
const cli_namespaceObject = require("@modern-js/runtime/cli");
|
|
35
|
+
const applyLocalisedRoutes = (routes, localeDetection, entrypoint)=>{
|
|
36
|
+
const { localePathRedirect, languages = [], localisedUrls } = localeDetection ?? {};
|
|
37
|
+
const resolved = (0, i18n_runtime_extensions_namespaceObject.resolveLocalisedUrlsConfig)(localisedUrls);
|
|
38
|
+
if (!localePathRedirect || !languages.length || !resolved.enabled) return routes;
|
|
39
|
+
return (0, i18n_runtime_extensions_namespaceObject.applyLocalisedUrlsToRoutes)(routes, languages, resolved.map, entrypoint && '@modern-js/plugin-tanstack' === (0, cli_namespaceObject.getEntrypointRoutesOwner)(entrypoint) ? 'canonical' : 'physical');
|
|
40
|
+
};
|
|
41
|
+
exports.applyLocalisedRoutes = __webpack_exports__.applyLocalisedRoutes;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"applyLocalisedRoutes"
|
|
44
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
45
|
+
Object.defineProperty(exports, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
|
@@ -29,9 +29,9 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
FederatedI18nBoundary: ()=>FederatedI18nBoundary,
|
|
32
|
-
ModernI18nContext: ()=>ModernI18nContext,
|
|
32
|
+
ModernI18nContext: ()=>external_sharedContexts_js_namespaceObject.ModernI18nContext,
|
|
33
33
|
ModernI18nProvider: ()=>ModernI18nProvider,
|
|
34
|
-
ReactI18nextProviderContext: ()=>ReactI18nextProviderContext,
|
|
34
|
+
ReactI18nextProviderContext: ()=>external_sharedContexts_js_namespaceObject.ReactI18nextProviderContext,
|
|
35
35
|
getActualI18nextInstance: ()=>instance_js_namespaceObject.getActualI18nextInstance,
|
|
36
36
|
useModernI18n: ()=>useModernI18n
|
|
37
37
|
});
|
|
@@ -40,22 +40,14 @@ const context_namespaceObject = require("@modern-js/runtime/context");
|
|
|
40
40
|
const external_react_namespaceObject = require("react");
|
|
41
41
|
const external_contextHelpers_js_namespaceObject = require("./contextHelpers.js");
|
|
42
42
|
const external_routerAdapter_js_namespaceObject = require("./routerAdapter.js");
|
|
43
|
+
const external_sharedContexts_js_namespaceObject = require("./sharedContexts.js");
|
|
43
44
|
const instance_js_namespaceObject = require("./i18n/instance.js");
|
|
44
|
-
const modernI18nContextKey = Symbol.for('@modern-js/plugin-i18n/runtime/ModernI18nContext');
|
|
45
|
-
const reactI18nextProviderContextKey = Symbol.for('@modern-js/plugin-i18n/runtime/ReactI18nextProviderContext');
|
|
46
|
-
const getGlobalContext = (key, defaultValue)=>{
|
|
47
|
-
const globalStore = globalThis;
|
|
48
|
-
globalStore[key] ??= /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(defaultValue);
|
|
49
|
-
return globalStore[key];
|
|
50
|
-
};
|
|
51
|
-
const ModernI18nContext = getGlobalContext(modernI18nContextKey, null);
|
|
52
|
-
const ReactI18nextProviderContext = getGlobalContext(reactI18nextProviderContextKey, null);
|
|
53
45
|
const ModernI18nProvider = ({ children, i18nextProvider, value })=>{
|
|
54
|
-
const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ModernI18nContext.Provider, {
|
|
46
|
+
const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_sharedContexts_js_namespaceObject.ModernI18nContext.Provider, {
|
|
55
47
|
value: value,
|
|
56
48
|
children: children
|
|
57
49
|
});
|
|
58
|
-
return void 0 === i18nextProvider ? content : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ReactI18nextProviderContext.Provider, {
|
|
50
|
+
return void 0 === i18nextProvider ? content : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_sharedContexts_js_namespaceObject.ReactI18nextProviderContext.Provider, {
|
|
59
51
|
value: i18nextProvider,
|
|
60
52
|
children: content
|
|
61
53
|
});
|
|
@@ -74,7 +66,7 @@ const FederatedI18nBoundary = (props)=>{
|
|
|
74
66
|
});
|
|
75
67
|
};
|
|
76
68
|
const useModernI18n = ()=>{
|
|
77
|
-
const context = (0, external_react_namespaceObject.useContext)(ModernI18nContext);
|
|
69
|
+
const context = (0, external_react_namespaceObject.useContext)(external_sharedContexts_js_namespaceObject.ModernI18nContext);
|
|
78
70
|
if (!context) throw new Error('useModernI18n must be used within ModernI18nProvider');
|
|
79
71
|
const { language: contextLanguage, i18nInstance, languages, localePathRedirect, ignoreRedirectRoutes, urlStrategy, updateLanguage, synchronizeLanguage } = context;
|
|
80
72
|
const { navigate, location, hasRouter } = (0, external_routerAdapter_js_namespaceObject.useI18nRouterAdapter)();
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
I18nNavigationContext: ()=>I18nNavigationContext,
|
|
32
|
+
ModernI18nContext: ()=>ModernI18nContext,
|
|
33
|
+
ReactI18nextProviderContext: ()=>ReactI18nextProviderContext
|
|
34
|
+
});
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const ModernI18nContext = (0, external_react_namespaceObject.createContext)(null);
|
|
37
|
+
const ReactI18nextProviderContext = (0, external_react_namespaceObject.createContext)(null);
|
|
38
|
+
const I18nNavigationContext = (0, external_react_namespaceObject.createContext)(null);
|
|
39
|
+
exports.I18nNavigationContext = __webpack_exports__.I18nNavigationContext;
|
|
40
|
+
exports.ModernI18nContext = __webpack_exports__.ModernI18nContext;
|
|
41
|
+
exports.ReactI18nextProviderContext = __webpack_exports__.ReactI18nextProviderContext;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"I18nNavigationContext",
|
|
44
|
+
"ModernI18nContext",
|
|
45
|
+
"ReactI18nextProviderContext"
|
|
46
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
47
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
|
+
value: true
|
|
49
|
+
});
|
package/dist/cjs/runtime/core.js
CHANGED
|
@@ -31,15 +31,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
FederatedI18nBoundary: ()=>external_context_js_namespaceObject.FederatedI18nBoundary,
|
|
32
32
|
I18nLink: ()=>external_I18nLink_js_namespaceObject.I18nLink,
|
|
33
33
|
I18nNavigationProvider: ()=>external_routerAdapter_js_namespaceObject.I18nNavigationProvider,
|
|
34
|
+
I18nRouterNavigationProvider: ()=>external_navigation_js_namespaceObject.I18nRouterNavigationProvider,
|
|
34
35
|
Link: ()=>external_Link_js_namespaceObject.Link,
|
|
35
36
|
createI18nPlugin: ()=>createI18nPlugin,
|
|
36
37
|
splitUrlTarget: ()=>external_utils_js_namespaceObject.splitUrlTarget,
|
|
37
38
|
useI18nRouterAdapter: ()=>external_routerAdapter_js_namespaceObject.useI18nRouterAdapter,
|
|
39
|
+
useIntegratedRouterAdapter: ()=>external_navigation_js_namespaceObject.useIntegratedRouterAdapter,
|
|
38
40
|
useLocalizedLocation: ()=>external_localizedPaths_js_namespaceObject.useLocalizedLocation,
|
|
39
41
|
useLocalizedPaths: ()=>external_localizedPaths_js_namespaceObject.useLocalizedPaths,
|
|
40
42
|
useModernI18n: ()=>external_context_js_namespaceObject.useModernI18n,
|
|
41
43
|
useNativeI18nRouterAdapter: ()=>external_routerAdapter_js_namespaceObject.useNativeI18nRouterAdapter
|
|
42
44
|
});
|
|
45
|
+
const mappedUrlStrategy_js_namespaceObject = require("../shared/mappedUrlStrategy.js");
|
|
46
|
+
const urlStrategy_js_namespaceObject = require("../shared/urlStrategy.js");
|
|
47
|
+
const external_navigation_js_namespaceObject = require("./navigation.js");
|
|
43
48
|
const external_pluginSetup_js_namespaceObject = require("./pluginSetup.js");
|
|
44
49
|
const external_providerComposition_js_namespaceObject = require("./providerComposition.js");
|
|
45
50
|
const external_reactI18next_js_namespaceObject = require("./reactI18next.js");
|
|
@@ -56,6 +61,7 @@ const createI18nPlugin = (loadReactI18nextIntegration)=>(options)=>({
|
|
|
56
61
|
const { entryName, i18nInstance: userI18nInstance, initOptions, localeDetection, backend, htmlLangAttr = false, reactI18next = true, urlStrategy, NavigationProvider, LanguageSynchronization } = options;
|
|
57
62
|
const { localePathRedirect = false, i18nextDetector = true, languages = [], fallbackLanguage = 'en', detection, ignoreRedirectRoutes } = localeDetection || {};
|
|
58
63
|
const { enabled: backendEnabled = false } = backend || {};
|
|
64
|
+
const resolvedUrlStrategy = (0, urlStrategy_js_namespaceObject.asI18nUrlStrategy)(urlStrategy) ?? (0, mappedUrlStrategy_js_namespaceObject.resolveMappedUrlStrategy)(localeDetection);
|
|
59
65
|
let latestI18nInstance;
|
|
60
66
|
let I18nextProvider;
|
|
61
67
|
api.onBeforeRender(async (context)=>{
|
|
@@ -83,8 +89,8 @@ const createI18nPlugin = (loadReactI18nextIntegration)=>(options)=>({
|
|
|
83
89
|
languages,
|
|
84
90
|
fallbackLanguage,
|
|
85
91
|
ignoreRedirectRoutes,
|
|
86
|
-
urlStrategy,
|
|
87
|
-
NavigationProvider,
|
|
92
|
+
urlStrategy: resolvedUrlStrategy,
|
|
93
|
+
NavigationProvider: NavigationProvider ?? external_navigation_js_namespaceObject.I18nRouterNavigationProvider,
|
|
88
94
|
LanguageSynchronization,
|
|
89
95
|
getLatestI18nInstance: ()=>latestI18nInstance,
|
|
90
96
|
getI18nextProvider: ()=>I18nextProvider
|
|
@@ -94,10 +100,12 @@ const createI18nPlugin = (loadReactI18nextIntegration)=>(options)=>({
|
|
|
94
100
|
exports.FederatedI18nBoundary = __webpack_exports__.FederatedI18nBoundary;
|
|
95
101
|
exports.I18nLink = __webpack_exports__.I18nLink;
|
|
96
102
|
exports.I18nNavigationProvider = __webpack_exports__.I18nNavigationProvider;
|
|
103
|
+
exports.I18nRouterNavigationProvider = __webpack_exports__.I18nRouterNavigationProvider;
|
|
97
104
|
exports.Link = __webpack_exports__.Link;
|
|
98
105
|
exports.createI18nPlugin = __webpack_exports__.createI18nPlugin;
|
|
99
106
|
exports.splitUrlTarget = __webpack_exports__.splitUrlTarget;
|
|
100
107
|
exports.useI18nRouterAdapter = __webpack_exports__.useI18nRouterAdapter;
|
|
108
|
+
exports.useIntegratedRouterAdapter = __webpack_exports__.useIntegratedRouterAdapter;
|
|
101
109
|
exports.useLocalizedLocation = __webpack_exports__.useLocalizedLocation;
|
|
102
110
|
exports.useLocalizedPaths = __webpack_exports__.useLocalizedPaths;
|
|
103
111
|
exports.useModernI18n = __webpack_exports__.useModernI18n;
|
|
@@ -106,10 +114,12 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
106
114
|
"FederatedI18nBoundary",
|
|
107
115
|
"I18nLink",
|
|
108
116
|
"I18nNavigationProvider",
|
|
117
|
+
"I18nRouterNavigationProvider",
|
|
109
118
|
"Link",
|
|
110
119
|
"createI18nPlugin",
|
|
111
120
|
"splitUrlTarget",
|
|
112
121
|
"useI18nRouterAdapter",
|
|
122
|
+
"useIntegratedRouterAdapter",
|
|
113
123
|
"useLocalizedLocation",
|
|
114
124
|
"useLocalizedPaths",
|
|
115
125
|
"useModernI18n",
|
|
@@ -56,7 +56,7 @@ const useI18nextLanguageDetector = (i18nInstance)=>{
|
|
|
56
56
|
}
|
|
57
57
|
return i18nInstance;
|
|
58
58
|
};
|
|
59
|
-
const readLanguageFromStorage = (detectionOptions)=>{
|
|
59
|
+
const readLanguageFromStorage = (detectionOptions, _request, _languages)=>{
|
|
60
60
|
try {
|
|
61
61
|
const options = detectionOptions || {};
|
|
62
62
|
const order = options.order || [
|
|
@@ -34,8 +34,17 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
34
34
|
useI18nextLanguageDetector: ()=>useI18nextLanguageDetector
|
|
35
35
|
});
|
|
36
36
|
const external_i18next_http_middleware_namespaceObject = require("i18next-http-middleware");
|
|
37
|
+
const detection_js_namespaceObject = require("../../../shared/detection.js");
|
|
38
|
+
const isDetectionRequest = (request)=>{
|
|
39
|
+
if (!request || 'object' != typeof request) return false;
|
|
40
|
+
const { url, headers } = request;
|
|
41
|
+
return 'string' == typeof url && !!headers && 'object' == typeof headers;
|
|
42
|
+
};
|
|
37
43
|
const cacheUserLanguage = (_i18nInstance, _language, _detectionOptions)=>{};
|
|
38
|
-
const readLanguageFromStorage = (
|
|
44
|
+
const readLanguageFromStorage = (detectionOptions, request, languages = [])=>{
|
|
45
|
+
if (!isDetectionRequest(request)) return;
|
|
46
|
+
return (0, detection_js_namespaceObject.detectLanguageFromRequest)(request, languages, detectionOptions) ?? void 0;
|
|
47
|
+
};
|
|
39
48
|
const useI18nextLanguageDetector = (i18nInstance)=>{
|
|
40
49
|
if (!i18nInstance.isInitialized) return i18nInstance.use(external_i18next_http_middleware_namespaceObject.LanguageDetector);
|
|
41
50
|
return i18nInstance;
|
|
@@ -41,7 +41,7 @@ const detectLanguageWithPriority = async (i18nInstance, options)=>{
|
|
|
41
41
|
let detectedLanguage;
|
|
42
42
|
detectedLanguage = (0, external_path_js_namespaceObject.detectLanguageFromPathPriority)(pathname, languages, localePathRedirect);
|
|
43
43
|
if (!detectedLanguage) detectedLanguage = (0, external_ssr_js_namespaceObject.detectLanguageFromSSR)(languages);
|
|
44
|
-
if (!detectedLanguage && i18nextDetector) detectedLanguage = (0, external_instance_js_namespaceObject.isI18nWrapperInstance)(i18nInstance) ? (0, external_middleware_js_namespaceObject.readLanguageFromStorage)((0, external_initOptions_js_namespaceObject.mergeDetectionOptions)(i18nextDetector, detection, localePathRedirect, userInitOptions)) : await (0, external_detector_js_namespaceObject.detectLanguageFromI18nextDetector)(i18nInstance, {
|
|
44
|
+
if (!detectedLanguage && i18nextDetector) detectedLanguage = (0, external_instance_js_namespaceObject.isI18nWrapperInstance)(i18nInstance) ? (0, external_middleware_js_namespaceObject.readLanguageFromStorage)((0, external_initOptions_js_namespaceObject.mergeDetectionOptions)(i18nextDetector, detection, localePathRedirect, userInitOptions), ssrContext?.request, languages) : await (0, external_detector_js_namespaceObject.detectLanguageFromI18nextDetector)(i18nInstance, {
|
|
45
45
|
languages,
|
|
46
46
|
fallbackLanguage,
|
|
47
47
|
localePathRedirect,
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
I18nRouterNavigationProvider: ()=>I18nRouterNavigationProvider,
|
|
32
|
+
useIntegratedRouterAdapter: ()=>useIntegratedRouterAdapter
|
|
33
|
+
});
|
|
34
|
+
const router_navigation_namespaceObject = require("@modern-js/i18n-runtime-extensions/router-navigation");
|
|
35
|
+
const external_routerAdapter_js_namespaceObject = require("./routerAdapter.js");
|
|
36
|
+
const { I18nRouterNavigationProvider, useIntegratedRouterAdapter } = (0, router_navigation_namespaceObject.createI18nRouterNavigation)({
|
|
37
|
+
I18nNavigationProvider: external_routerAdapter_js_namespaceObject.I18nNavigationProvider,
|
|
38
|
+
useNativeI18nRouterAdapter: external_routerAdapter_js_namespaceObject.useNativeI18nRouterAdapter
|
|
39
|
+
});
|
|
40
|
+
exports.I18nRouterNavigationProvider = __webpack_exports__.I18nRouterNavigationProvider;
|
|
41
|
+
exports.useIntegratedRouterAdapter = __webpack_exports__.useIntegratedRouterAdapter;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"I18nRouterNavigationProvider",
|
|
44
|
+
"useIntegratedRouterAdapter"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
|
@@ -33,13 +33,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
useNativeI18nRouterAdapter: ()=>useNativeI18nRouterAdapter
|
|
34
34
|
});
|
|
35
35
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
36
|
+
const contexts_namespaceObject = require("@modern-js/plugin-i18n/runtime/contexts");
|
|
36
37
|
const runtime_namespaceObject = require("@modern-js/runtime");
|
|
37
38
|
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
38
39
|
const external_react_namespaceObject = require("react");
|
|
39
|
-
const
|
|
40
|
-
const contextStore = globalThis;
|
|
41
|
-
const I18nNavigationContext = contextStore[navigationContextKey] ??= /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(null);
|
|
42
|
-
const I18nNavigationProvider = ({ children, value })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(I18nNavigationContext.Provider, {
|
|
40
|
+
const I18nNavigationProvider = ({ children, value })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(contexts_namespaceObject.I18nNavigationContext.Provider, {
|
|
43
41
|
value: value,
|
|
44
42
|
children: children
|
|
45
43
|
});
|
|
@@ -66,7 +64,7 @@ const useNativeI18nRouterAdapter = ()=>{
|
|
|
66
64
|
};
|
|
67
65
|
};
|
|
68
66
|
const useI18nRouterAdapter = ()=>{
|
|
69
|
-
const provided = (0, external_react_namespaceObject.useContext)(I18nNavigationContext);
|
|
67
|
+
const provided = (0, external_react_namespaceObject.useContext)(contexts_namespaceObject.I18nNavigationContext);
|
|
70
68
|
const native = useNativeI18nRouterAdapter();
|
|
71
69
|
return provided ?? native;
|
|
72
70
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
ModernI18nContext: ()=>contexts_namespaceObject.ModernI18nContext,
|
|
32
|
+
ReactI18nextProviderContext: ()=>contexts_namespaceObject.ReactI18nextProviderContext
|
|
33
|
+
});
|
|
34
|
+
const contexts_namespaceObject = require("@modern-js/plugin-i18n/runtime/contexts");
|
|
35
|
+
exports.ModernI18nContext = __webpack_exports__.ModernI18nContext;
|
|
36
|
+
exports.ReactI18nextProviderContext = __webpack_exports__.ReactI18nextProviderContext;
|
|
37
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
38
|
+
"ModernI18nContext",
|
|
39
|
+
"ReactI18nextProviderContext"
|
|
40
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
41
|
+
Object.defineProperty(exports, '__esModule', {
|
|
42
|
+
value: true
|
|
43
|
+
});
|
|
@@ -39,6 +39,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
39
39
|
const runtime_namespaceObject = require("@modern-js/runtime");
|
|
40
40
|
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
41
41
|
const url_namespaceObject = require("@modern-js/runtime-utils/url");
|
|
42
|
+
const mappedUrlStrategy_js_namespaceObject = require("../shared/mappedUrlStrategy.js");
|
|
43
|
+
const urlStrategy_js_namespaceObject = require("../shared/urlStrategy.js");
|
|
42
44
|
const getPathname = (context)=>{
|
|
43
45
|
if ((0, runtime_namespaceObject.isBrowser)()) return window.location.pathname;
|
|
44
46
|
return context.ssrContext?.request?.pathname || '/';
|
|
@@ -56,7 +58,8 @@ const getLanguageFromPath = (pathname, languages, fallbackLanguage)=>{
|
|
|
56
58
|
};
|
|
57
59
|
const buildLocalizedUrl = (target, language, languages, urlStrategy)=>{
|
|
58
60
|
const { pathname, search, hash } = (0, url_namespaceObject.splitUrlTarget)(target);
|
|
59
|
-
|
|
61
|
+
const strategy = (0, urlStrategy_js_namespaceObject.asI18nUrlStrategy)(urlStrategy);
|
|
62
|
+
if (strategy) return `${strategy.localizePathname(pathname, language, languages)}${search}${hash}`;
|
|
60
63
|
const segments = pathname.split('/').filter(Boolean);
|
|
61
64
|
if (segments[0] && languages.some((item)=>item.toLowerCase() === segments[0].toLowerCase())) segments[0] = language;
|
|
62
65
|
else segments.unshift(language);
|
|
@@ -81,7 +84,8 @@ const detectLanguageFromPath = (pathname, languages, localePathRedirect)=>{
|
|
|
81
84
|
};
|
|
82
85
|
};
|
|
83
86
|
const shouldIgnoreRedirect = (pathname, languages, ignoreRedirectRoutes, urlStrategy)=>{
|
|
84
|
-
if (
|
|
87
|
+
if ((0, mappedUrlStrategy_js_namespaceObject.isDefaultLocaleRedirectSkipPath)(pathname, languages)) return true;
|
|
88
|
+
if ((0, urlStrategy_js_namespaceObject.asI18nUrlStrategy)(urlStrategy)?.shouldSkipRedirect?.(pathname, languages)) return true;
|
|
85
89
|
if (!ignoreRedirectRoutes) return false;
|
|
86
90
|
const segments = pathname.split('/').filter(Boolean);
|
|
87
91
|
if (segments[0] && languages.some((item)=>item.toLowerCase() === segments[0].toLowerCase())) segments.shift();
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
createDefaultUrlStrategy: ()=>createDefaultUrlStrategy,
|
|
32
|
+
resolveDefaultUrlStrategy: ()=>resolveDefaultUrlStrategy
|
|
33
|
+
});
|
|
34
|
+
const external_mappedUrlStrategy_js_namespaceObject = require("./mappedUrlStrategy.js");
|
|
35
|
+
const createDefaultUrlStrategy = (localisedUrls)=>(0, external_mappedUrlStrategy_js_namespaceObject.createMappedUrlStrategy)(localisedUrls);
|
|
36
|
+
const resolveDefaultUrlStrategy = (localisedUrls)=>{
|
|
37
|
+
if (!localisedUrls || 'object' != typeof localisedUrls || 0 === Object.keys(localisedUrls).length) return;
|
|
38
|
+
return createDefaultUrlStrategy(localisedUrls);
|
|
39
|
+
};
|
|
40
|
+
exports.createDefaultUrlStrategy = __webpack_exports__.createDefaultUrlStrategy;
|
|
41
|
+
exports.resolveDefaultUrlStrategy = __webpack_exports__.resolveDefaultUrlStrategy;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"createDefaultUrlStrategy",
|
|
44
|
+
"resolveDefaultUrlStrategy"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
package/dist/cjs/server/index.js
CHANGED
|
@@ -34,8 +34,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
34
34
|
matchesApiPrefix: ()=>external_apiPrefix_js_namespaceObject.matchesApiPrefix
|
|
35
35
|
});
|
|
36
36
|
const hono_namespaceObject = require("@modern-js/server-core/hono");
|
|
37
|
+
const urlStrategy_js_namespaceObject = require("../shared/urlStrategy.js");
|
|
37
38
|
const utils_js_namespaceObject = require("../shared/utils.js");
|
|
38
39
|
const external_apiPrefix_js_namespaceObject = require("./apiPrefix.js");
|
|
40
|
+
const external_defaultUrlStrategy_js_namespaceObject = require("./defaultUrlStrategy.js");
|
|
39
41
|
const external_detectorOptions_js_namespaceObject = require("./detectorOptions.js");
|
|
40
42
|
const external_redirectPolicy_js_namespaceObject = require("./redirectPolicy.js");
|
|
41
43
|
const { languageDetector } = hono_namespaceObject;
|
|
@@ -61,8 +63,7 @@ const i18nServerPlugin = (options)=>({
|
|
|
61
63
|
const entryLocaleDetection = (0, utils_js_namespaceObject.getLocaleDetectionOptions)(entryName, options.localeDetection);
|
|
62
64
|
const { localePathRedirect, i18nextDetector = true, languages = [], fallbackLanguage = 'en', detection, ignoreRedirectRoutes } = entryLocaleDetection;
|
|
63
65
|
const legacyLocalisedUrls = Reflect.get(entryLocaleDetection, 'localisedUrls');
|
|
64
|
-
const urlStrategy = options.resolveUrlStrategy?.(entryName);
|
|
65
|
-
if (legacyLocalisedUrls && 'object' == typeof legacyLocalisedUrls && Object.keys(legacyLocalisedUrls).length > 0 && !urlStrategy) throw new Error('Mapped locale URLs require a URL strategy. Use the i18n integration server plugin or supply resolveUrlStrategy.');
|
|
66
|
+
const urlStrategy = (0, urlStrategy_js_namespaceObject.asI18nUrlStrategy)(options.resolveUrlStrategy?.(entryName)) ?? (0, external_defaultUrlStrategy_js_namespaceObject.resolveDefaultUrlStrategy)(legacyLocalisedUrls);
|
|
66
67
|
const staticRoutePrefixes = options.staticRoutePrefixes;
|
|
67
68
|
const originUrlPath = route.urlPath;
|
|
68
69
|
const urlPath = originUrlPath.endsWith('/') ? `${originUrlPath}*` : `${originUrlPath}/*`;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
createMappedUrlStrategy: ()=>mappedUrlStrategy_js_namespaceObject.createMappedUrlStrategy,
|
|
32
|
+
resolveMappedUrlStrategy: ()=>mappedUrlStrategy_js_namespaceObject.resolveMappedUrlStrategy
|
|
33
|
+
});
|
|
34
|
+
const mappedUrlStrategy_js_namespaceObject = require("../shared/mappedUrlStrategy.js");
|
|
35
|
+
exports.createMappedUrlStrategy = __webpack_exports__.createMappedUrlStrategy;
|
|
36
|
+
exports.resolveMappedUrlStrategy = __webpack_exports__.resolveMappedUrlStrategy;
|
|
37
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
38
|
+
"createMappedUrlStrategy",
|
|
39
|
+
"resolveMappedUrlStrategy"
|
|
40
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
41
|
+
Object.defineProperty(exports, '__esModule', {
|
|
42
|
+
value: true
|
|
43
|
+
});
|
|
@@ -27,6 +27,15 @@ var __webpack_require__ = {};
|
|
|
27
27
|
})();
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
buildLocalizedUrl: ()=>buildLocalizedUrl,
|
|
32
|
+
createLocaleRedirectResponse: ()=>createLocaleRedirectResponse,
|
|
33
|
+
getLanguageFromPath: ()=>getLanguageFromPath,
|
|
34
|
+
isStaticResourceRequest: ()=>isStaticResourceRequest,
|
|
35
|
+
shouldIgnoreRedirect: ()=>shouldIgnoreRedirect
|
|
36
|
+
});
|
|
37
|
+
const mappedUrlStrategy_js_namespaceObject = require("../shared/mappedUrlStrategy.js");
|
|
38
|
+
const urlStrategy_js_namespaceObject = require("../shared/urlStrategy.js");
|
|
30
39
|
const stripUrlPathPrefix = (pathname, urlPath)=>{
|
|
31
40
|
const basePath = urlPath.replace('/*', '');
|
|
32
41
|
if (!basePath || '/' === basePath) return pathname;
|
|
@@ -34,7 +43,8 @@ const stripUrlPathPrefix = (pathname, urlPath)=>{
|
|
|
34
43
|
};
|
|
35
44
|
const shouldIgnoreRedirect = (pathname, urlPath, ignoreRedirectRoutes, urlStrategy, languages = [])=>{
|
|
36
45
|
const remainingPath = stripUrlPathPrefix(pathname, urlPath);
|
|
37
|
-
if (
|
|
46
|
+
if ((0, mappedUrlStrategy_js_namespaceObject.isDefaultLocaleRedirectSkipPath)(remainingPath, languages)) return true;
|
|
47
|
+
if ((0, urlStrategy_js_namespaceObject.asI18nUrlStrategy)(urlStrategy)?.shouldSkipRedirect?.(remainingPath, languages)) return true;
|
|
38
48
|
if (!ignoreRedirectRoutes) return false;
|
|
39
49
|
const segments = remainingPath.split('/').filter(Boolean);
|
|
40
50
|
if (segments[0] && languages.some((language)=>language.toLowerCase() === segments[0].toLowerCase())) segments.shift();
|
|
@@ -66,7 +76,8 @@ const buildLocalizedUrl = (req, urlPath, language, languages, urlStrategy)=>{
|
|
|
66
76
|
const segments = remainingPath.split('/').filter(Boolean);
|
|
67
77
|
if (segments[0] && languages.some((item)=>item.toLowerCase() === segments[0].toLowerCase())) segments[0] = language;
|
|
68
78
|
else segments.unshift(language);
|
|
69
|
-
const
|
|
79
|
+
const strategy = (0, urlStrategy_js_namespaceObject.asI18nUrlStrategy)(urlStrategy);
|
|
80
|
+
const pathname = strategy ? strategy.localizePathname(remainingPath, language, languages) : `/${segments.join('/')}`;
|
|
70
81
|
return `${'/' === basePath ? '' : basePath}${pathname}${url.search}${url.hash}`;
|
|
71
82
|
};
|
|
72
83
|
const createLocaleRedirectResponse = (location)=>new Response(null, {
|
|
@@ -77,13 +88,6 @@ const createLocaleRedirectResponse = (location)=>new Response(null, {
|
|
|
77
88
|
Vary: 'Accept-Language, Cookie'
|
|
78
89
|
}
|
|
79
90
|
});
|
|
80
|
-
__webpack_require__.d(__webpack_exports__, {}, {
|
|
81
|
-
buildLocalizedUrl: buildLocalizedUrl,
|
|
82
|
-
createLocaleRedirectResponse: createLocaleRedirectResponse,
|
|
83
|
-
getLanguageFromPath: getLanguageFromPath,
|
|
84
|
-
isStaticResourceRequest: isStaticResourceRequest,
|
|
85
|
-
shouldIgnoreRedirect: shouldIgnoreRedirect
|
|
86
|
-
});
|
|
87
91
|
exports.buildLocalizedUrl = __webpack_exports__.buildLocalizedUrl;
|
|
88
92
|
exports.createLocaleRedirectResponse = __webpack_exports__.createLocaleRedirectResponse;
|
|
89
93
|
exports.getLanguageFromPath = __webpack_exports__.getLanguageFromPath;
|