diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index a59e75db4f1aa..9f55d901231b3 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -48,12 +48,12 @@ public function load($resource, $locale, $domain = 'messages') foreach ($xml->xpath('//xliff:trans-unit') as $translation) { $attributes = $translation->attributes(); - if (!(isset($attributes['resname']) || isset($translation->source)) || !isset($translation->target)) { + if (!(isset($attributes['resname']) || isset($translation->source))) { continue; } $source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source; - $target = (string) $translation->target; + $target = (string) isset($translation->target) ? $translation->target : $source; // If the xlf file has another encoding specified, try to convert it because // simple_xml will always return utf-8 encoded values diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index e5b731b71390d..15ff655ce6981 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -55,8 +55,7 @@ public function testIncompleteResource() $loader = new XliffFileLoader(); $catalogue = $loader->load(__DIR__.'/../fixtures/resources.xlf', 'en', 'domain1'); - $this->assertEquals(array('foo' => 'bar', 'key' => '', 'test' => 'with'), $catalogue->all('domain1')); - $this->assertFalse($catalogue->has('extra', 'domain1')); + $this->assertEquals(array('foo' => 'bar', 'extra' => 'extra', 'key' => '', 'test' => 'with'), $catalogue->all('domain1')); } public function testEncoding()