@blocklet/list 0.10.14 → 0.10.16

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.
@@ -123,12 +123,9 @@ function FilterProvider(_ref) {
123
123
  return (0, _orderBy.default)(list, [i => i.name], ['asc']);
124
124
  }, [allCategories]);
125
125
  const translate = (0, _react.useCallback)((key, data) => {
126
- if (!_locale.default[locale] || !_locale.default[locale][key]) {
127
- console.warn("Warning: no ".concat(key, " translation of ").concat(locale));
128
- return key;
129
- }
130
-
131
- return (0, _utils.replaceTranslate)(_locale.default[locale][key], data);
126
+ // 找不到对应的翻译时,fallback 到英文翻译
127
+ const fallback = _locale.default[locale] ? _locale.default[locale][key] : _locale.default.en[key];
128
+ return (0, _utils.replaceTranslate)(fallback, data);
132
129
  }, [locale]);
133
130
  const blockletList = (0, _react.useMemo)(() => {
134
131
  let blocklets = blockletsState.list || []; // 用户传入的过滤函数
package/lib/libs/utils.js CHANGED
@@ -56,7 +56,7 @@ const getCategoryOptions = function getCategoryOptions() {
56
56
  let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
57
57
  let locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';
58
58
  return list.map(item => ({
59
- name: item.locales[locale],
59
+ name: item.locales[locale] || "Category.".concat(locale),
60
60
  value: item._id
61
61
  }));
62
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/list",
3
- "version": "0.10.14",
3
+ "version": "0.10.16",
4
4
  "description": "Common ux components of blocklet",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@algolia/autocomplete-js": "^1.7.1",
44
44
  "@algolia/autocomplete-theme-classic": "^1.7.1",
45
- "@arcblock/ux": "^2.4.35",
45
+ "@arcblock/ux": "^2.4.39",
46
46
  "@emotion/react": "^11.10.0",
47
47
  "@emotion/styled": "^11.10.0",
48
48
  "@mui/icons-material": "^5.8.4",
@@ -71,5 +71,5 @@
71
71
  "eslint": "^8.22.0",
72
72
  "prettier": "^2.7.1"
73
73
  },
74
- "gitHead": "607f29e135ac4a1274d931ffab1a58b83b2b3965"
74
+ "gitHead": "9d833d6e5e6123e4d327ba17654d7d0ef0057994"
75
75
  }
@@ -87,12 +87,9 @@ function FilterProvider({
87
87
 
88
88
  const translate = useCallback(
89
89
  (key, data) => {
90
- if (!translations[locale] || !translations[locale][key]) {
91
- console.warn(`Warning: no ${key} translation of ${locale}`);
92
- return key;
93
- }
94
-
95
- return replaceTranslate(translations[locale][key], data);
90
+ // 找不到对应的翻译时,fallback 到英文翻译
91
+ const fallback = translations[locale] ? translations[locale][key] : translations.en[key];
92
+ return replaceTranslate(fallback, data);
96
93
  },
97
94
  [locale]
98
95
  );
package/src/libs/utils.js CHANGED
@@ -37,7 +37,7 @@ const getPrices = (t) => {
37
37
  ];
38
38
  };
39
39
  const getCategoryOptions = (list = [], locale = 'en') => {
40
- return list.map((item) => ({ name: item.locales[locale], value: item._id }));
40
+ return list.map((item) => ({ name: item.locales[locale] || `Category.${locale}`, value: item._id }));
41
41
  };
42
42
 
43
43
  /**