Files
apt-nl-map/static/Magic4/js/i18n/TimeI18n.js
2024-12-03 16:40:54 +08:00

47 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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){ }
}