Skip to content

Commit

Permalink
Translation updater to use the built in builder
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Dec 17, 2020
1 parent 58c10a2 commit 9f3a4ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
19 changes: 2 additions & 17 deletions src/I18n/TranslationUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,8 @@ public function storeTranslations(TranslationLogger $logger)

public function writeCatalog(DynamicArrayCatalog $catalog)
{
$indent = " ";
$implode = "\n";
$content = ['<?php', PHP_EOL, 'return ['];

foreach($catalog->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)
Expand Down

0 comments on commit 9f3a4ca

Please sign in to comment.