magic4
This commit is contained in:
47
static/Magic4/js/i18n/TimeI18n.js
Normal file
47
static/Magic4/js/i18n/TimeI18n.js
Normal file
@@ -0,0 +1,47 @@
|
||||
Object.defineProperty(window.top.frames[0].LANGUAGE_Index,'name', { //.frames[0]
|
||||
get: function () {
|
||||
return name;
|
||||
},
|
||||
set: function (newValue) {
|
||||
name = newValue;
|
||||
sessionStorage.setItem("LANGUAGE_Index",newValue);
|
||||
loadText()
|
||||
}
|
||||
});
|
||||
|
||||
function loadText(){
|
||||
// console.log("window.top.LANGUAGE_Index.name="+window.top.LANGUAGE_Index.name)
|
||||
// console.log("i18nType11="+i18nType)
|
||||
// if(i18nType != 'undefined'){
|
||||
// i18nType = window.top.LANGUAGE_Index.name
|
||||
// console.log("i18nType22="+window.top.LANGUAGE_Index.name)
|
||||
// }
|
||||
let languageMap;
|
||||
try{
|
||||
languageMap = new Map(Object.entries(JSON.parse(sessionStorage.getItem("LanguageMap"))));
|
||||
}catch (ex){return ;}
|
||||
//console.log("languageMap:",languageMap)
|
||||
try {
|
||||
//初始化页面元素
|
||||
$('[data-i18n-placeholder]').each(function () {
|
||||
$(this).attr('placeholder', languageMap.get($(this).data('i18n-placeholder')));
|
||||
});
|
||||
$('[data-i18n-text]').each(function () {
|
||||
//如果text里面还有html需要过滤掉
|
||||
var html = $(this).html();
|
||||
//console.log("111",html)
|
||||
var reg = /<(.*)>/;
|
||||
if (reg.test(html)) {
|
||||
var htmlValue = reg.exec(html)[0];
|
||||
$(this).html(htmlValue + languageMap.get($(this).data('i18n-text')));
|
||||
}
|
||||
else {
|
||||
$(this).text(languageMap.get($(this).data('i18n-text')));
|
||||
}
|
||||
});
|
||||
$('[data-i18n-value]').each(function () {
|
||||
$(this).val(languageMap.get($(this).data('i18n-value')));
|
||||
});
|
||||
}
|
||||
catch(ex){ }
|
||||
}
|
||||
Reference in New Issue
Block a user