8000 Support omitting the <target> node in an .xlf file. · symfony/symfony@3dcda1a · GitHub
[go: up one dir, main page]

Skip to content

Commit 3dcda1a

Browse files
leofeyeraitboudad
authored andcommitted
Support omitting the <target> node in an .xlf file.
1 parent cca29d8 commit 3dcda1a

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public function load($resource, $locale, $domain = 'messages')
4848
foreach ($xml->xpath('//xliff:trans-unit') as $translation) {
4949
$attributes = $translation->attributes();
5050

51-
if (!(isset($attributes['resname']) || isset($translation->source)) || !isset($translation->target)) {
51+
if (!(isset($attributes['resname']) || isset($translation->source))) {
5252
continue;
5353
}
5454

5555
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
56-
$target = (string) $translation->target;
56+
$target = (string) isset($translation->target) ? $translation->target : $source;
5757

5858
// If the xlf file has another encoding specified, try to convert it because
5959
// simple_xml will always return utf-8 encoded values

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function testIncompleteResource()
5555
$loader = new XliffFileLoader();
5656
$catalogue = $loader->load(__DIR__.'/../fixtures/resources.xlf', 'en', 'domain1');
5757

58-
$this->assertEquals(array('foo' => 'bar', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
59-
$this->assertFalse($catalogue->has('extra', 'domain1'));
58+
$this->assertEquals(array('foo' => 'bar', 'extra' => 'extra', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
6059
}
6160

6261
public function testEncoding()

0 commit comments

Comments
 (0)
0