From 82a3652373fa941aa06c0b3d73bf5395a5628d5d Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Wed, 16 Mar 2022 18:18:12 +0100 Subject: [PATCH] Fix --- lib/SimpleSAML/Locale/Localization.php | 2 +- lib/SimpleSAML/Locale/Translate.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index b10a94012..5dc2a064b 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -251,7 +251,7 @@ class Localization $file = new File($langPath . $domain . '.po'); if ($this->fileSystem->exists($file->getRealPath()) && $file->isReadable()) { - $translations = (new PoLoader())->loadFile($file); + $translations = (new PoLoader())->loadFile($file->getRealPath()); $arrayGenerator = new ArrayGenerator(); $this->translator->addTranslations( $arrayGenerator->generateArray($translations) diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index 230ce68ff..dbfd793ab 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace SimpleSAML\Locale; use Gettext\Translator; +use Gettext\TranslatorFunctions; use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; @@ -81,8 +82,7 @@ class Translate // This may happen if you forget to set a variable and then run undefinedVar through the trans-filter $original = $original ?? 'undefined variable'; - $loc = new Localization(Configuration::getInstance()); - $text = $loc->getTranslator()->gettext($original); + $text = TranslatorFunctions::getTranslator()->gettext($original); if (func_num_args() === 1) { return $text; @@ -108,8 +108,7 @@ class Translate // This may happen if you forget to set a variable and then run undefinedVar through the trans-filter $original = $original ?? 'undefined variable'; - $loc = new Localization(Configuration::getInstance()); - $text = $loc->getTranslator()->ngettext($original, $plural, $value); + $text = TranslatorFunctions::getTranslator()->ngettext($original, $plural, $value); if (func_num_args() === 3) { return $text; -- GitLab