From 6a810bf75a3016a1478130f297e70e5b22f24da8 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 25 Feb 2023 17:19:17 +0100 Subject: [PATCH] I18n: fix handling core mode in po2json() --- src/I18n.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/I18n.php b/src/I18n.php index c16e72f..56aa37d 100644 --- a/src/I18n.php +++ b/src/I18n.php @@ -285,10 +285,11 @@ class I18n { * * @param string $locale The locale of the input PO file * @param string $path The path of the input PO file + * @param bool $core Set to True if it's a run for core translations * * @return string JSON encoded file content */ - public static function po2json($locale, $path) { + public static function po2json($locale, $path, $core=false) { $fileHandler = new \Sepia\PoParser\SourceHandler\FileSystem($path); $poparser = new \Sepia\PoParser\Parser($fileHandler); $catalog = $poparser->parse(); @@ -305,7 +306,7 @@ class I18n { return json_encode(array( 'messages' => $messages, 'locale' => $locale, - 'domain' => self :: TEXT_DOMAIN, + 'domain' => $core?self :: CORE_TEXT_DOMAIN:self :: TEXT_DOMAIN, 'plural_expr' => '(n > 1)', )); } @@ -675,7 +676,7 @@ class I18n { } // Compile messages from PO file to JS catalog file - $js_catalog = self :: po2json($lang, $po_file); + $js_catalog = self :: po2json($lang, $po_file, $core_mode); $js_file = "$root_path/$lang.js"; if(!$fd = fopen($js_file, 'w')) { Log :: error(self::_("Fail to open %s JS catalog file in write mode (%s)."),