Use XLIFF source rather than resname when there's no target
This commit is contained in:
parent
e4a7fd8eed
commit
8633ebbca0
@ -90,7 +90,7 @@ class XliffFileLoader implements LoaderInterface
|
|||||||
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
|
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
|
||||||
// If the xlf file has another encoding specified, try to convert it because
|
// If the xlf file has another encoding specified, try to convert it because
|
||||||
// simple_xml will always return utf-8 encoded values
|
// simple_xml will always return utf-8 encoded values
|
||||||
$target = $this->utf8ToCharset((string) (isset($translation->target) ? $translation->target : $source), $encoding);
|
$target = $this->utf8ToCharset((string) (isset($translation->target) ? $translation->target : $translation->source), $encoding);
|
||||||
|
|
||||||
$catalogue->set((string) $source, $target, $domain);
|
$catalogue->set((string) $source, $target, $domain);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class XliffFileLoaderTest extends TestCase
|
|||||||
$loader = new XliffFileLoader();
|
$loader = new XliffFileLoader();
|
||||||
$catalogue = $loader->load(__DIR__.'/../fixtures/resname.xlf', 'en', 'domain1');
|
$catalogue = $loader->load(__DIR__.'/../fixtures/resname.xlf', 'en', 'domain1');
|
||||||
|
|
||||||
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'foo'), $catalogue->all('domain1'));
|
$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'foo', 'qux' => 'qux source'), $catalogue->all('domain1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIncompleteResource()
|
public function testIncompleteResource()
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
<source>baz</source>
|
<source>baz</source>
|
||||||
<target>foo</target>
|
<target>foo</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="4" resname="qux">
|
||||||
|
<source>qux source</source>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
Reference in New Issue
Block a user