From 0b1c2011ed88d5b0b1a319112bd08a944ae876aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 11 Apr 2023 20:42:45 -0700 Subject: [PATCH] Restore all previously loaded translations when sending user notifications Fixes #5087 --- app/Core/Translator.php | 4 ++-- app/Model/UserNotificationModel.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Core/Translator.php b/app/Core/Translator.php index f516271e6..65227da59 100644 --- a/app/Core/Translator.php +++ b/app/Core/Translator.php @@ -14,10 +14,10 @@ class Translator * Locale * * @static - * @access private + * @access public * @var array */ - private static $locales = array(); + public static $locales = array(); /** * Instance diff --git a/app/Model/UserNotificationModel.php b/app/Model/UserNotificationModel.php index 9e90cf5d5..6e4adc38b 100644 --- a/app/Model/UserNotificationModel.php +++ b/app/Model/UserNotificationModel.php @@ -41,6 +41,7 @@ class UserNotificationModel extends Base */ public function sendUserNotification(array $user, $event_name, array $event_data) { + $loadedLocales = Translator::$locales; Translator::unload(); // Use the user language otherwise use the application language (do not use the session language) @@ -55,7 +56,7 @@ class UserNotificationModel extends Base } // Restore locales - $this->languageModel->loadCurrentLanguage(); + Translator::$locales = $loadedLocales; } /**