diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index b10a940121a483b1d34ae5c988f994c28463a5b4..5dc2a064bd5f973ed77b34388ae269b10ea434fa 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 230ce68ff44c083acbc88507e6c9c20e48c1688c..dbfd793ab8c81d83f2b3d62f86c41c7acb0f15f2 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;