From 9f3a4ca00a03d560b8181150b6077d49a3ddf817 Mon Sep 17 00:00:00 2001 From: Brooke Bryan Date: Thu, 17 Dec 2020 11:30:48 +0000 Subject: [PATCH] Translation updater to use the built in builder --- composer.json | 2 +- src/I18n/TranslationUpdater.php | 19 ++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/composer.json b/composer.json index 663a2fd..e765c29 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "packaged/routing": "~2.1", "packaged/ui": "~1.0", "packaged/docblock": "~1.1", - "packaged/i18n": "~1.0", + "packaged/i18n": "~1.2", "symfony/console": "~4.2", "psr/log": "~1.1" }, diff --git a/src/I18n/TranslationUpdater.php b/src/I18n/TranslationUpdater.php index 60960f1..872c20f 100644 --- a/src/I18n/TranslationUpdater.php +++ b/src/I18n/TranslationUpdater.php @@ -63,23 +63,8 @@ public function storeTranslations(TranslationLogger $logger) public function writeCatalog(DynamicArrayCatalog $catalog) { - $indent = " "; - $implode = "\n"; - $content = ['getData() as $mid => $options) - { - $content[] = $indent . "'" . addslashes($mid) . "' => ["; - foreach($options as $optK => $text) - { - $text = $this->_getTranslation($text, $this->_lang); - $content[] = $indent . $indent . "'" . addslashes($optK) . "' => '" . addslashes($text) . "',"; - } - $content[] = '],'; - } - $content[] = '];'; - $content[] = ''; - $this->_writeFile($this->_file, implode($implode, $content)); + $catalog->setTranslationCallback(function ($text) { return $this->_getTranslation($text, $this->_lang); }); + $this->_writeFile($this->_file, $catalog->asPhpFile(true)); } protected function _writeFile($filename, $data)