What is XLIFF and what to do prior to launching it for translation?
File Extensions | .xlf, .xliff |
API Extension | xlf |
Import | Yes |
Export | Yes |
Pluralization supported? | Yes |
Descriptions supported? | Yes |
Format Options | enclose_in_cdata, include_translation_state, indent_size, indent_style, ignore_source_translations, ignore_target_translations, export_key_id_as_resname, export_key_name_hash_as_extradata, override_file_language, strip_placeholder_delimiters, delimit_placeholders |
XLIFF (current version XLIFF 1.2) is the most-widely used file format in the translation industry. It can be seen as the mirror of the source file that breaks down source content into various segments stored in tags (e.g. <trans-unit>, <seg-source>).
XLIFF is XML based, and hence, it is subject to basic XML conventions, such as validity and being well-formed. As a result, it is a good practice to always have a sanity check prior to translation. The easiest way to do this is to change the file extension from .xliff (.xlf) to .xml and open it with your web browser. If the file is valid, you will see a well-organized document structure that would otherwise appear to be either unrenderable or with an error message.
Note: There is an updated XLIFF referred to as XLIFF 2.0. Although it has a lot in common with the more widely-used XLIFF, it is basically a different file format that is incompatible with XLIFF most times.
Code Sample
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="global" datatype="plaintext" source-language="de-DE" target-language="en-GB">
<body>
<trans-unit id="boolean_key">
<source xml:lang="de-DE">--- true
</source>
<target xml:lang="en-GB">--- true
</target>
</trans-unit>
<trans-unit id="empty_string_translation">
<source xml:lang="de-DE"/>
<target xml:lang="en-GB"/>
</trans-unit>
<trans-unit id="key_with_description">
<source xml:lang="de-DE">Schau dir das mal an! Dieser Schlüssel hat eine Beschreibung!</source>
<target xml:lang="en-GB">Check it out! This key has a description! (At least in some formats)</target>
<note>This is the amazing description for this key!</note>
</trans-unit>
<trans-unit id="key_with_line-break">
<source xml:lang="de-DE">Diese Übersetzung hat
einen Zeilenumbruch.</source>
<target xml:lang="en-GB">This translations contains
a line-break.</target>
</trans-unit>
<trans-unit id="nested.deeply.key">
<source xml:lang="de-DE">Ich bin ein tief verschachtelter Schlüssel.</source>
<target xml:lang="en-GB">I'm a deeply nested key.</target>
</trans-unit>
<trans-unit id="nested.key">
<source xml:lang="de-DE">Dieser Schlüssel ist innerhalb eines Namensraumes verschachtelt.</source>
<target xml:lang="en-GB">This key is nested inside a namespace.</target>
</trans-unit>
<trans-unit id="null_translation">
<source xml:lang="de-DE"/>
<target xml:lang="en-GB"/>
</trans-unit>
<trans-unit id="sample_collection">
<source xml:lang="de-DE">---
- erstes Item
- zweites Item
</source>
<target xml:lang="en-GB">---
- first item
- second item
- third item
</target>
</trans-unit>
<trans-unit id="simple_key">
<source xml:lang="de-DE">Einfacher Schlüssel, einfache Nachricht, so einfach</source>
<target xml:lang="en-GB">Simple key, simple message, so simple.</target>
</trans-unit>
<trans-unit id="unverified_key">
<source xml:lang="de-DE">Diese Übersetzung ist noch nicht bestätigt und wartet drauf!</source>
<target xml:lang="en-GB">This translation is not yet verified and waits for it. (In some formats we also export this status)</target>
</trans-unit>
</body>
</file>
</xliff>
Plural forms
Pluralized keys will be exported using the following syntax:
<trans-unit id="plural_key">
<source xml:lang="en">{"one":"one chair","other":"{nrOfChairs} chairs","zero":"no chairs"}</source>
<target xml:lang="de">{"one":"ein Stuhl","other":"{nrOfChairs} Stühle","zero":"keine Stühle"}</target>
</trans-unit>
Format Options
Identifier | enclose_in_cdata |
Type | boolean |
Upload | No |
Download | Yes |
Default | false |
Description | Encloses translations containing html tags in CDATA |
Identifier | include_translation_state |
Type | boolean |
Upload | No |
Download | Yes |
Default | false |
Description | Include state of translations in the target locale |
Identifier | indent_size |
Type | integer |
Upload | No |
Download | Yes |
Default | 4 |
Description | Specifies number of indentation characters |
Identifier | indent_style |
Type | string |
Upload | No |
Download | Yes |
Default | space |
Description | Specifies indentation character. Allowed values are space and tab . |
Identifier | ignore_source_translations |
Type | boolean |
Upload | Yes |
Download | No |
Default | false |
Description | Ignores the source translations in the file during the upload (to avoid accidental source language updates) |
Identifier | ignore_target_translations |
Type | boolean |
Upload | Yes |
Download | No |
Default | false |
Description | Ignores the target translations in the file during the upload (to avoid accidental source language updates) |
Identifier | export_key_id_as_resname |
Type | boolean |
Upload | No |
Download | Yes |
Default | false |
Description |
Exports the Key ID as the "resname" attribute. |
Identifier | export_key_name_hash_as_extradata |
Type | boolean |
Upload | No |
Download | Yes |
Default | false |
Description | Exports the Key Name hash as the "extradata" attribute. |
Identifier |
override_file_language |
Type | boolean |
Upload | Yes |
Download | No |
Default | false |
Description | This file format typically contains language information in the file itself. Use this option to override the language with one you specify. |
Identifier |
strip_placeholder_delimiters |
Type | boolean |
Upload | Yes |
Download | No |
Default | false |
Description | Removes <ph> tags from translations |
Identifier |
delimit_placeholders |
Type | boolean |
Upload | No |
Download | Yes |
Default | false |
Description | Wrap translation placeholders in <ph> tags. You must have defined valid placeholder styles in your project settings |
Side note
Xcode can package your localizable strings into the industry standard XLIFF format to send off for localization with Phrase.
We're also supporting XLIFF 2.0.
Learn More