[Translator] Preserve default domain when extracting strings from php files

This commit is contained in:
Stadly 2019-04-26 16:33:25 +02:00 committed by Fabien Potencier
parent 2774705c39
commit ca77d9a33e
3 changed files with 7 additions and 1 deletions

View File

@ -226,7 +226,10 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
} elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
$this->skipMethodArgument($tokenIterator);
} elseif (self::DOMAIN_TOKEN === $item) {
$domain = $this->getValue($tokenIterator);
$domainToken = $this->getValue($tokenIterator);
if ('' !== $domainToken) {
$domain = $domainToken;
}
break;
} else {

View File

@ -52,6 +52,7 @@ EOF;
$expectedNowdoc => 'prefix'.$expectedNowdoc,
'{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples' => 'prefix{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
'concatenated message with heredoc and nowdoc' => 'prefixconcatenated message with heredoc and nowdoc',
'default domain' => 'prefixdefault domain',
],
'not_messages' => [
'other-domain-test-no-params-short-array' => 'prefixother-domain-test-no-params-short-array',

View File

@ -55,3 +55,5 @@ EOF
<?php echo $view['translator']->trans('typecast', ['a' => (int) '123'], 'not_messages'); ?>
<?php echo $view['translator']->transChoice('msg1', 10 + 1, [], 'not_messages'); ?>
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), [], 'not_messages'); ?>
<?php echo $view['translator']->trans('default domain', [], null); ?>