mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Save language in user account settings.
This commit is contained in:
parent
40593e00ed
commit
c633ce13b5
@ -113,7 +113,12 @@ ComunicWeb.components.langPicker = {
|
||||
closeModal();
|
||||
|
||||
//Set the language
|
||||
ComunicWeb.common.langs.setLang(this.getAttribute("data-lang"));
|
||||
var lang = this.getAttribute("data-lang");
|
||||
ComunicWeb.common.langs.setLang(lang);
|
||||
|
||||
//Save settings in user account if signed in
|
||||
if(signed_in())
|
||||
ComunicWeb.components.settings.interface.setLanguage(lang);
|
||||
|
||||
//Restart the app
|
||||
ComunicWeb.common.system.reset();
|
||||
|
@ -45,6 +45,33 @@ ComunicWeb.components.settings.interface = {
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get language settings
|
||||
*
|
||||
* @param {function} callback
|
||||
*/
|
||||
getLanguage: function(callback){
|
||||
//Make a request over the API
|
||||
var apiURI = "settings/get_language";
|
||||
var params = {};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set (update) language settinsg
|
||||
*
|
||||
* @param {string} language The language to apply
|
||||
* @param {function} callback
|
||||
*/
|
||||
setLanguage: function(language, callback){
|
||||
//Make a request over the API
|
||||
var apiURI = "settings/set_language";
|
||||
var params = {
|
||||
lang: language
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get security account settings
|
||||
*
|
||||
|
@ -174,8 +174,19 @@ ComunicWeb.user.userLogin = {
|
||||
|
||||
//Else refresh login state to get user ID
|
||||
ComunicWeb.user.userLogin.refreshLoginState(function(){
|
||||
|
||||
//Then get and apply user language settings
|
||||
ComunicWeb.components.settings.interface.getLanguage(function(lang){
|
||||
|
||||
if(!lang.error)
|
||||
ComunicWeb.common.langs.setLang(lang.lang);
|
||||
|
||||
//And then we'll be able to perform next action
|
||||
afterLogin(true);
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user