Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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); ?>