profile: store preferred language in the database
This commit is contained in:
@@ -453,7 +453,7 @@ angular.module('Application').filter('tr', translateFilterFactory);
|
||||
// Cloudron REST API wrapper
|
||||
// ----------------------------------------------
|
||||
|
||||
angular.module('Application').service('Client', ['$http', '$interval', '$timeout', 'md5', 'Notification', function ($http, $interval, $timeout, md5, Notification) {
|
||||
angular.module('Application').service('Client', ['$http', '$interval', '$timeout', 'md5', 'Notification', '$translate', function ($http, $interval, $timeout, md5, Notification, $translate) {
|
||||
var client = null;
|
||||
|
||||
// variable available only here to avoid this._property pattern
|
||||
@@ -2327,6 +2327,15 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.setProfileLanguage = function (language, callback) {
|
||||
post('/api/v1/profile/language', { language: language }, null, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 204) return callback(new ClientError(status, data));
|
||||
|
||||
callback(null, data);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.setProfileEmail = function (email, password, callback) {
|
||||
post('/api/v1/profile/email', { email: email, password: password }, null, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
@@ -2530,6 +2539,11 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
this.getProfile(function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (result.language !== '' && $translate.use() !== result.language) {
|
||||
console.log('Changing users language from ' + $translate.use() + ' to ', result.language);
|
||||
$translate.use(result.language);
|
||||
}
|
||||
|
||||
that.setUserInfo(result);
|
||||
callback(null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user