|
@@ -18,32 +18,31 @@
|
|
|
|
|
|
|
|
|
var applocale = {
|
|
|
- lang: navigator.language,
|
|
|
+ lang: localStorage.getItem('global_language') == null || localStorage.getItem('global_language') == "default" ? navigator.language : localStorage.getItem('global_language'),
|
|
|
localeFile: "",
|
|
|
localData: {},
|
|
|
- init: function(localeFile, callback=undefined){
|
|
|
+ init: function(localeFile, callback = undefined) {
|
|
|
applocale.localeFile = localeFile;
|
|
|
$.ajax({
|
|
|
dataType: "json",
|
|
|
url: localeFile,
|
|
|
- success: function(data){
|
|
|
+ success: function(data) {
|
|
|
applocale.localData = data;
|
|
|
- if (callback != undefined){
|
|
|
+ if (callback != undefined) {
|
|
|
callback(data);
|
|
|
}
|
|
|
|
|
|
- if (data.keys[applocale.lang] != undefined && data.keys[applocale.lang].fwtitle != undefined && ao_module_virtualDesktop){
|
|
|
+ if (data.keys[applocale.lang] != undefined && data.keys[applocale.lang].fwtitle != undefined && ao_module_virtualDesktop) {
|
|
|
//Update the floatwindow title as well
|
|
|
ao_module_setWindowTitle(data.keys[applocale.lang].fwtitle);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
},
|
|
|
- translate: function(targetLang = ""){
|
|
|
+ translate: function(targetLang = "") {
|
|
|
var targetLang = targetLang || applocale.lang;
|
|
|
-
|
|
|
//Check if the given locale exists
|
|
|
- if (applocale.localData.keys[targetLang] == undefined){
|
|
|
+ if (applocale.localData.keys[targetLang] == undefined) {
|
|
|
console.log("[Applocale] This language is not supported. Using default")
|
|
|
return
|
|
|
}
|
|
@@ -52,39 +51,39 @@ var applocale = {
|
|
|
let hasTitleLocale = (applocale.localData.keys[targetLang].titles !== undefined);
|
|
|
let hasStringLocale = (applocale.localData.keys[targetLang].strings !== undefined);
|
|
|
let hasPlaceHolderLocale = (applocale.localData.keys[targetLang].placeholder !== undefined);
|
|
|
- $("*").each(function(){
|
|
|
- if ($(this).attr("title") != undefined && hasTitleLocale){
|
|
|
- let targetString = applocale.localData.keys[targetLang].titles[$(this).attr("title")];
|
|
|
- if (targetString != undefined){
|
|
|
+ $("*").each(function() {
|
|
|
+ if ($(this).attr("title") != undefined && hasTitleLocale) {
|
|
|
+ let targetString = applocale.localData.keys[targetLang].titles[$(this).attr("title")];
|
|
|
+ if (targetString != undefined) {
|
|
|
$(this).attr("title", targetString);
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- if ($(this).attr("locale") != undefined && hasStringLocale){
|
|
|
+ if ($(this).attr("locale") != undefined && hasStringLocale) {
|
|
|
let targetString = applocale.localData.keys[targetLang].strings[$(this).attr("locale")];
|
|
|
- if (targetString != undefined){
|
|
|
+ if (targetString != undefined) {
|
|
|
$(this).html(targetString);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ($(this).attr("placeholder") != undefined && hasPlaceHolderLocale){
|
|
|
+ if ($(this).attr("placeholder") != undefined && hasPlaceHolderLocale) {
|
|
|
let targetString = applocale.localData.keys[targetLang].placeholder[$(this).attr("placeholder")];
|
|
|
- if (targetString != undefined){
|
|
|
- $(this).attr("placeholder",targetString);
|
|
|
+ if (targetString != undefined) {
|
|
|
+ $(this).attr("placeholder", targetString);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- },
|
|
|
- getString: function(key, original, type="strings"){
|
|
|
+ },
|
|
|
+ getString: function(key, original, type = "strings") {
|
|
|
var targetLang = applocale.lang;
|
|
|
- if (applocale.localData.keys[targetLang] == undefined){
|
|
|
+ if (applocale.localData.keys[targetLang] == undefined) {
|
|
|
return original;
|
|
|
}
|
|
|
let targetString = applocale.localData.keys[targetLang].strings[key];
|
|
|
- if (targetString != undefined){
|
|
|
+ if (targetString != undefined) {
|
|
|
return targetString
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return original
|
|
|
}
|
|
|
}
|