@arcblock/ux 2.4.31 → 2.4.33
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/lib/Datatable/index.js +2 -2
- package/lib/Locale/context.js +12 -1
- package/package.json +4 -4
- package/src/Datatable/index.js +2 -2
- package/src/Locale/context.js +7 -1
package/lib/Datatable/index.js
CHANGED
@@ -216,11 +216,11 @@ function ReDatatable(_ref2) {
|
|
216
216
|
emptyEl = emptyNode;
|
217
217
|
} else if (locale === 'zh') {
|
218
218
|
emptyEl = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Empty.default, {
|
219
|
-
children: emptyNode || '
|
219
|
+
children: emptyNode || '没有找到匹配的记录'
|
220
220
|
});
|
221
221
|
} else {
|
222
222
|
emptyEl = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Empty.default, {
|
223
|
-
children: emptyNode || '
|
223
|
+
children: emptyNode || 'No matching records found'
|
224
224
|
});
|
225
225
|
}
|
226
226
|
|
package/lib/Locale/context.js
CHANGED
@@ -20,7 +20,7 @@ var _Util = require("../Util");
|
|
20
20
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
22
22
|
|
23
|
-
const _excluded = ["children", "locale", "translations", "languages"];
|
23
|
+
const _excluded = ["children", "locale", "fallbackLocale", "translations", "languages"];
|
24
24
|
|
25
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
26
26
|
|
@@ -94,6 +94,7 @@ function LocaleProvider(_ref) {
|
|
94
94
|
let {
|
95
95
|
children,
|
96
96
|
locale,
|
97
|
+
fallbackLocale,
|
97
98
|
translations,
|
98
99
|
languages
|
99
100
|
} = _ref,
|
@@ -118,6 +119,13 @@ function LocaleProvider(_ref) {
|
|
118
119
|
const translate = (key, data) => {
|
119
120
|
if (!translations[currentLocale] || !translations[currentLocale][key]) {
|
120
121
|
console.warn("Warning: no ".concat(key, " translation of ").concat(currentLocale));
|
122
|
+
|
123
|
+
if (fallbackLocale) {
|
124
|
+
var _translations$fallbac;
|
125
|
+
|
126
|
+
return ((_translations$fallbac = translations[fallbackLocale]) === null || _translations$fallbac === void 0 ? void 0 : _translations$fallbac[key]) || key;
|
127
|
+
}
|
128
|
+
|
121
129
|
return key;
|
122
130
|
}
|
123
131
|
|
@@ -144,6 +152,8 @@ LocaleProvider.propTypes = {
|
|
144
152
|
children: _propTypes.default.any.isRequired,
|
145
153
|
translations: _propTypes.default.object.isRequired,
|
146
154
|
locale: _propTypes.default.string,
|
155
|
+
// 会影响 translate(key) 的结果 - 当 key 无效时查找 fallbackLocale 对应的翻译结果
|
156
|
+
fallbackLocale: _propTypes.default.string,
|
147
157
|
languages: _propTypes.default.arrayOf(_propTypes.default.shape({
|
148
158
|
value: _propTypes.default.string,
|
149
159
|
text: _propTypes.default.string
|
@@ -151,6 +161,7 @@ LocaleProvider.propTypes = {
|
|
151
161
|
};
|
152
162
|
LocaleProvider.defaultProps = {
|
153
163
|
locale: '',
|
164
|
+
fallbackLocale: '',
|
154
165
|
languages: [{
|
155
166
|
value: 'en',
|
156
167
|
text: 'English'
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.4.
|
3
|
+
"version": "2.4.33",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -47,10 +47,10 @@
|
|
47
47
|
"react": ">=18.1.0",
|
48
48
|
"react-ga": "^2.7.0"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "d7a8cfbbcc9f926305b0da8c4507c510190a105e",
|
51
51
|
"dependencies": {
|
52
|
-
"@arcblock/icons": "^2.4.
|
53
|
-
"@arcblock/react-hooks": "^2.4.
|
52
|
+
"@arcblock/icons": "^2.4.33",
|
53
|
+
"@arcblock/react-hooks": "^2.4.33",
|
54
54
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
55
55
|
"@emotion/react": "^11.10.0",
|
56
56
|
"@emotion/styled": "^11.10.0",
|
package/src/Datatable/index.js
CHANGED
@@ -171,9 +171,9 @@ function ReDatatable({
|
|
171
171
|
} else if (isValidElement(emptyNode)) {
|
172
172
|
emptyEl = emptyNode;
|
173
173
|
} else if (locale === 'zh') {
|
174
|
-
emptyEl = <Empty>{emptyNode || '
|
174
|
+
emptyEl = <Empty>{emptyNode || '没有找到匹配的记录'}</Empty>;
|
175
175
|
} else {
|
176
|
-
emptyEl = <Empty>{emptyNode || '
|
176
|
+
emptyEl = <Empty>{emptyNode || 'No matching records found'}</Empty>;
|
177
177
|
}
|
178
178
|
|
179
179
|
let textLabels = {
|
package/src/Locale/context.js
CHANGED
@@ -44,7 +44,7 @@ const replace = (template, data) =>
|
|
44
44
|
|
45
45
|
const LocaleContext = createContext();
|
46
46
|
const { Provider, Consumer } = LocaleContext;
|
47
|
-
function LocaleProvider({ children, locale, translations, languages, ...rest }) {
|
47
|
+
function LocaleProvider({ children, locale, fallbackLocale, translations, languages, ...rest }) {
|
48
48
|
const [currentLocale, setCurrentLocale] = useState(locale || getLocale(languages));
|
49
49
|
|
50
50
|
const changeLocale = (newLocale) => {
|
@@ -63,6 +63,9 @@ function LocaleProvider({ children, locale, translations, languages, ...rest })
|
|
63
63
|
const translate = (key, data) => {
|
64
64
|
if (!translations[currentLocale] || !translations[currentLocale][key]) {
|
65
65
|
console.warn(`Warning: no ${key} translation of ${currentLocale}`);
|
66
|
+
if (fallbackLocale) {
|
67
|
+
return translations[fallbackLocale]?.[key] || key;
|
68
|
+
}
|
66
69
|
return key;
|
67
70
|
}
|
68
71
|
|
@@ -83,11 +86,14 @@ LocaleProvider.propTypes = {
|
|
83
86
|
children: PropTypes.any.isRequired,
|
84
87
|
translations: PropTypes.object.isRequired,
|
85
88
|
locale: PropTypes.string,
|
89
|
+
// 会影响 translate(key) 的结果 - 当 key 无效时查找 fallbackLocale 对应的翻译结果
|
90
|
+
fallbackLocale: PropTypes.string,
|
86
91
|
languages: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string, text: PropTypes.string })),
|
87
92
|
};
|
88
93
|
|
89
94
|
LocaleProvider.defaultProps = {
|
90
95
|
locale: '',
|
96
|
+
fallbackLocale: '',
|
91
97
|
languages: [
|
92
98
|
{ value: 'en', text: 'English' },
|
93
99
|
{ value: 'zh', text: '简体中文' },
|