XLIFF Parser Plugin
Plugin source location: <serge_root>/lib/Serge/Engine/Plugin/parse_xliff.pm
This plugin is used to parse XLIFF 1.x and XLIFF 2.x documents (a subset thereof). Parser doesn't do any strict XLIFF validation, and only requires some basic structure as shown in the examples below. In the translated document, Plugin will add <target>...</target>
nodes with translations, as well as set proper target-language="LANGUAGE"
attribute on each <file>
tag.
In case XML format validation fails, the plugin can send an error report to specified recipients. If no email settings are provided, it will simply report the error in the console output.
Code Example (XLIFF 1.x)
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file original="sample1.txt" source-language="en">
<body>
<trans-unit id="foo">
<source>Foo</source>
</trans-unit>
<trans-unit id="bar">
<source>Bar</source>
</trans-unit>
</body>
</file>
<file original="sample2.txt" source-language="en">
<header>
<note>File-related comment</note>
</header>
<body>
<group id="mygroup">
<note>Group-related comment 1</note>
<note>Group-related comment 2</note>
<trans-unit id="foo2">
<source>Foo2 <x xid="bar2"/></source>
</trans-unit>
<trans-unit id="bar2">
<note>Unit-related comment</note>
<source>Bar2</source>
</trans-unit>
</group>
</body>
</file>
</xliff>
Limitation: All inline elements inside <source>...</source>
will be exposed as a raw XML string for translation.
Original file names, as well as group and unit identifier are extracted and combined into a single hint, along with file- group- and unit-level notes. Given the example above, the final hint for string Bar2
will look like this:
file-original:sample2.txt group-id:mygroup unit-id:bar2
File note: File-related comment
Group note: Group-related comment 1
Group note: Group-related comment 2
Unit note: Unit-related comment
Code Example (XLIFF 2.x)
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="2.0">
<file original="sample1.txt" source-language="en">
<header/>
<body>
<unit id="foo">
<source>Foo</source>
</unit>
<unit id="bar">
<source>Bar</source>
</unit>
</body>
</file>
<file original="sample2.txt" source-language="en">
<notes>
<note>File-related comment 1</note>
<note>File-related comment 2</note>
</notes>
<body>
<group id="mygroup">
<notes>
<note>Group-related comment</note>
</notes>
<unit id="foo2">
<source>Foo2 <ph id="1" dataRef="bar2" /></source>
</unit>
<unit id="bar2">
<notes>
<note>Unit-related comment</note>
</notes>
<segment>
<source>Bar2</source>
</segment>
<ignorable>Baz2</ignorable>
<segment>
<source>Etc2</source>
</segment>
</unit>
</group>
</body>
</file>
</xliff>
Limitation: All inline elements inside <source>...</source>
will be exposed as a raw XML string for translation.