wgt-node-utils 1.2.35 → 1.2.36
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +4 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -834,9 +834,11 @@ class wgtNodeUtils {
|
|
|
834
834
|
const countryCode = req.headers['cloudfront-viewer-country'];
|
|
835
835
|
// 从header中获取accept-language
|
|
836
836
|
const acceptLanguage = req.headers['accept-language'];
|
|
837
|
-
|
|
838
|
-
let languageCode =
|
|
837
|
+
// 优先使用accept-language中的语言代码,如果没有,则使用国家code
|
|
838
|
+
let languageCode = (acceptLanguage ? acceptLanguage.split(',')[0].split('-')[0].toLowerCase() : LANGUAGE_CODE_LIST[0].code) || (countryCode && countryCode.toLowerCase());
|
|
839
|
+
// 如果都没有,则使用默认的语言代码列表中的第一个语言代码
|
|
839
840
|
return LANGUAGE_CODE_LIST.some(item => item.code === languageCode) ? languageCode : LANGUAGE_CODE_LIST[0].code;
|
|
841
|
+
|
|
840
842
|
}
|
|
841
843
|
|
|
842
844
|
/**
|