translation: Add support for ipl-i18n

This commit is contained in:
Johannes Meyer 2021-05-28 13:55:49 +02:00
parent 8fe282b9aa
commit 5af833bb6d
2 changed files with 16 additions and 4 deletions

View File

@ -6,7 +6,8 @@ namespace Icinga\Module\Translation\Clicommands;
use Icinga\Date\DateFormatter;
use Icinga\Module\Translation\Cli\ArrayToTextTableHelper;
use Icinga\Module\Translation\Cli\TranslationCommand;
use Icinga\Util\Translator;
use ipl\I18n\GettextTranslator;
use ipl\I18n\StaticTranslator;
/**
* Timestamp test helper
@ -89,12 +90,19 @@ class TestCommand extends TranslationCommand
foreach ($this->params->getAllStandalone() as $l) {
$this->locales[] = $l;
}
// TODO: get from to environment by default?
if (empty($this->locales)) {
/** @var GettextTranslator $translator */
$translator = StaticTranslator::$instance;
$this->locales = $translator->listLocales();
}
}
protected function callTranslated($callback, $arguments, $locale = 'C')
protected function callTranslated($callback, $arguments, $locale = 'en_US')
{
Translator::setupLocale($locale);
/** @var GettextTranslator $translator */
$translator = StaticTranslator::$instance;
$translator->setLocale($locale);
return call_user_func_array($callback, $arguments);
}

View File

@ -235,8 +235,12 @@ class GettextTranslationHelper
'--language=PHP',
'--keyword=translate',
'--keyword=translate:1,2c',
'--keyword=translateInDomain:2',
'--keyword=translateInDomain:2,3c',
'--keyword=translatePlural:1,2',
'--keyword=translatePlural:1,2,4c',
'--keyword=translatePluralInDomain:2,3',
'--keyword=translatePluralInDomain:2,3,5c',
'--keyword=mt:2',
'--keyword=mt:2,3c',
'--keyword=mtp:2,3',