@fe-free/core 6.0.17 → 6.0.19
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/CHANGELOG.md +16 -0
- package/package.json +3 -3
- package/src/i18n.tsx +32 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @fe-free/core
|
|
2
2
|
|
|
3
|
+
## 6.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- i18n
|
|
8
|
+
- @fe-free/icons@6.0.19
|
|
9
|
+
- @fe-free/tool@6.0.19
|
|
10
|
+
|
|
11
|
+
## 6.0.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- i18n
|
|
16
|
+
- @fe-free/icons@6.0.18
|
|
17
|
+
- @fe-free/tool@6.0.18
|
|
18
|
+
|
|
3
19
|
## 6.0.17
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.19",
|
|
4
4
|
"description": "React 业务核心组件库:CRUD、ProForm 扩展、布局、路由、树、上传等(Antd + ProComponents)",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"i18next-icu": "^2.4.1",
|
|
44
44
|
"react": "^19.2.0",
|
|
45
45
|
"react-i18next": "^16.4.0",
|
|
46
|
-
"@fe-free/icons": "6.0.
|
|
47
|
-
"@fe-free/tool": "6.0.
|
|
46
|
+
"@fe-free/icons": "6.0.19",
|
|
47
|
+
"@fe-free/tool": "6.0.19"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"i18n-extract": "rm -rf ./src/locales/zh-CN && npx i18next-cli extract"
|
package/src/i18n.tsx
CHANGED
|
@@ -37,8 +37,6 @@ const listLanguage = Object.keys(valueEnumLanguage).map((key) => {
|
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
let hasSetupPlugins = false;
|
|
41
|
-
|
|
42
40
|
function getDefaultLng() {
|
|
43
41
|
if (typeof window === 'undefined') {
|
|
44
42
|
return EnumLanguage.ZH_CN;
|
|
@@ -51,55 +49,50 @@ function getDefaultLng() {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
function initI18n(
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
params: {
|
|
53
|
+
lng?: EnumLanguage;
|
|
54
|
+
enUSTranslation?: Record<string, unknown>;
|
|
56
55
|
zhHKTranslation?: Record<string, unknown>;
|
|
56
|
+
// 历史原因,保留
|
|
57
|
+
enTranslation?: Record<string, unknown>;
|
|
57
58
|
} = {},
|
|
58
59
|
) {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
60
|
+
const lng = params.lng || getDefaultLng();
|
|
61
|
+
const resources = {
|
|
62
|
+
[EnumLanguage.ZH_CN]: {
|
|
63
|
+
translation: {},
|
|
64
|
+
},
|
|
65
|
+
[EnumLanguage.ZH_HK]: {
|
|
66
|
+
translation: { ...zhHKTranslation, ...params.zhHKTranslation },
|
|
67
|
+
},
|
|
68
|
+
[EnumLanguage.EN_US]: {
|
|
69
|
+
translation: { ...enUSTranslation, ...params.enUSTranslation, ...params.enTranslation },
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
console.log('initI18n', lng);
|
|
73
|
+
console.log('initI18n', lng, resources);
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
window._i18nResources = resources;
|
|
77
|
+
|
|
78
|
+
void i18n
|
|
79
|
+
.use(LanguageDetector)
|
|
80
|
+
.use(initReactI18next)
|
|
81
|
+
.use(ICU)
|
|
82
|
+
.init({
|
|
83
|
+
resources,
|
|
84
|
+
lng,
|
|
85
|
+
fallbackLng: EnumLanguage.ZH_CN,
|
|
86
|
+
interpolation: {
|
|
87
|
+
escapeValue: false,
|
|
86
88
|
},
|
|
87
|
-
}
|
|
88
|
-
lng,
|
|
89
|
-
fallbackLng: EnumLanguage.ZH_CN,
|
|
90
|
-
interpolation: {
|
|
91
|
-
escapeValue: false,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
89
|
+
});
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
function I18nProvider({ children }: { children: React.ReactNode }) {
|
|
97
|
-
initI18n();
|
|
98
93
|
return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
|
|
99
94
|
}
|
|
100
95
|
|
|
101
|
-
initI18n();
|
|
102
|
-
|
|
103
96
|
if (typeof window !== 'undefined') {
|
|
104
97
|
// @ts-ignore
|
|
105
98
|
window._i18n = i18n;
|