@modern-js/plugin-i18n 3.9.3 → 3.10.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/runtime/i18n/instance.js +12 -14
- package/dist/cjs/runtime/utils.js +72 -88
- package/dist/esm/runtime/i18n/instance.mjs +12 -14
- package/dist/esm/runtime/utils.mjs +1 -7
- package/dist/esm-node/runtime/i18n/instance.mjs +12 -14
- package/dist/esm-node/runtime/utils.mjs +1 -9
- package/dist/types/runtime/i18n/index.d.ts +1 -1
- package/dist/types/runtime/utils.d.ts +8 -3
- package/package.json +18 -19
- package/rstack.config.mts +4 -0
- package/src/runtime/i18n/backend/sdk-event.ts +1 -2
- package/src/runtime/i18n/index.ts +1 -4
- package/src/runtime/i18n/instance.ts +10 -17
- package/src/runtime/utils.ts +1 -5
- package/src/shared/utils.ts +1 -2
- package/dist/esm/rslib-runtime~1.mjs +0 -18
- package/dist/esm-node/rslib-runtime~0.mjs +0 -19
- package/rslib.config.mts +0 -4
|
@@ -69,14 +69,6 @@ async function createI18nextInstance() {
|
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
async function tryImportReactI18next() {
|
|
73
|
-
try {
|
|
74
|
-
const reactI18next = await import("react-i18next");
|
|
75
|
-
return reactI18next;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
72
|
function getI18nextInstanceForProvider(instance) {
|
|
81
73
|
if (isI18nWrapperInstance(instance)) {
|
|
82
74
|
const i18nextInstance = getI18nWrapperI18nextInstance(instance);
|
|
@@ -94,14 +86,20 @@ async function getI18nInstance(userInstance) {
|
|
|
94
86
|
throw new Error('No i18n instance found');
|
|
95
87
|
}
|
|
96
88
|
async function getInitReactI18next() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
try {
|
|
90
|
+
const { initReactI18next } = await import("react-i18next");
|
|
91
|
+
return initReactI18next;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
100
95
|
}
|
|
101
96
|
async function getI18nextProvider() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
try {
|
|
98
|
+
const { I18nextProvider } = await import("react-i18next");
|
|
99
|
+
return I18nextProvider;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
105
103
|
}
|
|
106
104
|
__webpack_require__.d(__webpack_exports__, {
|
|
107
105
|
getActualI18nextInstance: ()=>getActualI18nextInstance,
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
"@modern-js/runtime/router" (module) {
|
|
4
|
-
module.exports = require("@modern-js/runtime/router");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
var __webpack_module_cache__ = {};
|
|
8
|
-
function __webpack_require__(moduleId) {
|
|
9
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
-
exports: {}
|
|
13
|
-
};
|
|
14
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
-
return module.exports;
|
|
16
|
-
}
|
|
2
|
+
var __webpack_require__ = {};
|
|
17
3
|
(()=>{
|
|
18
4
|
__webpack_require__.d = (exports1, getters, values)=>{
|
|
19
5
|
var define = (defs, kind)=>{
|
|
@@ -40,85 +26,83 @@ function __webpack_require__(moduleId) {
|
|
|
40
26
|
};
|
|
41
27
|
})();
|
|
42
28
|
var __webpack_exports__ = {};
|
|
43
|
-
(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
buildLocalizedUrl: ()=>buildLocalizedUrl,
|
|
32
|
+
detectLanguageFromPath: ()=>detectLanguageFromPath,
|
|
33
|
+
getEntryPath: ()=>getEntryPath,
|
|
34
|
+
getLanguageFromPath: ()=>getLanguageFromPath,
|
|
35
|
+
getPathname: ()=>getPathname,
|
|
36
|
+
shouldIgnoreRedirect: ()=>shouldIgnoreRedirect,
|
|
37
|
+
useRouterHooks: ()=>useRouterHooks
|
|
38
|
+
});
|
|
39
|
+
const runtime_namespaceObject = require("@modern-js/runtime");
|
|
40
|
+
const context_namespaceObject = require("@modern-js/runtime/context");
|
|
41
|
+
const router_namespaceObject = require("@modern-js/runtime/router");
|
|
42
|
+
const getPathname = (context)=>{
|
|
43
|
+
if ((0, runtime_namespaceObject.isBrowser)()) return window.location.pathname;
|
|
44
|
+
return context.ssrContext?.request?.pathname || '/';
|
|
45
|
+
};
|
|
46
|
+
const getEntryPath = ()=>{
|
|
47
|
+
const basename = (0, context_namespaceObject.getGlobalBasename)();
|
|
48
|
+
if (basename) return '/' === basename ? '' : basename;
|
|
49
|
+
return '';
|
|
50
|
+
};
|
|
51
|
+
const getLanguageFromPath = (pathname, languages, fallbackLanguage)=>{
|
|
52
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
53
|
+
const firstSegment = segments[0];
|
|
54
|
+
if (languages.includes(firstSegment)) return firstSegment;
|
|
55
|
+
return fallbackLanguage;
|
|
56
|
+
};
|
|
57
|
+
const buildLocalizedUrl = (pathname, language, languages)=>{
|
|
58
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
59
|
+
if (segments.length > 0 && languages.includes(segments[0])) segments[0] = language;
|
|
60
|
+
else segments.unshift(language);
|
|
61
|
+
return `/${segments.join('/')}`;
|
|
62
|
+
};
|
|
63
|
+
const detectLanguageFromPath = (pathname, languages, localePathRedirect)=>{
|
|
64
|
+
if (!localePathRedirect) return {
|
|
65
|
+
detected: false
|
|
64
66
|
};
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const entryPath = getEntryPath();
|
|
68
|
+
const relativePath = pathname.replace(entryPath, '');
|
|
69
|
+
const segments = relativePath.split('/').filter(Boolean);
|
|
70
|
+
const segmentsToCheck = !entryPath && segments.length > 1 && segments[0] && !languages.includes(segments[0]) ? segments.slice(1) : segments;
|
|
71
|
+
const firstSegment = segmentsToCheck[0];
|
|
72
|
+
if (firstSegment && languages.includes(firstSegment)) return {
|
|
73
|
+
detected: true,
|
|
74
|
+
language: firstSegment
|
|
70
75
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (segments.length > 0 && languages.includes(segments[0])) segments[0] = language;
|
|
74
|
-
else segments.unshift(language);
|
|
75
|
-
return `/${segments.join('/')}`;
|
|
76
|
+
return {
|
|
77
|
+
detected: false
|
|
76
78
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
};
|
|
80
|
+
const shouldIgnoreRedirect = (pathname, languages, ignoreRedirectRoutes)=>{
|
|
81
|
+
if (!ignoreRedirectRoutes) return false;
|
|
82
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
83
|
+
let pathWithoutLang = pathname;
|
|
84
|
+
if (segments.length > 0 && languages.includes(segments[0])) pathWithoutLang = `/${segments.slice(1).join('/')}`;
|
|
85
|
+
const normalizedPath = pathWithoutLang.startsWith('/') ? pathWithoutLang : `/${pathWithoutLang}`;
|
|
86
|
+
if ('function' == typeof ignoreRedirectRoutes) return ignoreRedirectRoutes(normalizedPath);
|
|
87
|
+
return ignoreRedirectRoutes.some((pattern)=>normalizedPath === pattern || normalizedPath.startsWith(`${pattern}/`));
|
|
88
|
+
};
|
|
89
|
+
const useRouterHooks = ()=>{
|
|
90
|
+
try {
|
|
91
|
+
return {
|
|
92
|
+
navigate: (0, router_namespaceObject.useNavigate)(),
|
|
93
|
+
location: (0, router_namespaceObject.useLocation)(),
|
|
94
|
+
params: (0, router_namespaceObject.useParams)(),
|
|
95
|
+
hasRouter: true
|
|
89
96
|
};
|
|
97
|
+
} catch (error) {
|
|
90
98
|
return {
|
|
91
|
-
|
|
99
|
+
navigate: null,
|
|
100
|
+
location: null,
|
|
101
|
+
params: {},
|
|
102
|
+
hasRouter: false
|
|
92
103
|
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!ignoreRedirectRoutes) return false;
|
|
96
|
-
const segments = pathname.split('/').filter(Boolean);
|
|
97
|
-
let pathWithoutLang = pathname;
|
|
98
|
-
if (segments.length > 0 && languages.includes(segments[0])) pathWithoutLang = `/${segments.slice(1).join('/')}`;
|
|
99
|
-
const normalizedPath = pathWithoutLang.startsWith('/') ? pathWithoutLang : `/${pathWithoutLang}`;
|
|
100
|
-
if ('function' == typeof ignoreRedirectRoutes) return ignoreRedirectRoutes(normalizedPath);
|
|
101
|
-
return ignoreRedirectRoutes.some((pattern)=>normalizedPath === pattern || normalizedPath.startsWith(`${pattern}/`));
|
|
102
|
-
};
|
|
103
|
-
const useRouterHooks = ()=>{
|
|
104
|
-
try {
|
|
105
|
-
const { useLocation, useNavigate, useParams } = __webpack_require__("@modern-js/runtime/router");
|
|
106
|
-
return {
|
|
107
|
-
navigate: useNavigate(),
|
|
108
|
-
location: useLocation(),
|
|
109
|
-
params: useParams(),
|
|
110
|
-
hasRouter: true
|
|
111
|
-
};
|
|
112
|
-
} catch (error) {
|
|
113
|
-
return {
|
|
114
|
-
navigate: null,
|
|
115
|
-
location: null,
|
|
116
|
-
params: {},
|
|
117
|
-
hasRouter: false
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
})();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
122
106
|
exports.buildLocalizedUrl = __webpack_exports__.buildLocalizedUrl;
|
|
123
107
|
exports.detectLanguageFromPath = __webpack_exports__.detectLanguageFromPath;
|
|
124
108
|
exports.getEntryPath = __webpack_exports__.getEntryPath;
|
|
@@ -40,14 +40,6 @@ async function createI18nextInstance() {
|
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
async function tryImportReactI18next() {
|
|
44
|
-
try {
|
|
45
|
-
const reactI18next = await import("react-i18next");
|
|
46
|
-
return reactI18next;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
43
|
function getI18nextInstanceForProvider(instance) {
|
|
52
44
|
if (isI18nWrapperInstance(instance)) {
|
|
53
45
|
const i18nextInstance = getI18nWrapperI18nextInstance(instance);
|
|
@@ -65,13 +57,19 @@ async function getI18nInstance(userInstance) {
|
|
|
65
57
|
throw new Error('No i18n instance found');
|
|
66
58
|
}
|
|
67
59
|
async function getInitReactI18next() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
try {
|
|
61
|
+
const { initReactI18next } = await import("react-i18next");
|
|
62
|
+
return initReactI18next;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
71
66
|
}
|
|
72
67
|
async function getI18nextProvider() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
try {
|
|
69
|
+
const { I18nextProvider } = await import("react-i18next");
|
|
70
|
+
return I18nextProvider;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
76
74
|
}
|
|
77
75
|
export { getActualI18nextInstance, getI18nInstance, getI18nWrapperI18nextInstance, getI18nextInstanceForProvider, getI18nextProvider, getInitReactI18next, isI18nInstance, isI18nWrapperInstance };
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { isBrowser } from "@modern-js/runtime";
|
|
2
2
|
import { getGlobalBasename } from "@modern-js/runtime/context";
|
|
3
|
-
import {
|
|
4
|
-
__webpack_require__.add({
|
|
5
|
-
He (module) {
|
|
6
|
-
module.exports = require("@modern-js/runtime/router");
|
|
7
|
-
}
|
|
8
|
-
});
|
|
3
|
+
import { useLocation, useNavigate, useParams } from "@modern-js/runtime/router";
|
|
9
4
|
const getPathname = (context)=>{
|
|
10
5
|
if (isBrowser()) return window.location.pathname;
|
|
11
6
|
return context.ssrContext?.request?.pathname || '/';
|
|
@@ -55,7 +50,6 @@ const shouldIgnoreRedirect = (pathname, languages, ignoreRedirectRoutes)=>{
|
|
|
55
50
|
};
|
|
56
51
|
const useRouterHooks = ()=>{
|
|
57
52
|
try {
|
|
58
|
-
const { useLocation, useNavigate, useParams } = __webpack_require__("He");
|
|
59
53
|
return {
|
|
60
54
|
navigate: useNavigate(),
|
|
61
55
|
location: useLocation(),
|
|
@@ -41,14 +41,6 @@ async function createI18nextInstance() {
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
async function tryImportReactI18next() {
|
|
45
|
-
try {
|
|
46
|
-
const reactI18next = await import("react-i18next");
|
|
47
|
-
return reactI18next;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
44
|
function getI18nextInstanceForProvider(instance) {
|
|
53
45
|
if (isI18nWrapperInstance(instance)) {
|
|
54
46
|
const i18nextInstance = getI18nWrapperI18nextInstance(instance);
|
|
@@ -66,13 +58,19 @@ async function getI18nInstance(userInstance) {
|
|
|
66
58
|
throw new Error('No i18n instance found');
|
|
67
59
|
}
|
|
68
60
|
async function getInitReactI18next() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
try {
|
|
62
|
+
const { initReactI18next } = await import("react-i18next");
|
|
63
|
+
return initReactI18next;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
72
67
|
}
|
|
73
68
|
async function getI18nextProvider() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
try {
|
|
70
|
+
const { I18nextProvider } = await import("react-i18next");
|
|
71
|
+
return I18nextProvider;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
77
75
|
}
|
|
78
76
|
export { getActualI18nextInstance, getI18nInstance, getI18nWrapperI18nextInstance, getI18nextInstanceForProvider, getI18nextProvider, getInitReactI18next, isI18nInstance, isI18nWrapperInstance };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { isBrowser } from "@modern-js/runtime";
|
|
3
3
|
import { getGlobalBasename } from "@modern-js/runtime/context";
|
|
4
|
-
import {
|
|
5
|
-
import { createRequire as __rspack_createRequire } from "node:module";
|
|
6
|
-
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
7
|
-
__webpack_require__.add({
|
|
8
|
-
"@modern-js/runtime/router?a7f7" (module) {
|
|
9
|
-
module.exports = __rspack_createRequire_require("@modern-js/runtime/router");
|
|
10
|
-
}
|
|
11
|
-
});
|
|
4
|
+
import { useLocation, useNavigate, useParams } from "@modern-js/runtime/router";
|
|
12
5
|
const getPathname = (context)=>{
|
|
13
6
|
if (isBrowser()) return window.location.pathname;
|
|
14
7
|
return context.ssrContext?.request?.pathname || '/';
|
|
@@ -58,7 +51,6 @@ const shouldIgnoreRedirect = (pathname, languages, ignoreRedirectRoutes)=>{
|
|
|
58
51
|
};
|
|
59
52
|
const useRouterHooks = ()=>{
|
|
60
53
|
try {
|
|
61
|
-
const { useLocation, useNavigate, useParams } = __webpack_require__("@modern-js/runtime/router?a7f7");
|
|
62
54
|
return {
|
|
63
55
|
navigate: useNavigate(),
|
|
64
56
|
location: useLocation(),
|
|
@@ -26,8 +26,13 @@ export declare const detectLanguageFromPath: (pathname: string, languages: strin
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const shouldIgnoreRedirect: (pathname: string, languages: string[], ignoreRedirectRoutes?: string[] | ((pathname: string) => boolean)) => boolean;
|
|
28
28
|
export declare const useRouterHooks: () => {
|
|
29
|
-
navigate:
|
|
30
|
-
location: any
|
|
31
|
-
params:
|
|
29
|
+
navigate: import("@modern-js/runtime/router").NavigateFunction;
|
|
30
|
+
location: import("@modern-js/runtime/router").Location<any>;
|
|
31
|
+
params: Readonly<import("@modern-js/runtime/router").Params<string>>;
|
|
32
|
+
hasRouter: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
navigate: null;
|
|
35
|
+
location: null;
|
|
36
|
+
params: {};
|
|
32
37
|
hasRouter: boolean;
|
|
33
38
|
};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.10.1",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
@@ -82,22 +82,22 @@
|
|
|
82
82
|
"@swc/helpers": "^0.5.17",
|
|
83
83
|
"i18next-browser-languagedetector": "^8.2.1",
|
|
84
84
|
"i18next-chained-backend": "^4.6.3",
|
|
85
|
-
"i18next-fs-backend": "^2.6.
|
|
86
|
-
"i18next-http-backend": "^
|
|
85
|
+
"i18next-fs-backend": "^2.6.9",
|
|
86
|
+
"i18next-http-backend": "^4.0.4",
|
|
87
87
|
"i18next-http-middleware": "^3.9.9",
|
|
88
|
-
"@modern-js/plugin": "3.
|
|
89
|
-
"@modern-js/
|
|
90
|
-
"@modern-js/
|
|
91
|
-
"@modern-js/server-runtime": "3.
|
|
92
|
-
"@modern-js/types": "3.
|
|
93
|
-
"@modern-js/utils": "3.
|
|
88
|
+
"@modern-js/plugin": "3.10.1",
|
|
89
|
+
"@modern-js/runtime-utils": "3.10.1",
|
|
90
|
+
"@modern-js/server-core": "3.10.1",
|
|
91
|
+
"@modern-js/server-runtime": "3.10.1",
|
|
92
|
+
"@modern-js/types": "3.10.1",
|
|
93
|
+
"@modern-js/utils": "3.10.1"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"react": ">=18.3.1",
|
|
97
97
|
"react-dom": ">=18.3.1",
|
|
98
|
-
"i18next": ">=25.
|
|
98
|
+
"i18next": ">=25.10.10",
|
|
99
99
|
"react-i18next": ">=15.7.4",
|
|
100
|
-
"@modern-js/runtime": "^3.
|
|
100
|
+
"@modern-js/runtime": "^3.10.1"
|
|
101
101
|
},
|
|
102
102
|
"peerDependenciesMeta": {
|
|
103
103
|
"i18next": {
|
|
@@ -108,17 +108,16 @@
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@rslib/core": "1.0.1",
|
|
112
111
|
"@types/node": "^20",
|
|
113
|
-
"i18next": "25.
|
|
114
|
-
"react": "^19.
|
|
115
|
-
"react-dom": "^19.
|
|
112
|
+
"i18next": "25.10.10",
|
|
113
|
+
"react": "^19.3.1",
|
|
114
|
+
"react-dom": "^19.3.1",
|
|
116
115
|
"react-i18next": "15.7.4",
|
|
117
116
|
"ts-node": "^10.9.2",
|
|
118
117
|
"typescript": "^5",
|
|
119
|
-
"@modern-js/app-tools": "3.
|
|
118
|
+
"@modern-js/app-tools": "3.10.1",
|
|
120
119
|
"@modern-js/rslib": "2.68.10",
|
|
121
|
-
"@modern-js/runtime": "3.
|
|
120
|
+
"@modern-js/runtime": "3.10.1"
|
|
122
121
|
},
|
|
123
122
|
"sideEffects": false,
|
|
124
123
|
"publishConfig": {
|
|
@@ -126,8 +125,8 @@
|
|
|
126
125
|
"access": "public"
|
|
127
126
|
},
|
|
128
127
|
"scripts": {
|
|
129
|
-
"dev": "
|
|
130
|
-
"build": "
|
|
128
|
+
"dev": "rs lib --watch",
|
|
129
|
+
"build": "rs lib",
|
|
131
130
|
"test": "rstest"
|
|
132
131
|
}
|
|
133
132
|
}
|
|
@@ -167,15 +167,6 @@ async function createI18nextInstance(): Promise<I18nInstance | null> {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
async function tryImportReactI18next() {
|
|
171
|
-
try {
|
|
172
|
-
const reactI18next = await import('react-i18next');
|
|
173
|
-
return reactI18next;
|
|
174
|
-
} catch (error) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
170
|
export function getI18nextInstanceForProvider(
|
|
180
171
|
instance: I18nInstance | any,
|
|
181
172
|
): any {
|
|
@@ -211,17 +202,19 @@ export async function getI18nInstance(
|
|
|
211
202
|
}
|
|
212
203
|
|
|
213
204
|
export async function getInitReactI18next() {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return
|
|
205
|
+
try {
|
|
206
|
+
const { initReactI18next } = await import('react-i18next');
|
|
207
|
+
return initReactI18next;
|
|
208
|
+
} catch (error) {
|
|
209
|
+
return null;
|
|
217
210
|
}
|
|
218
|
-
return null;
|
|
219
211
|
}
|
|
220
212
|
|
|
221
213
|
export async function getI18nextProvider() {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return
|
|
214
|
+
try {
|
|
215
|
+
const { I18nextProvider } = await import('react-i18next');
|
|
216
|
+
return I18nextProvider;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return null;
|
|
225
219
|
}
|
|
226
|
-
return null;
|
|
227
220
|
}
|
package/src/runtime/utils.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type TInternalRuntimeContext,
|
|
4
4
|
getGlobalBasename,
|
|
5
5
|
} from '@modern-js/runtime/context';
|
|
6
|
+
import { useLocation, useNavigate, useParams } from '@modern-js/runtime/router';
|
|
6
7
|
|
|
7
8
|
export const getPathname = (context: TInternalRuntimeContext): string => {
|
|
8
9
|
if (isBrowser()) {
|
|
@@ -141,11 +142,6 @@ export const shouldIgnoreRedirect = (
|
|
|
141
142
|
// Safe hook wrapper to handle cases where router context is not available
|
|
142
143
|
export const useRouterHooks = () => {
|
|
143
144
|
try {
|
|
144
|
-
const {
|
|
145
|
-
useLocation,
|
|
146
|
-
useNavigate,
|
|
147
|
-
useParams,
|
|
148
|
-
} = require('@modern-js/runtime/router');
|
|
149
145
|
return {
|
|
150
146
|
navigate: useNavigate(),
|
|
151
147
|
location: useLocation(),
|
package/src/shared/utils.ts
CHANGED
|
@@ -11,8 +11,7 @@ export function getEntryConfig<T extends Record<string, any>>(
|
|
|
11
11
|
entryKey: string,
|
|
12
12
|
): T | undefined {
|
|
13
13
|
const entryConfigMap = (config as any)[entryKey] as
|
|
14
|
-
|
|
15
|
-
| undefined;
|
|
14
|
+
Record<string, T> | undefined;
|
|
16
15
|
return entryConfigMap?.[entryName];
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var __webpack_modules__ = {};
|
|
2
|
-
var __webpack_module_cache__ = {};
|
|
3
|
-
function __webpack_require__(moduleId) {
|
|
4
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
-
exports: {}
|
|
8
|
-
};
|
|
9
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
-
return module.exports;
|
|
11
|
-
}
|
|
12
|
-
__webpack_require__.m = __webpack_modules__;
|
|
13
|
-
(()=>{
|
|
14
|
-
__webpack_require__.add = function(modules) {
|
|
15
|
-
Object.assign(__webpack_require__.m, modules);
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
|
-
export { __webpack_require__ };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
var __webpack_modules__ = {};
|
|
3
|
-
var __webpack_module_cache__ = {};
|
|
4
|
-
function __webpack_require__(moduleId) {
|
|
5
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
-
return module.exports;
|
|
12
|
-
}
|
|
13
|
-
__webpack_require__.m = __webpack_modules__;
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.add = function(modules) {
|
|
16
|
-
Object.assign(__webpack_require__.m, modules);
|
|
17
|
-
};
|
|
18
|
-
})();
|
|
19
|
-
export { __webpack_require__ };
|
package/rslib.config.mts
DELETED