Restore all previously loaded translations when sending user notifications

Fixes #5087
This commit is contained in:
Frédéric Guillot 2023-04-11 20:42:45 -07:00 committed by Frédéric Guillot
parent ae7bc0b74d
commit 0b1c2011ed
2 changed files with 4 additions and 3 deletions

View File

@ -14,10 +14,10 @@ class Translator
* Locale * Locale
* *
* @static * @static
* @access private * @access public
* @var array * @var array
*/ */
private static $locales = array(); public static $locales = array();
/** /**
* Instance * Instance

View File

@ -41,6 +41,7 @@ class UserNotificationModel extends Base
*/ */
public function sendUserNotification(array $user, $event_name, array $event_data) public function sendUserNotification(array $user, $event_name, array $event_data)
{ {
$loadedLocales = Translator::$locales;
Translator::unload(); Translator::unload();
// Use the user language otherwise use the application language (do not use the session language) // 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 // Restore locales
$this->languageModel->loadCurrentLanguage(); Translator::$locales = $loadedLocales;
} }
/** /**