From 03ae601d21f63367d500e3f3817eb580ec50e27b Mon Sep 17 00:00:00 2001 From: Ben Martin Date: Sat, 16 Mar 2024 21:18:58 +1000 Subject: [PATCH] i18n: when loading from po file the domain from the file has to be wiped --- src/SimpleSAML/Locale/Localization.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/SimpleSAML/Locale/Localization.php b/src/SimpleSAML/Locale/Localization.php index 8f3be015ee..02fc118256 100644 --- a/src/SimpleSAML/Locale/Localization.php +++ b/src/SimpleSAML/Locale/Localization.php @@ -251,6 +251,22 @@ private function loadGettextGettextFromPO( $file->getfileName(), $langPath, )); + $file = new File($langPath . $domain . '.po', false); + if ($file->getRealPath() !== false && $file->isReadable()) { + $translations = (new PoLoader())->loadFile($file->getRealPath()); + $translations->setDomain(''); + $arrayGenerator = new ArrayGenerator(); + $this->translator->addTranslations( + $arrayGenerator->generateArray($translations) + ); + } else { + Logger::debug(sprintf( + "%s - Localization file '%s' not found or not readable in '%s', falling back to default", + $_SERVER['PHP_SELF'], + $file->getfileName(), + $langPath, + )); + } } }