diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index e61cd49e..2c783bc7 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -74,7 +74,7 @@ var ComunicWeb = { /** * Return current language */ - getCurrentLanguage: function(){}, + current: function(){}, /** * Initializate languages diff --git a/assets/js/common/langs.js b/assets/js/common/langs.js index 8d7f67e7..f3db0738 100644 --- a/assets/js/common/langs.js +++ b/assets/js/common/langs.js @@ -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