mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Automatically detect appropriated language
This commit is contained in:
parent
e214573e4e
commit
40593e00ed
@ -74,7 +74,7 @@ var ComunicWeb = {
|
||||
/**
|
||||
* Return current language
|
||||
*/
|
||||
getCurrentLanguage: function(){},
|
||||
current: function(){},
|
||||
|
||||
/**
|
||||
* Initializate languages
|
||||
|
@ -26,12 +26,19 @@ ComunicWeb.common.langs = {
|
||||
*
|
||||
* @return {String} The id of the current language
|
||||
*/
|
||||
getCurrentLanguage: function(){
|
||||
current: function(){
|
||||
|
||||
//Check if a language has been set in local storage
|
||||
if(localStorage.getItem(this._lang_storage_field_name) != null)
|
||||
return localStorage.getItem(this._lang_storage_field_name);
|
||||
|
||||
//Get user language
|
||||
var language = navigator.language || navigator.userLanguage;
|
||||
|
||||
if(language){
|
||||
return language.split("-")[0];
|
||||
}
|
||||
|
||||
//Else return default language
|
||||
return ComunicWeb.__config.defaultLanguage;
|
||||
},
|
||||
@ -61,7 +68,7 @@ ComunicWeb.common.langs = {
|
||||
ComunicWeb.debug.logMessage("Get and install languages...");
|
||||
|
||||
//Get languages to install
|
||||
this.__currentLang = this.getCurrentLanguage();
|
||||
this.__currentLang = this.current();
|
||||
this.__defaultLang = ComunicWeb.__config.defaultLanguage;
|
||||
|
||||
//Everything is OK
|
||||
|
Loading…
Reference in New Issue
Block a user