@fe-free/core 6.0.17 → 6.0.18

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 6.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - i18n
8
+ - @fe-free/icons@6.0.18
9
+ - @fe-free/tool@6.0.18
10
+
3
11
  ## 6.0.17
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "6.0.17",
3
+ "version": "6.0.18",
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.17",
47
- "@fe-free/tool": "6.0.17"
46
+ "@fe-free/icons": "6.0.18",
47
+ "@fe-free/tool": "6.0.18"
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;
@@ -56,50 +54,42 @@ function initI18n(
56
54
  zhHKTranslation?: Record<string, unknown>;
57
55
  } = {},
58
56
  ) {
59
- const mergedEnTranslation = { ...enUSTranslation, ...resources.enTranslation };
60
- const mergedZhHKTranslation = { ...zhHKTranslation, ...resources.zhHKTranslation };
61
-
62
- if (i18n.isInitialized) {
63
- i18n.addResourceBundle(EnumLanguage.ZH_HK, 'translation', mergedZhHKTranslation, true, true);
64
- i18n.addResourceBundle(EnumLanguage.EN_US, 'translation', mergedEnTranslation, true, true);
65
- return;
66
- }
67
-
68
- if (!hasSetupPlugins) {
69
- i18n.use(LanguageDetector).use(initReactI18next).use(ICU);
70
- hasSetupPlugins = true;
71
- }
72
-
73
57
  const lng = getDefaultLng();
74
- console.log('initI18n', lng);
75
-
76
- void i18n.init({
77
- resources: {
78
- [EnumLanguage.ZH_CN]: {
79
- translation: {},
80
- },
81
- [EnumLanguage.ZH_HK]: {
82
- translation: mergedZhHKTranslation,
83
- },
84
- [EnumLanguage.EN_US]: {
85
- translation: mergedEnTranslation,
86
- },
58
+ const allResources = {
59
+ [EnumLanguage.ZH_CN]: {
60
+ translation: {},
61
+ },
62
+ [EnumLanguage.ZH_HK]: {
63
+ translation: { ...zhHKTranslation, ...resources.zhHKTranslation },
87
64
  },
88
- lng,
89
- fallbackLng: EnumLanguage.ZH_CN,
90
- interpolation: {
91
- escapeValue: false,
65
+ [EnumLanguage.EN_US]: {
66
+ translation: { ...enUSTranslation, ...resources.enTranslation },
92
67
  },
93
- });
68
+ };
69
+
70
+ console.log('initI18n', lng, allResources);
71
+
72
+ // @ts-ignore
73
+ window._i18nResources = allResources;
74
+
75
+ void i18n
76
+ .use(LanguageDetector)
77
+ .use(initReactI18next)
78
+ .use(ICU)
79
+ .init({
80
+ resources: allResources,
81
+ lng,
82
+ fallbackLng: EnumLanguage.ZH_CN,
83
+ interpolation: {
84
+ escapeValue: false,
85
+ },
86
+ });
94
87
  }
95
88
 
96
89
  function I18nProvider({ children }: { children: React.ReactNode }) {
97
- initI18n();
98
90
  return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
99
91
  }
100
92
 
101
- initI18n();
102
-
103
93
  if (typeof window !== 'undefined') {
104
94
  // @ts-ignore
105
95
  window._i18n = i18n;