8000 Use XLIFF source rather than resname when there's no target · symfony/symfony@8633ebb · GitHub
[go: up one dir, main page]

Skip to content

Commit 8633ebb

Browse files
Use XLIFF source rather than resname when there's no target
1 parent e4a7fd8 commit 8633ebb

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, $
9090
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
9191
// If the xlf file has another encoding specified, try to convert it because
9292
// simple_xml will always return utf-8 encoded values
93-
$target = $this->utf8ToCharset((string) (isset($translation->target) ? $translation->target : $source), $encoding);
93+
$target = $this->utf8ToCharset((string) (isset($translation->target) ? $translation->target : $translation->source), $encoding);
9494

9595
$catalogue->set((string) $source, $target, $domain);
9696

src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testLoadWithResname()
6666
$loader = new XliffFileLoader();
6767
$catalogue = $loader->load(__DIR__.'/../fixtures/resname.xlf', 'en', 'domain1');
6868

69-
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'foo'), $catalogue->all('domain1'));
69+
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'foo', 'qux' => 'qux source'), $catalogue->all('domain1'));
7070
}
7171

7272
public function testIncompleteResource()

src/Symfony/Component/Translation/Tests/fixtures/resname.xlf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<source>baz</source>
1515
<target>foo</target>
1616
</trans-unit>
17+
<trans-unit id="4" resname="qux">
18+
<source>qux source</source>
19+
</trans-unit>
1720
</body>
1821
</file>
1922
</xliff>

0 commit comments

Comments
 (0)
0