Skip to content

Commit

Permalink
[Translator] Preserve default domain when extracting strings from php…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
Stadly authored and fabpot committed Apr 27, 2019
1 parent 2774705 commit ca77d9a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Symfony/Component/Translation/Extractor/PhpExtractor.php
Expand Up @@ -226,7 +226,10 @@ protected function parseTokens($tokens, MessageCatalogue $catalog)
} 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 {
Expand Down
Expand Up @@ -52,6 +52,7 @@ public function testExtraction($resource)
$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',
Expand Down
Expand Up @@ -55,3 +55,5 @@
<?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); ?>

0 comments on commit ca77d9a

Please sign in to comment.