0
我正在开发一个使用此代码的多语言网站,我得到它的工作完美,但我有问题,当它改变时,文本中的所有样式都丢失,顶部菜单不是只有失去它的风格,但它也完全停止工作多语言丢失的文本样式
这是JavaScript函数,改变文本:
(function() {
$.MultiLanguage = function(a, c) {
var b = this;
if (c == null) {
c = null
}
return $.getJSON(a, function(g) {
var f, d, h, e;
if (c !== null) {
localStorage.MultiLanguage = c
} else {
if (typeof localStorage.MultiLanguage === "undefined") {
c = localStorage.MultiLanguage = g.config["default"]
} else {
c = localStorage.MultiLanguage
}
}
d = g.language[c];
e = [];
for (f in d) {
h = d[f];
if ($(f).get(0).tagName.toLowerCase() === "title") {
document.title = h;
continue
}
if (f.length > 0) {
e.push($(f).html(d[f]))
} else {
e.push(void 0)
}
}
return e
})
}
})
.call(this);
的JSON语言文件是这样的:
{
"config": {
"default": "es"
},
"language": {
"es": {
"#ml-home": "HOME",
"#ml-agencia": "AGENCIA",
"ml-img-serv":"images/labels/servicios.png",
"#ml-texto_agencia": "Somos una agencia creativa y multidisciplinaria que busca potenciar a sus clientes. "
},
"en": {
"#ml-home": "HOME",
"#ml-agencia": "AGENCY",
"ml-img-serv":"images/labels/agencia.png",
"#ml-texto_agencia": "Octagon is a creative and multidisciplinary agency seeking to empower its customers. "
}
}
}
什么说控制台?任何错误? –
请注意,JSON的''ml-img-serv“'缺少''''或'#'选择器中的任何一个。 –
你有没有jQuery功能?并关于你如何使用/调用它? –