Currently we support XLIFF file (.xlf, .xliff) version 1.2 as per XLIFF specification. Some XLIFF usage examples are:

Elements supported

The XLIFF specification is more or less ‘tl;dr’ so we support the most popular stuff. Non-supported information or elements will not be saved. The context and notes will be saved as custom key attributes along with some other information for the Angular XLIFF format. The supported elements are:

Import

As the file is imported, we try to find the source and target language tags and match them against existing languages. If only one of either source or target languages is defined in the file, we import the language specified, however XLIFF specifications indicates both source and target must be specified. Specifying the language manually will assume target language is the one you are setting.

Handling translation states

Your target tags can contain certain translation states, for example:

<source>source text</source>
<target state="translated">target translation</target>

Lokalise reads these states and updates translation statuses accordingly.

XLIFF state

Translation status on Lokalise

translated

Reviewed = false, unverified = false

final, signed-off

Reviewed = true, unverified = false

new

Reviewed = false, unverified = false

needs-translation

Reviewed = false, unverified = true

needs-adaptation

Reviewed = false, unverified = true

needs-l10n

Reviewed = false, unverified = true

needs-review-adaptation

Reviewed = false, unverified = true

needs-review-l10n

Reviewed = false, unverified = true

needs-review-translation

Reviewed = false, unverified = true

Please note that the Reviewed status will become available only if the project admin has enabled the Reviewing feature in the project settings.

Export

Select the appropriate platform's format when exporting. Choosing Angular XLIFF causes plurals (see below) to be exported in ICU format (you can also check our blog post which gives a nice introduction to the ICU message format). As for the other XLIFF formats, plurals will be exported as JSON objects with keys and values.

Working with offline XLIFF

If the Offline translation feature is enabled in the project settings, task assignees can export the assigned items in the XLIFF format to work on them offline. Then, the finalized XLIFF file can be imported back to the assigned task. To achieve that, open the Tasks page, find the task you are interested in, and click on the Offline XLIFF dropdown:

Plural support

For all three we support ICU message format and JSON encoded string plurals. Currently, this is the predefined set of plural forms according to the Unicode CLDR Project which are described in the Plural Rules specification. Each language has its own set of tags specified in the Language Plural Rules

For Apple XLIFF files we also support the Apple format for keeping plurals. It's similar to the process in .stringsdict files as it contains format key and plural forms. There are keys for each format plural form and one for format. See example for details.


  <file original="Hello/en.lproj/Localizable.stringsdict" source-language="en" datatype="plaintext" target-language="ru">
    <body>
      <trans-unit id="/plural_test:dict/NSStringLocalizedFormatKey:dict/:string">
        <source>%#@format@</source>
        <target>%#@format@</target>
      </trans-unit>
      <trans-unit id="/plural_test:dict/format:dict/few:dict/:string">
        <source>Other</source>
        <target>Немного</target>
      </trans-unit>
      <trans-unit id="/plural_test:dict/format:dict/many:dict/:string">
        <source>Other</source>
        <target>Много</target>
      </trans-unit>
      <trans-unit id="/plural_test:dict/format:dict/one:dict/:string">
        <source>One</source>
        <target>Один</target>
      </trans-unit>
      <trans-unit id="/plural_test:dict/format:dict/other:dict/:string">
        <source>Other</source>
        <target>Другое</target>
      </trans-unit>
    </body>
  </file>

Supported forms are:

  • zero

  • one

  • two

  • few

  • many

  • other

Forms like =0 or =404 will be lost at import.

Read more about plurals in our docs article.

Custom attributes

You can easily set XLIFF attributes in the useful JSON in our key editor. Follow the examples below.

Sample data

An XLIFF file example with English as the source language with 2 plural forms and Arabic as the target language with 6 plural forms:

<!--?xml version="1.0" encoding="UTF-8" ?-->
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" target-language="ar" datatype="plaintext" original="user_section.tmpl">
        <body>
            <trans-unit id="header" datatype="html">
                <source>Hello</source>
                <target> ... </target>
                <context-group purpose="location">
                    <context context-type="sourcefile">app/app.component.ts</context>
                    <context context-type="linenumber">14</context>
                </context-group>
                <note priority="1" from="description">Sample header</note>
                <note priority="1" from="meaning">Welcome visitors</note>
            </trans-unit>
            <trans-unit id="wolves" datatype="html">
                <source>{wolves, plural, one {one} other {wolves}}</source>
                <target>{wolves, plural, zero {...} one {...} two {...} few {...} many {...} other {...}}</target>
            </trans-unit>
        </body>
    </file>
</xliff>

Here is a full example of custom attributes in JSON with 1 context group and 2 notes:

{
    "datatype": "html",
    "context-groups": [
        {
            "contexts": [
                {
                    "context-type": "sourcefile",
                    "value": "app/app.component.ts"
                },
                {
                    "context-type": "linenumber",
                    "value": "1"
                }
            ],
            "purpose": "location"
        }
    ],
    "notes": [
        {
            "value": "An introduction header for this sample",
            "priority": "1",
            "from": "description"
        },
        {
            "value": "User welcome",
            "priority": "1",
            "from": "meaning"
        }
    ]
}
Did this answer your question?