From ff509f2b5c808d8cc72adce19c46462b6160ac14 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 19 Nov 2017 15:23:38 -0800 Subject: [PATCH] added updating of translation when user changes profile language --- public/modules/core/config/i18n/french.js | 2 +- .../users/controllers/settings.client.controller.js | 7 +++++-- public/modules/users/services/auth.client.service.js | 4 ++++ .../users/views/settings/edit-profile.client.view.html | 8 ++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/public/modules/core/config/i18n/french.js b/public/modules/core/config/i18n/french.js index adfc6318..4b54b50a 100644 --- a/public/modules/core/config/i18n/french.js +++ b/public/modules/core/config/i18n/french.js @@ -6,7 +6,7 @@ angular.module('core').config(['$translateProvider', function ($translateProvide MENU: 'MENU', SIGNUP_TAB: 'Créer un Compte', SIGNIN_TAB: 'Connexion', - SIGNOUT_TAB: 'Créer un compte', + SIGNOUT_TAB: 'Déconnexion', EDIT_PROFILE: 'Modifier Mon Profil', MY_SETTINGS: 'Mes Paramètres', CHANGE_PASSWORD: 'Changer mon Mot de Pass', diff --git a/public/modules/users/controllers/settings.client.controller.js b/public/modules/users/controllers/settings.client.controller.js index 5d5c7be7..45cc0ed3 100755 --- a/public/modules/users/controllers/settings.client.controller.js +++ b/public/modules/users/controllers/settings.client.controller.js @@ -1,7 +1,7 @@ 'use strict'; -angular.module('users').controller('SettingsController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth', 'currentUser', 'USERS_URL', - function($scope, $rootScope, $http, $state, Users, Auth, currentUser, USERS_URL) { +angular.module('users').controller('SettingsController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth', 'currentUser', 'USERS_URL', '$translate', + function($scope, $rootScope, $http, $state, Users, Auth, currentUser, USERS_URL, $translate) { $scope.user = currentUser; @@ -18,6 +18,9 @@ angular.module('users').controller('SettingsController', ['$scope', '$rootScope' $scope.success = true; $scope.error = null; $scope.user = response.data; + + $translate.use($scope.user.language); + Auth.update($scope.user); }, function(error) { $scope.success = null; $scope.error = 'Could not update your profile due to an error with the server. Sorry about this!' diff --git a/public/modules/users/services/auth.client.service.js b/public/modules/users/services/auth.client.service.js index 63fa8067..4ca7c621 100644 --- a/public/modules/users/services/auth.client.service.js +++ b/public/modules/users/services/auth.client.service.js @@ -56,6 +56,10 @@ angular.module('users').factory('Auth', ['$window', '$q', 'User', this._currentUser = new_user; }, + update: function(new_user) { + this._currentUser = new_user; + }, + logout: function() { $window.user = null; userState.isLoggedIn = false; diff --git a/public/modules/users/views/settings/edit-profile.client.view.html b/public/modules/users/views/settings/edit-profile.client.view.html index d7840c48..c4df4e75 100755 --- a/public/modules/users/views/settings/edit-profile.client.view.html +++ b/public/modules/users/views/settings/edit-profile.client.view.html @@ -19,7 +19,7 @@

{{ 'FIRST_NAME_LABEL' | translate }}

- +
@@ -27,7 +27,7 @@

{{ 'LAST_NAME_LABEL' | translate }}

- +
@@ -56,7 +56,7 @@

{{ 'USERNAME_LABEL' | translate }}

- +
@@ -65,7 +65,7 @@

{{ 'EMAIL_LABEL' | translate }}

- +