From 65e94ed789b2c2df0ef2320acf773275dbebecbe Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 23 Apr 2015 16:53:37 -0500 Subject: [PATCH] i18n: Switch language immediately on profile update --- include/class.i18n.php | 8 ++------ include/class.staff.php | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/class.i18n.php b/include/class.i18n.php index 566cf6945..5d5000b2a 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -372,10 +372,6 @@ class Internationalization { static function getCurrentLanguage($user=false) { global $thisstaff, $thisclient; - static $session = null; - - if (!isset($session)) - $session = &$_SESSION['::lang']; $user = $user ?: $thisstaff ?: $thisclient; if ($user && method_exists($user, 'getLanguage')) @@ -383,8 +379,8 @@ class Internationalization { return $lang; // Support the flag buttons for guests - if ((!$user || $user != $thisstaff) && $session) - return $session; + if ((!$user || $user != $thisstaff) && $_SESSION['::lang']) + return $_SESSION['::lang']; return self::getDefaultLanguage(); } diff --git a/include/class.staff.php b/include/class.staff.php index 22cda33e7..b573eaa6e 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -603,9 +603,6 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { if($errors) return false; - $_SESSION['::lang'] = null; - TextDomain::configureForUser($this); - $this->firstname = $vars['firstname']; $this->lastname = $vars['lastname']; $this->email = $vars['email']; @@ -622,6 +619,9 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { $this->default_paper_size = $vars['default_paper_size']; $this->lang = $vars['lang']; + $_SESSION['::lang'] = null; + TextDomain::configureForUser($this); + return $this->save(); } -- GitLab