Skip to content

Commit 0d8959d

Browse files
committed
【fix】预请求examples的国际化资源设置默认值language; review by songym
1 parent 02fafca commit 0d8959d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

examples/js/include-web.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,34 @@
4141
if (c.indexOf(name) !== -1) return c.substring(name.length, c.length);
4242
}
4343
return "";
44-
}
44+
}
45+
46+
function getLanguage() {
47+
var lang = getCookie('language');
48+
if (!lang) {
49+
if (navigator.appName === 'Netscape') {
50+
lang = navigator.language;
51+
} else {
52+
lang = navigator.browserLanguage;
53+
}
54+
}
55+
if (lang) {
56+
if (lang.indexOf('zh') === 0) {
57+
return 'zh-CN';
58+
}
59+
if (lang.indexOf('en') === 0) {
60+
return 'en-US';
61+
}
62+
}
63+
return 'zh-CN';
64+
}
4565

4666
//加载类库资源文件
4767
function load(config) {
4868
var libsurl = config.libsurl;
4969
var includes = (targetScript.getAttribute('include') || "").split(",");
5070
var excludes = (targetScript.getAttribute('exclude') || "").split(",");
51-
const resourceLanguage = getCookie('language');
71+
const resourceLanguage = getLanguage();
5272
inputScript("../locales/" + resourceLanguage + "/resources.js");
5373
inputScript("../js/tokengenerator.js");
5474
inputScript("../js/websymbol.js");

0 commit comments

Comments
 (0)