@fe-free/core 6.0.15 → 6.0.17
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/i18next.config.ts +2 -2
- package/package.json +3 -3
- package/src/core_app/index.tsx +10 -1
- package/src/crud/crud_detail.tsx +16 -3
- package/src/i18n.tsx +23 -3
- package/src/locales/zh-HK/translation.json +87 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @fe-free/core
|
|
2
2
|
|
|
3
|
+
## 6.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: i18n
|
|
8
|
+
- @fe-free/icons@6.0.17
|
|
9
|
+
- @fe-free/tool@6.0.17
|
|
10
|
+
|
|
11
|
+
## 6.0.16
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- fix bug
|
|
16
|
+
- @fe-free/icons@6.0.16
|
|
17
|
+
- @fe-free/tool@6.0.16
|
|
18
|
+
|
|
3
19
|
## 6.0.15
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/i18next.config.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { defineConfig } from 'i18next-cli';
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
locales: ['zh-CN', 'en-US'],
|
|
4
|
+
locales: ['zh-CN', 'zh-HK', 'en-US'],
|
|
5
5
|
extract: {
|
|
6
6
|
primaryLanguage: 'zh-CN',
|
|
7
|
-
secondaryLanguages: ['en-US'],
|
|
7
|
+
secondaryLanguages: ['zh-HK', 'en-US'],
|
|
8
8
|
input: ['./src/**/*.{js,jsx,ts,tsx}'],
|
|
9
9
|
output: './src/locales/{{language}}/{{namespace}}.json',
|
|
10
10
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.17",
|
|
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.17",
|
|
47
|
+
"@fe-free/tool": "6.0.17"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"i18n-extract": "rm -rf ./src/locales/zh-CN && npx i18next-cli extract"
|
package/src/core_app/index.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { useTitle } from 'ahooks';
|
|
|
3
3
|
import { App, ConfigProvider } from 'antd';
|
|
4
4
|
import enUS from 'antd/locale/en_US';
|
|
5
5
|
import zhCN from 'antd/locale/zh_CN';
|
|
6
|
+
import zhHK from 'antd/locale/zh_HK';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import { merge } from 'lodash-es';
|
|
8
9
|
import { useEffect, useMemo } from 'react';
|
|
@@ -151,7 +152,15 @@ function CoreAppBase(props: CoreAppProps) {
|
|
|
151
152
|
return configProviderProps.locale;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
if (i18n.language === EnumLanguage.EN_US) {
|
|
156
|
+
return enUS;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (i18n.language === EnumLanguage.ZH_HK) {
|
|
160
|
+
return zhHK;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return zhCN;
|
|
155
164
|
}, [configProviderProps?.locale, i18n.language]);
|
|
156
165
|
|
|
157
166
|
return (
|
package/src/crud/crud_detail.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
import { isString } from 'lodash-es';
|
|
5
5
|
import { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
7
8
|
import type { CRUDProps } from './types';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -121,15 +122,27 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
121
122
|
|
|
122
123
|
const handleOpenChange = useCallback(
|
|
123
124
|
async (open) => {
|
|
125
|
+
// pro-components 有 bug,handleOpenChange 会重复调用,导致调用多次。
|
|
126
|
+
|
|
127
|
+
let isSame = false;
|
|
128
|
+
setIsOpen((v) => {
|
|
129
|
+
if (open === v) {
|
|
130
|
+
isSame = true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return open;
|
|
134
|
+
});
|
|
135
|
+
if (isSame) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
124
139
|
if (!open) {
|
|
125
140
|
// 关闭重置
|
|
126
141
|
form?.resetFields();
|
|
127
|
-
|
|
142
|
+
|
|
128
143
|
return;
|
|
129
144
|
}
|
|
130
145
|
|
|
131
|
-
setIsOpen(open);
|
|
132
|
-
|
|
133
146
|
if (id) {
|
|
134
147
|
setLoading(true);
|
|
135
148
|
|
package/src/i18n.tsx
CHANGED
|
@@ -3,8 +3,12 @@ import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
3
3
|
import ICU from 'i18next-icu';
|
|
4
4
|
import { I18nextProvider, initReactI18next } from 'react-i18next';
|
|
5
5
|
|
|
6
|
+
import enUSTranslation from './locales/en-US/translation.json';
|
|
7
|
+
import zhHKTranslation from './locales/zh-HK/translation.json';
|
|
8
|
+
|
|
6
9
|
enum EnumLanguage {
|
|
7
10
|
ZH_CN = 'zh-CN',
|
|
11
|
+
ZH_HK = 'zh-HK',
|
|
8
12
|
EN_US = 'en-US',
|
|
9
13
|
}
|
|
10
14
|
|
|
@@ -13,6 +17,10 @@ const valueEnumLanguage = {
|
|
|
13
17
|
text: '中文',
|
|
14
18
|
value: EnumLanguage.ZH_CN,
|
|
15
19
|
},
|
|
20
|
+
[EnumLanguage.ZH_HK]: {
|
|
21
|
+
text: '繁體中文',
|
|
22
|
+
value: EnumLanguage.ZH_HK,
|
|
23
|
+
},
|
|
16
24
|
[EnumLanguage.EN_US]: {
|
|
17
25
|
text: '英文',
|
|
18
26
|
value: EnumLanguage.EN_US,
|
|
@@ -42,9 +50,18 @@ function getDefaultLng() {
|
|
|
42
50
|
return lng;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
function initI18n(
|
|
53
|
+
function initI18n(
|
|
54
|
+
resources: {
|
|
55
|
+
enTranslation?: Record<string, unknown>;
|
|
56
|
+
zhHKTranslation?: Record<string, unknown>;
|
|
57
|
+
} = {},
|
|
58
|
+
) {
|
|
59
|
+
const mergedEnTranslation = { ...enUSTranslation, ...resources.enTranslation };
|
|
60
|
+
const mergedZhHKTranslation = { ...zhHKTranslation, ...resources.zhHKTranslation };
|
|
61
|
+
|
|
46
62
|
if (i18n.isInitialized) {
|
|
47
|
-
i18n.addResourceBundle(EnumLanguage.
|
|
63
|
+
i18n.addResourceBundle(EnumLanguage.ZH_HK, 'translation', mergedZhHKTranslation, true, true);
|
|
64
|
+
i18n.addResourceBundle(EnumLanguage.EN_US, 'translation', mergedEnTranslation, true, true);
|
|
48
65
|
return;
|
|
49
66
|
}
|
|
50
67
|
|
|
@@ -61,8 +78,11 @@ function initI18n({ enTranslation = {} }: { enTranslation?: Record<string, unkno
|
|
|
61
78
|
[EnumLanguage.ZH_CN]: {
|
|
62
79
|
translation: {},
|
|
63
80
|
},
|
|
81
|
+
[EnumLanguage.ZH_HK]: {
|
|
82
|
+
translation: mergedZhHKTranslation,
|
|
83
|
+
},
|
|
64
84
|
[EnumLanguage.EN_US]: {
|
|
65
|
-
translation:
|
|
85
|
+
translation: mergedEnTranslation,
|
|
66
86
|
},
|
|
67
87
|
},
|
|
68
88
|
lng,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@fe-free/core": {
|
|
3
|
+
"app": {
|
|
4
|
+
"mainScriptNotFound": "沒找到 [data-name=\"mainScript\"],不啟用更新提醒",
|
|
5
|
+
"newVersionFound": "發現新版本",
|
|
6
|
+
"refresh": "重新整理",
|
|
7
|
+
"refreshPrompt": "請及時重新整理頁面更新,以避免影響使用",
|
|
8
|
+
"updateLater": "稍後更新"
|
|
9
|
+
},
|
|
10
|
+
"crud": {
|
|
11
|
+
"batchActionConfirm": "確定要執行 {action} 嗎?",
|
|
12
|
+
"batchDelete": "批次刪除",
|
|
13
|
+
"cancel": "取消",
|
|
14
|
+
"clearSelection": "取消選取",
|
|
15
|
+
"confirm": "確定",
|
|
16
|
+
"create": "新增",
|
|
17
|
+
"createSuccess": "新增成功",
|
|
18
|
+
"delete": "刪除",
|
|
19
|
+
"deleteConfirm": "確認刪除 \"{name}\" 嗎?",
|
|
20
|
+
"deleteSuccess": "刪除成功",
|
|
21
|
+
"deleteWarning": "刪除後不可恢復,請謹慎操作",
|
|
22
|
+
"operate": "操作",
|
|
23
|
+
"read": "查看",
|
|
24
|
+
"requestDeleteByRecordRequired": "沒有傳 requestDeleteByRecord",
|
|
25
|
+
"selectedItems": "已選 {num} 項",
|
|
26
|
+
"update": "編輯",
|
|
27
|
+
"updateSuccess": "更新成功",
|
|
28
|
+
"warnCreateDetailForm": "actions 包含 create 時,需要傳遞 detailForm",
|
|
29
|
+
"warnReadDetailForm": "actions 包含 read 時,需要傳遞 detailForm",
|
|
30
|
+
"warnUpdateDetailForm": "actions 包含 update 時,需要傳遞 detailForm"
|
|
31
|
+
},
|
|
32
|
+
"crudOfList": {
|
|
33
|
+
"searchPlaceholder": "輸入搜尋"
|
|
34
|
+
},
|
|
35
|
+
"crudOfPure": {
|
|
36
|
+
"inputPlaceholder": "請輸入{title}",
|
|
37
|
+
"selectPlaceholder": "請選擇{title}"
|
|
38
|
+
},
|
|
39
|
+
"dataViewer": {
|
|
40
|
+
"view": "查看"
|
|
41
|
+
},
|
|
42
|
+
"fileTree": {
|
|
43
|
+
"create": "新增",
|
|
44
|
+
"createSubDirectory": "新增子目錄",
|
|
45
|
+
"delete": "刪除",
|
|
46
|
+
"directoryName": "目錄名稱",
|
|
47
|
+
"update": "編輯"
|
|
48
|
+
},
|
|
49
|
+
"formList": {
|
|
50
|
+
"add": "新增",
|
|
51
|
+
"duplicateValue": "不能有重複",
|
|
52
|
+
"edit": "編輯",
|
|
53
|
+
"emptyOption": "存在空選項"
|
|
54
|
+
},
|
|
55
|
+
"infiniteList": {
|
|
56
|
+
"loadingMore": "載入更多資料中...",
|
|
57
|
+
"noMoreData": "沒有更多資料"
|
|
58
|
+
},
|
|
59
|
+
"record": {
|
|
60
|
+
"inputPlaceholder": "請輸入"
|
|
61
|
+
},
|
|
62
|
+
"upload": {
|
|
63
|
+
"delete": "刪除",
|
|
64
|
+
"dragUpload": "點擊或拖曳到此區域進行上傳",
|
|
65
|
+
"fileCount": "檔案數量 ({success}/{total})",
|
|
66
|
+
"localUpload": "本機上傳",
|
|
67
|
+
"maxFilesWarning": "最多只能上傳 {num} 個檔案,超出部分會忽略。",
|
|
68
|
+
"pleaseSelect": "請選擇"
|
|
69
|
+
},
|
|
70
|
+
"valueTypeMap": {
|
|
71
|
+
"view": "查看"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"core": {
|
|
75
|
+
"crud": {
|
|
76
|
+
"warnBatchDeleteRequestDeleteByRecords": "actions 包含 batch_delete 時,需要傳遞 requestDeleteByRecords",
|
|
77
|
+
"warnCreateRequestCreateByValues": "actions 包含 create 時,需要傳遞 requestCreateByValues",
|
|
78
|
+
"warnDeleteProps": "actions 包含 delete 時,需要傳遞 deleteProps 和 requestDeleteByRecord",
|
|
79
|
+
"warnReadRequestGetByRecord": "actions 包含 read 時,需要傳遞 requestGetByRecord",
|
|
80
|
+
"warnUpdateRequest": "actions 包含 update 時,需要傳遞 requestGetByRecord 和 requestUpdateByValues"
|
|
81
|
+
},
|
|
82
|
+
"crudOfList": {
|
|
83
|
+
"warnAtLeastOneSearch": "CRUDOfList 的 columns 中至少有一個 search 為 true 的欄位",
|
|
84
|
+
"warnOnlyOneSearch": "CRUDOfList 的 columns 中只能有一個 search 為 true 的欄位"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|