PO and XLIFF 2 both express the same conceptual model — a source string, its translation, and language metadata — but they disagree on almost every detail of how to encode it. PO uses msgid / msgstr pairs at the top level and stuffs metadata into a header pseudo-entry; XLIFF 2 wraps each translation in a <unit> with a <segment> containing <source> and <target> elements, and hangs the language attributes off the root <xliff> and <file> elements. Most converters either flatten everything into a generic key/value map or silently drop the target-language attribute, leaving downstream tools guessing whether a file is source-only or already translated.
i18n-convert preserves the source string, the translation, and the target language code on the way through, emitting a well-formed XLIFF 2 document with trgLang set from the Language: header of the PO file. The fixture below is the canonical simple.po from the project's own test suite: a three-entry German file. Notice how the Language: de header in the PO file becomes the trgLang="de" attribute on the XLIFF 2 root, and each msgid/msgstr pair becomes a <unit> whose id is the source string. This page shows the exact command and the verbatim output produced by the latest CLI build.
Command
i18n-convert simple.po --to xliff2 -o simple.xliff
Input
# Simple PO file for testing
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: de\n"
"MIME-Version: 1.0\n"
msgid "Hello"
msgstr "Hallo"
msgid "Goodbye"
msgstr "Auf Wiedersehen"
msgid "Welcome to %s"
msgstr "Willkommen bei %s"
Output
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" trgLang="de">
<file id="f1">
<unit id="Hello">
<segment>
<source>Hello</source>
<target>Hallo</target>
</segment>
</unit>
<unit id="Goodbye">
<segment>
<source>Goodbye</source>
<target>Auf Wiedersehen</target>
</segment>
</unit>
<unit id="Welcome to %s">
<segment>
<source>Welcome to %s</source>
<target>Willkommen bei %s</target>
</segment>
</unit>
</file>
</xliff>