Skip to content

Commit

Permalink
Merge pull request #60 from bedita/fix/command-domain-match
Browse files Browse the repository at this point in the history
Handle domains with double quotes
  • Loading branch information
batopa authored Jun 9, 2022
2 parents 32c24f0 + cecbfd1 commit 7446e68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Command/GettextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ private function parseContentSecondArg($start, $content, $options): void

$limit = count($matches[0]);
for ($i = 0; $i < $limit; $i++) {
$domain = $matches[3][$i];
$str = $matches[4][$i];
$domain = !empty($matches[1][$i]) ? $matches[1][$i] : $matches[3][$i];
$str = !empty($matches[2][$i]) ? $matches[2][$i] : $matches[4][$i];

// context not handled for now
if (strpos($start, '__x') === 0) {
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/Command/GettextCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ public function parseFileProvider(): array
],
'DomainSampleD' => [
'A twig string in a domain',
'A twig string in a domain in double quotes',
'A twig string in a domain with {0}',
],
],
],
Expand Down Expand Up @@ -403,6 +405,8 @@ public function parseDirProvider(): array
],
'DomainSampleD' => [
'A twig string in a domain',
'A twig string in a domain in double quotes',
'A twig string in a domain with {0}',
'1 test __d',
],
'DomainSampleDN' => [
Expand Down
4 changes: 4 additions & 0 deletions tests/files/gettext/contents/sample.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
{{ __('A twig string with \'single quotes\'', true) }}

{{ __d('DomainSampleD', 'A twig string in a domain') }}

{{ __d("DomainSampleD", "A twig string in a domain in double quotes") }}

{{ __d('DomainSampleD', 'A twig string in a domain with {0}') }}

0 comments on commit 7446e68

Please sign in to comment.