webclient/js/I18n.js

33 lines
652 B
JavaScript
Raw Normal View History

import Translations;
var language = chooseLanguage();
return {
get: get
};
function chooseLanguage() {
var userPreference = navigator.language || navigator.userLanguage;
if(userPreference != undefined) {
if(Translations[userPreference] != undefined) {
return userPreference;
}
var lang = userPreference.replace(/-.*/, '');
for(var key in Translations) {
if(key.replace(/-.*/, '') == lang) {
return key;
}
}
}
if(Translations['en-US'] != undefined) {
return 'en-US';
}
for(var key in Translations) {
return key;
}
}
function get(textId) {
return Translations[language][textId] || ('TRANSLATE "'+textId+'" !!');
}