Skip to content

Commit 8fd892f

Browse files
committed
修复例子因为浏览器语言是“中文”而不是“中文(简体)”时页面错误的问题
1 parent 1d82d04 commit 8fd892f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

examples/js/utils.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,19 @@
2929
return lang;
3030
}
3131
if (navigator.appName === 'Netscape') {
32-
return navigator.language;
32+
lang = navigator.language;
3333
} else {
34-
return navigator.browserLanguage;
34+
lang = navigator.browserLanguage;
3535
}
36+
if (lang) {
37+
if (lang.indexOf('zh') === 0) {
38+
return 'zh-CN';
39+
}
40+
if (lang.indexOf('en') === 0) {
41+
return 'en-US';
42+
}
43+
}
44+
return 'zh-CN';
3645
}
3746

3847
//设置cookie,参数分别为:key,value,过期时间(单位:ms),域

0 commit comments

Comments
 (0)