cache language version in localStorage
This commit is contained in:
parent
31aede3418
commit
600e2bc022
|
@ -290,13 +290,35 @@ $(window).load(function() {
|
|||
$('title').html('‫واگذارنده');
|
||||
}
|
||||
|
||||
// get the translation file and continue after
|
||||
// if we already have this version of this language in localstorage, we
|
||||
// use that cached version. we do this because $.ajax doesn't respect caching, it seems
|
||||
if(localStorageIsEnabled()
|
||||
&& (typeof localStorage['languageData-' + window.availableLanguages[window.selectedLanguage]] != 'undefined' && localStorage['languageData-' + window.availableLanguages[window.selectedLanguage]] !== null)) {
|
||||
proceedToSetLanguageAndLogin(JSON.parse(localStorage['languageData-' + window.availableLanguages[window.selectedLanguage]]));
|
||||
}
|
||||
// if we need to get the language file from the server
|
||||
else {
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: window.fullUrlToThisQvitterApp + 'locale/' + window.availableLanguages[window.selectedLanguage],
|
||||
error: function(data){console.log(data)},
|
||||
success: function(data) {
|
||||
|
||||
// store this response in localstorage
|
||||
if(localStorageIsEnabled()) {
|
||||
localStorage['languageData-' + window.availableLanguages[window.selectedLanguage]] = JSON.stringify(data);
|
||||
}
|
||||
|
||||
proceedToSetLanguageAndLogin(data);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// proceed to set language and login
|
||||
function proceedToSetLanguageAndLogin(data){
|
||||
window.sL = data;
|
||||
|
||||
window.siteTitle = $('head title').html(); // remember this for later use
|
||||
|
@ -368,11 +390,7 @@ $(window).load(function() {
|
|||
remove_spinner();
|
||||
},true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* ·
|
||||
·
|
||||
|
|
Loading…
Reference in New Issue
Block a user