@alicloud/alfa-core 1.4.36 → 1.4.37

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.
@@ -9,18 +9,15 @@ var localeMap = {
9
9
  fr: 'fr_FR',
10
10
  de: 'de_DE'
11
11
  };
12
- var getLocaleFromCookie = function getLocaleFromCookie() {
13
- var lang = getCookie('aliyun_lang');
14
- return lang && localeMap[lang];
15
- };
16
12
 
17
13
  /**
18
- * x-X-Y to x_X_Y
14
+ * 1. x-X-Y to x_X_Y
15
+ * 2. zh to zh_CN
19
16
  * @param key
20
17
  * @returns
21
18
  */
22
19
  var formatLocale = function formatLocale(key) {
23
- return key.replace('-', '_');
20
+ return localeMap[key] ? localeMap[key] : key.replace('-', '_');
24
21
  };
25
22
 
26
23
  /**
@@ -29,5 +26,5 @@ var formatLocale = function formatLocale(key) {
29
26
  */
30
27
  export var getLocale = function getLocale(key) {
31
28
  var _window, _window$ALIYUN_CONSOL;
32
- return formatLocale(key || ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.LOCALE) || getLocaleFromCookie() || globalLocale);
29
+ return formatLocale(key || ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.LOCALE) || getCookie('aliyun_lang') || globalLocale);
33
30
  };
@@ -15,18 +15,15 @@ var localeMap = {
15
15
  fr: 'fr_FR',
16
16
  de: 'de_DE'
17
17
  };
18
- var getLocaleFromCookie = function getLocaleFromCookie() {
19
- var lang = (0, _cookie.getCookie)('aliyun_lang');
20
- return lang && localeMap[lang];
21
- };
22
18
 
23
19
  /**
24
- * x-X-Y to x_X_Y
20
+ * 1. x-X-Y to x_X_Y
21
+ * 2. zh to zh_CN
25
22
  * @param key
26
23
  * @returns
27
24
  */
28
25
  var formatLocale = function formatLocale(key) {
29
- return key.replace('-', '_');
26
+ return localeMap[key] ? localeMap[key] : key.replace('-', '_');
30
27
  };
31
28
 
32
29
  /**
@@ -35,6 +32,6 @@ var formatLocale = function formatLocale(key) {
35
32
  */
36
33
  var getLocale = function getLocale(key) {
37
34
  var _window, _window$ALIYUN_CONSOL;
38
- return formatLocale(key || ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.LOCALE) || getLocaleFromCookie() || globalLocale);
35
+ return formatLocale(key || ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.LOCALE) || (0, _cookie.getCookie)('aliyun_lang') || globalLocale);
39
36
  };
40
37
  exports.getLocale = getLocale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-core",
3
- "version": "1.4.36",
3
+ "version": "1.4.37",
4
4
  "description": "MicroFront End SDK for alicloud",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",