merged branch xkobal/2.1 (PR #6079)
This PR was squashed before being merged into the 2.1 branch (closes #6079).
Commits
-------
bbeff54
Xliff with other node than source or target are ignored
Discussion
----------
Xliff with other node than source or target are ignored
Referring to the xliff XSD, the format can allow other nodes like <note>. Check only count is dangerous if others nodes are present, and we aren't sure that nodes are the two we wan't (source and target)
And the real problem if that if there is other node in translation, the translation is silently ignored.
---------------------------------------------------------------------------
by stloyd at 2012-11-20T17:44:47Z
You should add test that covers this, as well as #6078 should be closed (branch `2.1` is merged from time to time to `master`).
---------------------------------------------------------------------------
by xkobal at 2012-11-21T11:13:32Z
I have added a new node to xliff fixtures and edit test to be sure node isn't ignored.
This commit is contained in:
commit
aa12428867
@ -39,7 +39,7 @@ class XliffFileLoader implements LoaderInterface
|
|||||||
|
|
||||||
$catalogue = new MessageCatalogue($locale);
|
$catalogue = new MessageCatalogue($locale);
|
||||||
foreach ($xml->xpath('//xliff:trans-unit') as $translation) {
|
foreach ($xml->xpath('//xliff:trans-unit') as $translation) {
|
||||||
if (2 !== count($translation)) {
|
if (!isset($translation->source) || !isset($translation->target)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$catalogue->set((string) $translation->source, (string) $translation->target, $domain);
|
$catalogue->set((string) $translation->source, (string) $translation->target, $domain);
|
||||||
|
@ -38,7 +38,7 @@ class XliffFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$loader = new XliffFileLoader();
|
$loader = new XliffFileLoader();
|
||||||
$catalogue = $loader->load(__DIR__.'/../fixtures/resources.xlf', 'en', 'domain1');
|
$catalogue = $loader->load(__DIR__.'/../fixtures/resources.xlf', 'en', 'domain1');
|
||||||
|
|
||||||
$this->assertEquals(array('foo' => 'bar', 'key' => ''), $catalogue->all('domain1'));
|
$this->assertEquals(array('foo' => 'bar', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
|
||||||
$this->assertFalse($catalogue->has('extra', 'domain1'));
|
$this->assertFalse($catalogue->has('extra', 'domain1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
<source>key</source>
|
<source>key</source>
|
||||||
<target></target>
|
<target></target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="4">
|
||||||
|
<source>test</source>
|
||||||
|
<target>with</target>
|
||||||
|
<note>note</note>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
Reference in New Issue
Block a user