Skip to content

Commit af36bd5

Browse files
committed
【fix】部分例子因为国际化资源加载时机问题报错; review by luox
1 parent c94d0a3 commit af36bd5

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

examples/js/include-web.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,24 @@
3232
return false;
3333
}
3434

35+
function getCookie(cKey) {
36+
var name = cKey + "=";
37+
var ca = document.cookie.split(';');
38+
for (var i = 0; i < ca.length; i++) {
39+
var c = ca[i];
40+
while (c.charAt(0) === ' ') c = c.substring(1);
41+
if (c.indexOf(name) !== -1) return c.substring(name.length, c.length);
42+
}
43+
return "";
44+
}
45+
3546
//加载类库资源文件
3647
function load(config) {
3748
var libsurl = config.libsurl;
3849
var includes = (targetScript.getAttribute('include') || "").split(",");
3950
var excludes = (targetScript.getAttribute('exclude') || "").split(",");
51+
const resourceLanguage = getCookie('language');
52+
inputScript("../locales/" + resourceLanguage + "/resources.js");
4053
inputScript("../js/tokengenerator.js");
4154
inputScript("../js/websymbol.js");
4255
var jQueryInclude = false;

examples/locales/en-US/resources.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,3 +1830,5 @@ window.examplesResources = {
18301830
"text_print": "Print"
18311831
}
18321832
};
1833+
1834+
window.resources = window.examplesResources.resources;

examples/locales/zh-CN/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,3 +1781,4 @@ window.examplesResources = {
17811781
"text_print": "打印"
17821782
}
17831783
};
1784+
window.resources = window.examplesResources.resources;

0 commit comments

Comments
 (0)