Skip to content

Commit

Permalink
bug #30919 [Translator] Fix wrong dump for PO files (deguif)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[Translator] Fix wrong dump for PO files

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

When working on #30909 I encountered this bug.
Currently the tests were passing, because the po fixture file contained only one translation.

Commits
-------

b54abfc Fix wrong dump for PO files
  • Loading branch information
fabpot committed Apr 6, 2019
2 parents 86210b3 + b54abfc commit 09a808d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Translation/Dumper/PoFileDumper.php
Expand Up @@ -40,7 +40,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
$newLine = true;
}
$output .= sprintf('msgid "%s"'."\n", $this->escape($source));
$output .= sprintf('msgstr "%s"', $this->escape($target));
$output .= sprintf('msgstr "%s"'."\n", $this->escape($target));
}

return $output;
Expand Down
Expand Up @@ -20,7 +20,7 @@ class PoFileDumperTest extends TestCase
public function testFormatCatalogue()
{
$catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$catalogue->add(['foo' => 'bar', 'bar' => 'foo']);

$dumper = new PoFileDumper();

Expand Down
Expand Up @@ -23,7 +23,7 @@ public function testLoad()
$resource = __DIR__.'/../fixtures/resources.po';
$catalogue = $loader->load($resource, 'en', 'domain1');

$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals(['foo' => 'bar', 'bar' => 'foo'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
Expand Down
Expand Up @@ -5,4 +5,7 @@ msgstr ""
"Language: en\n"

msgid "foo"
msgstr "bar"
msgstr "bar"

msgid "bar"
msgstr "foo"

0 comments on commit 09a808d

Please sign in to comment.