Example incuding a new language and new language created based on english, that means that, if a key is missing in translations that will be english

This commit is contained in:
Mario Mol 2018-02-21 14:17:01 -03:00
parent 466c2c548b
commit 2f13f7fa54
2 changed files with 6 additions and 2 deletions

View File

@ -35,6 +35,9 @@
},
'en': {
'auto': 'Auto testing'
},
'newlang': {
'auto': 'Auto new lang'
}
}
};

View File

@ -102,11 +102,12 @@ var _defs = {
}
};
var _defaultLang = 'en';
var _lang;
var userLang = navigator.language || navigator.userLanguage;
_lang = _locales.find(l => l === userLang);
if (!_lang) {
_lang = 'en';
_lang = _defaultLang;
}
module.exports = {
@ -130,11 +131,11 @@ module.exports = {
return;
}
for (var key in languages) {
_defs[key] = Object.assign({}, _defs[key], languages[key]);
var langFound = _locales.find(l => l === key);
if (!langFound) {
_locales.push(key);
}
_defs[key] = Object.assign({}, _defs[_defaultLang], _defs[key], languages[key]);
}
},
translate: function (key, data, lang) {