Navigation Menu

Skip to content

Commit

Permalink
Support omitting the <target> node in an .xlf file.
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer authored and aitboudad committed Aug 25, 2015
1 parent cca29d8 commit 3dcda1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Translation/Loader/XliffFileLoader.php
Expand Up @@ -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
Expand Down
Expand Up @@ -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()
Expand Down

0 comments on commit 3dcda1a

Please sign in to comment.