MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / initializeI18N

Function initializeI18N

examples/js/localization.js:31–86  ·  view source on GitHub ↗
(path, callback)

Source from the content-addressed store, hash-verified

29
30
31 function initializeI18N(path, callback) {
32 var localPath = path + "./locales",
33 file = "/resources.js";
34
35 var filePathMap = {
36 "en-US": localPath + "/en-US" + file,
37 "zh-CN": localPath + "/zh-CN" + file
38 };
39
40 //脚本加载完成标志
41 var lang = utils.getLanguage();
42
43 inputScript(filePathMap[lang], function () {
44
45 i18next.init({
46 lng: lang,
47 whitelist: ["zh-CN", "en-US"],
48 fallbackLng: ["zh-CN", "en-US"]
49 },function(){
50 if (window.isSite) {
51 var webResourceURL = '../../web/locales/'+lang+'/resources.js';
52 $.get(webResourceURL, function () {
53 for (var name in window.webResources) {
54 var subWeb = window.webResources[name];
55 var subExamples = window.examplesResources[name];
56 //重名以webResource为准
57 if (typeof window.webResources[name] == 'object') {
58
59 if (!subExamples) {
60 subExamples = {};
61 }
62 for (var name1 in subWeb) {
63 subExamples[name1] = subWeb[name1];
64 }
65 } else {
66 subExamples[name1] = subWeb[name];
67 }
68
69 }
70 window.resources = window.examplesResources;
71 i18next.addResourceBundle && i18next.addResourceBundle(lang, 'translation', window.resources);
72 callback && callback();
73
74 })
75
76 } else {
77 window.resources = window.examplesResources;
78 i18next.addResourceBundle && i18next.addResourceBundle(lang, 'translation', window.resources);
79 callback && callback();
80 }
81 });
82
83
84 });
85
86 }
87
88 //国际化dom中的文本

Callers

nothing calls this directly

Calls 4

inputScriptFunction · 0.70
callbackFunction · 0.50
initMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected