中英文切换


//首页
var zh_index = {
"index1":"首页",
"index2":"产品实例"
};
var en_index = {
"index1":"index",
"index2":"Product examples"
};

//服务支持
var zh_serviceSupport = {
"serviceSupport1":"首页",
"serviceSupport2":"产品实例"
};
var en_serviceSupport = {
"serviceSupport1":"index",
"serviceSupport2":"Product examples"
};




var zh = {"index":zh_index,"serviceSupport":zh_serviceSupport};
var en = {"index":en_index,"serviceSupport":en_serviceSupport};

var language = [zh,en];


$(function(){
var value = sessionStorage.getItem("language");
var pathname = window.location.pathname;
var index = pathname.lastIndexOf("\/");
pathname = pathname.substring(index + 1, pathname.length).split(".html")[0];
if(value==null || value==0){
value=0;
}
var data = language[value][pathname];
for (var i = 1; i <= 2; i++) {
$("#"+pathname+i).text(data[pathname+i])
}
});
$("#change").click(function() {
var value = sessionStorage.getItem("language");
if(value==="1"){
sessionStorage.setItem("language", "0");
}else{
sessionStorage.setItem("language", "1");
}
window.location.reload();
})


作者:皓ma,发布于:2019/03/15
原文:https://www.cnblogs.com/shamszhang/p/10524829.html