@bleedingdev/modern-js-plugin-i18n 3.9.0-ultramodern.9 → 3.9.3-ultramodern.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/index.js +1 -1
- package/dist/cjs/cli/localisedRoutes.js +3 -2
- package/dist/cjs/runtime/context.js +6 -14
- package/dist/cjs/runtime/contexts.js +49 -0
- package/dist/cjs/runtime/core.js +8 -1
- 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/shared/detection.js +118 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localisedRoutes.mjs +3 -2
- package/dist/esm/runtime/context.mjs +2 -10
- package/dist/esm/runtime/contexts.mjs +5 -0
- package/dist/esm/runtime/core.mjs +3 -2
- 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/shared/detection.mjs +85 -1
- package/dist/esm-node/cli/index.mjs +1 -1
- package/dist/esm-node/cli/localisedRoutes.mjs +3 -2
- 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 +3 -2
- 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/shared/detection.mjs +85 -1
- package/dist/types/cli/localisedRoutes.d.ts +3 -2
- 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 +1 -0
- 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/shared/detection.d.ts +11 -1
- package/package.json +43 -25
- package/src/cli/index.ts +1 -0
- package/src/cli/localisedRoutes.ts +11 -1
- package/src/runtime/context.tsx +6 -31
- package/src/runtime/contexts.ts +16 -0
- package/src/runtime/core.tsx +12 -1
- 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/shared/detection.ts +34 -10
- package/rslib.config.mts +0 -4
- package/rstest.config.mts +0 -50
- package/tests/backendDefaults.test.ts +0 -30
- package/tests/defaultUrlStrategy.test.ts +0 -107
- package/tests/federatedI18nBoundaryResolver.test.tsx +0 -65
- package/tests/i18nUtils.test.ts +0 -60
- package/tests/link.test.tsx +0 -139
- package/tests/localisedRouteGeneration.test.ts +0 -159
- package/tests/localisedUrls.test.ts +0 -193
- package/tests/mappedUrlStrategyDerivation.test.ts +0 -62
- package/tests/reactI18nextRuntimeBoundary.test.ts +0 -117
- package/tests/redirectPolicy.test.ts +0 -107
- package/tests/routerAdapter.test.tsx +0 -221
- package/tests/urlStrategySerialization.test.ts +0 -122
- package/tsconfig.json +0 -15
package/dist/cjs/cli/index.js
CHANGED
|
@@ -84,7 +84,7 @@ const i18nPlugin = (options = {})=>({
|
|
|
84
84
|
});
|
|
85
85
|
api.modifyFileSystemRoutes(({ entrypoint, routes })=>({
|
|
86
86
|
entrypoint,
|
|
87
|
-
routes: (0, external_localisedRoutes_js_namespaceObject.applyLocalisedRoutes)(routes, localeDetection ? (0, utils_js_namespaceObject.getLocaleDetectionOptions)(entrypoint.entryName, localeDetection) : void 0)
|
|
87
|
+
routes: (0, external_localisedRoutes_js_namespaceObject.applyLocalisedRoutes)(routes, localeDetection ? (0, utils_js_namespaceObject.getLocaleDetectionOptions)(entrypoint.entryName, localeDetection) : void 0, entrypoint)
|
|
88
88
|
}));
|
|
89
89
|
api._internalServerPlugins(({ plugins })=>{
|
|
90
90
|
const { serverRoutes, metaName } = api.getAppContext();
|
|
@@ -31,11 +31,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
applyLocalisedRoutes: ()=>applyLocalisedRoutes
|
|
32
32
|
});
|
|
33
33
|
const i18n_runtime_extensions_namespaceObject = require("@modern-js/i18n-runtime-extensions");
|
|
34
|
-
const
|
|
34
|
+
const cli_namespaceObject = require("@modern-js/runtime/cli");
|
|
35
|
+
const applyLocalisedRoutes = (routes, localeDetection, entrypoint)=>{
|
|
35
36
|
const { localePathRedirect, languages = [], localisedUrls } = localeDetection ?? {};
|
|
36
37
|
const resolved = (0, i18n_runtime_extensions_namespaceObject.resolveLocalisedUrlsConfig)(localisedUrls);
|
|
37
38
|
if (!localePathRedirect || !languages.length || !resolved.enabled) return routes;
|
|
38
|
-
return (0, i18n_runtime_extensions_namespaceObject.applyLocalisedUrlsToRoutes)(routes, languages, resolved.map);
|
|
39
|
+
return (0, i18n_runtime_extensions_namespaceObject.applyLocalisedUrlsToRoutes)(routes, languages, resolved.map, entrypoint && '@modern-js/plugin-tanstack' === (0, cli_namespaceObject.getEntrypointRoutesOwner)(entrypoint) ? 'canonical' : 'physical');
|
|
39
40
|
};
|
|
40
41
|
exports.applyLocalisedRoutes = __webpack_exports__.applyLocalisedRoutes;
|
|
41
42
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -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,10 +31,12 @@ __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,
|
|
@@ -42,6 +44,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
42
44
|
});
|
|
43
45
|
const mappedUrlStrategy_js_namespaceObject = require("../shared/mappedUrlStrategy.js");
|
|
44
46
|
const urlStrategy_js_namespaceObject = require("../shared/urlStrategy.js");
|
|
47
|
+
const external_navigation_js_namespaceObject = require("./navigation.js");
|
|
45
48
|
const external_pluginSetup_js_namespaceObject = require("./pluginSetup.js");
|
|
46
49
|
const external_providerComposition_js_namespaceObject = require("./providerComposition.js");
|
|
47
50
|
const external_reactI18next_js_namespaceObject = require("./reactI18next.js");
|
|
@@ -87,7 +90,7 @@ const createI18nPlugin = (loadReactI18nextIntegration)=>(options)=>({
|
|
|
87
90
|
fallbackLanguage,
|
|
88
91
|
ignoreRedirectRoutes,
|
|
89
92
|
urlStrategy: resolvedUrlStrategy,
|
|
90
|
-
NavigationProvider,
|
|
93
|
+
NavigationProvider: NavigationProvider ?? external_navigation_js_namespaceObject.I18nRouterNavigationProvider,
|
|
91
94
|
LanguageSynchronization,
|
|
92
95
|
getLatestI18nInstance: ()=>latestI18nInstance,
|
|
93
96
|
getI18nextProvider: ()=>I18nextProvider
|
|
@@ -97,10 +100,12 @@ const createI18nPlugin = (loadReactI18nextIntegration)=>(options)=>({
|
|
|
97
100
|
exports.FederatedI18nBoundary = __webpack_exports__.FederatedI18nBoundary;
|
|
98
101
|
exports.I18nLink = __webpack_exports__.I18nLink;
|
|
99
102
|
exports.I18nNavigationProvider = __webpack_exports__.I18nNavigationProvider;
|
|
103
|
+
exports.I18nRouterNavigationProvider = __webpack_exports__.I18nRouterNavigationProvider;
|
|
100
104
|
exports.Link = __webpack_exports__.Link;
|
|
101
105
|
exports.createI18nPlugin = __webpack_exports__.createI18nPlugin;
|
|
102
106
|
exports.splitUrlTarget = __webpack_exports__.splitUrlTarget;
|
|
103
107
|
exports.useI18nRouterAdapter = __webpack_exports__.useI18nRouterAdapter;
|
|
108
|
+
exports.useIntegratedRouterAdapter = __webpack_exports__.useIntegratedRouterAdapter;
|
|
104
109
|
exports.useLocalizedLocation = __webpack_exports__.useLocalizedLocation;
|
|
105
110
|
exports.useLocalizedPaths = __webpack_exports__.useLocalizedPaths;
|
|
106
111
|
exports.useModernI18n = __webpack_exports__.useModernI18n;
|
|
@@ -109,10 +114,12 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
109
114
|
"FederatedI18nBoundary",
|
|
110
115
|
"I18nLink",
|
|
111
116
|
"I18nNavigationProvider",
|
|
117
|
+
"I18nRouterNavigationProvider",
|
|
112
118
|
"Link",
|
|
113
119
|
"createI18nPlugin",
|
|
114
120
|
"splitUrlTarget",
|
|
115
121
|
"useI18nRouterAdapter",
|
|
122
|
+
"useIntegratedRouterAdapter",
|
|
116
123
|
"useLocalizedLocation",
|
|
117
124
|
"useLocalizedPaths",
|
|
118
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
|
+
});
|
|
@@ -1,7 +1,123 @@
|
|
|
1
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
|
+
})();
|
|
2
28
|
var __webpack_exports__ = {};
|
|
3
|
-
|
|
4
|
-
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
detectLanguageFromRequest: ()=>detectLanguageFromRequest
|
|
32
|
+
});
|
|
33
|
+
const config_js_namespaceObject = require("../runtime/i18n/detection/config.js");
|
|
34
|
+
function detectLanguageFromRequest(req, languages, detectionOptions) {
|
|
35
|
+
try {
|
|
36
|
+
const mergedDetection = detectionOptions ? (0, config_js_namespaceObject.mergeDetectionOptions)(detectionOptions) : config_js_namespaceObject.DEFAULT_I18NEXT_DETECTION_OPTIONS;
|
|
37
|
+
const order = (mergedDetection.order || []).filter((item)=>![
|
|
38
|
+
'path',
|
|
39
|
+
'localStorage',
|
|
40
|
+
'navigator',
|
|
41
|
+
'htmlTag',
|
|
42
|
+
'subdomain'
|
|
43
|
+
].includes(item));
|
|
44
|
+
const detectionOrder = order.length > 0 ? order : [
|
|
45
|
+
'querystring',
|
|
46
|
+
'cookie',
|
|
47
|
+
'header'
|
|
48
|
+
];
|
|
49
|
+
const getHeader = (name)=>{
|
|
50
|
+
const headers = req.headers;
|
|
51
|
+
if ('function' == typeof headers?.get) return headers.get(name);
|
|
52
|
+
const value = headers[name.toLowerCase()];
|
|
53
|
+
if (Array.isArray(value)) return value[0] ?? null;
|
|
54
|
+
return value ?? null;
|
|
55
|
+
};
|
|
56
|
+
for (const method of detectionOrder){
|
|
57
|
+
let detectedLang = null;
|
|
58
|
+
switch(method){
|
|
59
|
+
case 'querystring':
|
|
60
|
+
{
|
|
61
|
+
const lookupKey = mergedDetection.lookupQuerystring || config_js_namespaceObject.DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupQuerystring || 'lng';
|
|
62
|
+
const host = getHeader('host') || 'localhost';
|
|
63
|
+
const url = new URL(req.url, `http://${host}`);
|
|
64
|
+
detectedLang = url.searchParams.get(lookupKey);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case 'cookie':
|
|
68
|
+
{
|
|
69
|
+
const lookupKey = mergedDetection.lookupCookie || config_js_namespaceObject.DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupCookie || 'i18next';
|
|
70
|
+
const cookieHeader = getHeader('Cookie');
|
|
71
|
+
if (cookieHeader) {
|
|
72
|
+
const cookies = cookieHeader.split(';').reduce((acc, item)=>{
|
|
73
|
+
const [key, value] = item.trim().split('=');
|
|
74
|
+
if (key && value) acc[key] = value;
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
detectedLang = cookies[lookupKey] || null;
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'header':
|
|
82
|
+
{
|
|
83
|
+
const lookupKey = mergedDetection.lookupHeader || config_js_namespaceObject.DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupHeader || 'accept-language';
|
|
84
|
+
const acceptLanguage = getHeader(lookupKey);
|
|
85
|
+
if (acceptLanguage) {
|
|
86
|
+
const languagesList = acceptLanguage.split(',').map((lang)=>{
|
|
87
|
+
const [code, q] = lang.trim().split(';');
|
|
88
|
+
return {
|
|
89
|
+
code,
|
|
90
|
+
baseCode: code.split('-')[0],
|
|
91
|
+
quality: q ? parseFloat(q.split('=')[1]) : 1.0
|
|
92
|
+
};
|
|
93
|
+
}).sort((a, b)=>b.quality - a.quality);
|
|
94
|
+
for (const lang of languagesList){
|
|
95
|
+
if (0 === languages.length || languages.includes(lang.code)) {
|
|
96
|
+
detectedLang = lang.code;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (languages.includes(lang.baseCode)) {
|
|
100
|
+
detectedLang = lang.baseCode;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (detectedLang && (0 === languages.length || languages.includes(detectedLang))) return detectedLang;
|
|
109
|
+
if (detectedLang) {
|
|
110
|
+
const baseLang = detectedLang.split('-')[0];
|
|
111
|
+
if (languages.includes(baseLang)) return baseLang;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
exports.detectLanguageFromRequest = __webpack_exports__.detectLanguageFromRequest;
|
|
118
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
119
|
+
"detectLanguageFromRequest"
|
|
120
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
5
121
|
Object.defineProperty(exports, '__esModule', {
|
|
6
122
|
value: true
|
|
7
123
|
});
|
package/dist/esm/cli/index.mjs
CHANGED
|
@@ -51,7 +51,7 @@ const i18nPlugin = (options = {})=>({
|
|
|
51
51
|
});
|
|
52
52
|
api.modifyFileSystemRoutes(({ entrypoint, routes })=>({
|
|
53
53
|
entrypoint,
|
|
54
|
-
routes: applyLocalisedRoutes(routes, localeDetection ? getLocaleDetectionOptions(entrypoint.entryName, localeDetection) : void 0)
|
|
54
|
+
routes: applyLocalisedRoutes(routes, localeDetection ? getLocaleDetectionOptions(entrypoint.entryName, localeDetection) : void 0, entrypoint)
|
|
55
55
|
}));
|
|
56
56
|
api._internalServerPlugins(({ plugins })=>{
|
|
57
57
|
const { serverRoutes, metaName } = api.getAppContext();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { applyLocalisedUrlsToRoutes, resolveLocalisedUrlsConfig } from "@modern-js/i18n-runtime-extensions";
|
|
2
|
-
|
|
2
|
+
import { getEntrypointRoutesOwner } from "@modern-js/runtime/cli";
|
|
3
|
+
const applyLocalisedRoutes = (routes, localeDetection, entrypoint)=>{
|
|
3
4
|
const { localePathRedirect, languages = [], localisedUrls } = localeDetection ?? {};
|
|
4
5
|
const resolved = resolveLocalisedUrlsConfig(localisedUrls);
|
|
5
6
|
if (!localePathRedirect || !languages.length || !resolved.enabled) return routes;
|
|
6
|
-
return applyLocalisedUrlsToRoutes(routes, languages, resolved.map);
|
|
7
|
+
return applyLocalisedUrlsToRoutes(routes, languages, resolved.map, entrypoint && '@modern-js/plugin-tanstack' === getEntrypointRoutesOwner(entrypoint) ? 'canonical' : 'physical');
|
|
7
8
|
};
|
|
8
9
|
export { applyLocalisedRoutes };
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RuntimeComponentResolverContext } from "@modern-js/runtime/context";
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback, useContext, useEffect, useMemo } from "react";
|
|
4
4
|
import { changeModernI18nLanguage, getPathLanguage, isI18nLanguageSupported, isI18nResourcesReady, translateI18n } from "./contextHelpers.mjs";
|
|
5
5
|
import { useI18nRouterAdapter } from "./routerAdapter.mjs";
|
|
6
|
-
|
|
7
|
-
const reactI18nextProviderContextKey = Symbol.for('@modern-js/plugin-i18n/runtime/ReactI18nextProviderContext');
|
|
8
|
-
const getGlobalContext = (key, defaultValue)=>{
|
|
9
|
-
const globalStore = globalThis;
|
|
10
|
-
globalStore[key] ??= /*#__PURE__*/ createContext(defaultValue);
|
|
11
|
-
return globalStore[key];
|
|
12
|
-
};
|
|
13
|
-
const ModernI18nContext = getGlobalContext(modernI18nContextKey, null);
|
|
14
|
-
const ReactI18nextProviderContext = getGlobalContext(reactI18nextProviderContextKey, null);
|
|
6
|
+
import { ModernI18nContext, ReactI18nextProviderContext } from "./sharedContexts.mjs";
|
|
15
7
|
const ModernI18nProvider = ({ children, i18nextProvider, value })=>{
|
|
16
8
|
const content = /*#__PURE__*/ jsx(ModernI18nContext.Provider, {
|
|
17
9
|
value: value,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
const ModernI18nContext = createContext(null);
|
|
3
|
+
const ReactI18nextProviderContext = createContext(null);
|
|
4
|
+
const I18nNavigationContext = createContext(null);
|
|
5
|
+
export { I18nNavigationContext, ModernI18nContext, ReactI18nextProviderContext };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveMappedUrlStrategy } from "../shared/mappedUrlStrategy.mjs";
|
|
2
2
|
import { asI18nUrlStrategy } from "../shared/urlStrategy.mjs";
|
|
3
|
+
import { I18nRouterNavigationProvider, useIntegratedRouterAdapter } from "./navigation.mjs";
|
|
3
4
|
import { setupI18nBeforeRender } from "./pluginSetup.mjs";
|
|
4
5
|
import { createI18nRootWrapper } from "./providerComposition.mjs";
|
|
5
6
|
import { resolveReactI18nextIntegration } from "./reactI18next.mjs";
|
|
@@ -39,7 +40,7 @@ const createI18nPlugin = (loadReactI18nextIntegration)=>(options)=>({
|
|
|
39
40
|
fallbackLanguage,
|
|
40
41
|
ignoreRedirectRoutes,
|
|
41
42
|
urlStrategy: resolvedUrlStrategy,
|
|
42
|
-
NavigationProvider,
|
|
43
|
+
NavigationProvider: NavigationProvider ?? I18nRouterNavigationProvider,
|
|
43
44
|
LanguageSynchronization,
|
|
44
45
|
getLatestI18nInstance: ()=>latestI18nInstance,
|
|
45
46
|
getI18nextProvider: ()=>I18nextProvider
|
|
@@ -52,4 +53,4 @@ export { I18nLink } from "./I18nLink.mjs";
|
|
|
52
53
|
export { Link } from "./Link.mjs";
|
|
53
54
|
export { useLocalizedLocation, useLocalizedPaths } from "./localizedPaths.mjs";
|
|
54
55
|
export { splitUrlTarget } from "./utils.mjs";
|
|
55
|
-
export { createI18nPlugin };
|
|
56
|
+
export { I18nRouterNavigationProvider, createI18nPlugin, useIntegratedRouterAdapter };
|
|
@@ -11,7 +11,7 @@ const useI18nextLanguageDetector = (i18nInstance)=>{
|
|
|
11
11
|
}
|
|
12
12
|
return i18nInstance;
|
|
13
13
|
};
|
|
14
|
-
const readLanguageFromStorage = (detectionOptions)=>{
|
|
14
|
+
const readLanguageFromStorage = (detectionOptions, _request, _languages)=>{
|
|
15
15
|
try {
|
|
16
16
|
const options = detectionOptions || {};
|
|
17
17
|
const order = options.order || [
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { LanguageDetector } from "i18next-http-middleware";
|
|
2
|
+
import { detectLanguageFromRequest } from "../../../shared/detection.mjs";
|
|
3
|
+
const isDetectionRequest = (request)=>{
|
|
4
|
+
if (!request || 'object' != typeof request) return false;
|
|
5
|
+
const { url, headers } = request;
|
|
6
|
+
return 'string' == typeof url && !!headers && 'object' == typeof headers;
|
|
7
|
+
};
|
|
2
8
|
const cacheUserLanguage = (_i18nInstance, _language, _detectionOptions)=>{};
|
|
3
|
-
const readLanguageFromStorage = (
|
|
9
|
+
const readLanguageFromStorage = (detectionOptions, request, languages = [])=>{
|
|
10
|
+
if (!isDetectionRequest(request)) return;
|
|
11
|
+
return detectLanguageFromRequest(request, languages, detectionOptions) ?? void 0;
|
|
12
|
+
};
|
|
4
13
|
const useI18nextLanguageDetector = (i18nInstance)=>{
|
|
5
14
|
if (!i18nInstance.isInitialized) return i18nInstance.use(LanguageDetector);
|
|
6
15
|
return i18nInstance;
|
|
@@ -9,7 +9,7 @@ const detectLanguageWithPriority = async (i18nInstance, options)=>{
|
|
|
9
9
|
let detectedLanguage;
|
|
10
10
|
detectedLanguage = detectLanguageFromPathPriority(pathname, languages, localePathRedirect);
|
|
11
11
|
if (!detectedLanguage) detectedLanguage = detectLanguageFromSSR(languages);
|
|
12
|
-
if (!detectedLanguage && i18nextDetector) detectedLanguage = isI18nWrapperInstance(i18nInstance) ? readLanguageFromStorage(mergeDetectionOptions(i18nextDetector, detection, localePathRedirect, userInitOptions)) : await detectLanguageFromI18nextDetector(i18nInstance, {
|
|
12
|
+
if (!detectedLanguage && i18nextDetector) detectedLanguage = isI18nWrapperInstance(i18nInstance) ? readLanguageFromStorage(mergeDetectionOptions(i18nextDetector, detection, localePathRedirect, userInitOptions), ssrContext?.request, languages) : await detectLanguageFromI18nextDetector(i18nInstance, {
|
|
13
13
|
languages,
|
|
14
14
|
fallbackLanguage,
|
|
15
15
|
localePathRedirect,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createI18nRouterNavigation } from "@modern-js/i18n-runtime-extensions/router-navigation";
|
|
2
|
+
import { I18nNavigationProvider, useNativeI18nRouterAdapter } from "./routerAdapter.mjs";
|
|
3
|
+
const { I18nRouterNavigationProvider: I18nRouterNavigationProvider, useIntegratedRouterAdapter: useIntegratedRouterAdapter } = createI18nRouterNavigation({
|
|
4
|
+
I18nNavigationProvider: I18nNavigationProvider,
|
|
5
|
+
useNativeI18nRouterAdapter: useNativeI18nRouterAdapter
|
|
6
|
+
});
|
|
7
|
+
export { I18nRouterNavigationProvider, useIntegratedRouterAdapter };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { I18nNavigationContext } from "@modern-js/plugin-i18n/runtime/contexts";
|
|
2
3
|
import { RuntimeContext, isBrowser } from "@modern-js/runtime";
|
|
3
4
|
import { InternalRuntimeContext } from "@modern-js/runtime/context";
|
|
4
|
-
import {
|
|
5
|
-
const navigationContextKey = Symbol.for('@modern-js/plugin-i18n/runtime/I18nNavigationContext');
|
|
6
|
-
const contextStore = globalThis;
|
|
7
|
-
const I18nNavigationContext = contextStore[navigationContextKey] ??= /*#__PURE__*/ createContext(null);
|
|
5
|
+
import { useContext } from "react";
|
|
8
6
|
const I18nNavigationProvider = ({ children, value })=>/*#__PURE__*/ jsx(I18nNavigationContext.Provider, {
|
|
9
7
|
value: value,
|
|
10
8
|
children: children
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ModernI18nContext, ReactI18nextProviderContext } from "@modern-js/plugin-i18n/runtime/contexts";
|