Skip to content

Commit 02f9463

Browse files
committed
Merge branch '2.3' into 2.7
Conflicts: .travis.yml src/Symfony/Component/Translation/Loader/XliffFileLoader.php
2 parents fda92d1 + a0d131f commit 02f9463

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Loader/XliffFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ 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;
5656
// If the xlf file has another encoding specified, try to convert it because
5757
// simple_xml will always return utf-8 encoded values
58-
$target = $this->utf8ToCharset((string) $translation->target, $encoding);
58+
$target = $this->utf8ToCharset((string) isset($translation->target) ? $translation->target : $source, $encoding);
5959

6060
$catalogue->set((string) $source, $target, $domain);
6161

Tests/Loader/XliffFileLoaderTest.php

Lines changed: 3 additions & 3 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()
@@ -136,7 +135,8 @@ public function testLoadNotes()
136135

137136
$this->assertEquals(array('notes' => array(array('priority' => 1, 'content' => 'foo'))), $catalogue->getMetadata('foo', 'domain1'));
138137
// message without target
139-
$this->assertNull($catalogue->getMetadata('extra', 'domain1'));
138+
$this->assertEquals(array('notes' => array(array('content' => 'bar', 'from' => 'foo'))), $catalogue->getMetadata('extra', 'domain1'));
139+
// message with empty target
140140
$this->assertEquals(array('notes' => array(array('content' => 'baz'), array('priority' => 2, 'from' => 'bar', 'content' => 'qux'))), $catalogue->getMetadata('key', 'domain1'));
141141
}
142142
}

0 commit comments

Comments
 (0)