BUG Detect JS lang by <body>, and force init

This commit is contained in:
Ingo Schommer 2012-08-06 10:59:18 +02:00
parent 8320e4e775
commit b135218789

View File

@ -23,8 +23,13 @@ ss.i18n = {
lang: {},
inited: false,
init: function() {
if(this.inited) return;
this.currentLocale = this.detectLocale();
this.inited = true;
},
/**
@ -59,6 +64,8 @@ ss.i18n = {
*
*/
_t: function (entity, fallbackString, priority, context) {
this.init();
if (this.lang && this.lang[this.getLocale()] && this.lang[this.getLocale()][entity]) {
return this.lang[this.getLocale()][entity];
} else if (this.lang && this.lang[this.defaultLocale] && this.lang[this.defaultLocale][entity]) {
@ -166,11 +173,16 @@ ss.i18n = {
var rawLocale;
var detectedLocale;
// get by container tag
rawLocale = jQuery('body').attr('lang');
// get by meta
var metas = document.getElementsByTagName('meta');
for(var i=0; i<metas.length; i++) {
if(metas[i].attributes['http-equiv'] && metas[i].attributes['http-equiv'].nodeValue.toLowerCase() == 'content-language') {
rawLocale = metas[i].attributes['content'].nodeValue;
if(!rawLocale) {
var metas = document.getElementsByTagName('meta');
for(var i=0; i<metas.length; i++) {
if(metas[i].attributes['http-equiv'] && metas[i].attributes['http-equiv'].nodeValue.toLowerCase() == 'content-language') {
rawLocale = metas[i].attributes['content'].nodeValue;
}
}
}