Soluling home   Document home

XLIFF Localization and Internationalization

XLIFF Localization and Internationalization

XLIFF (Wikipedia) is an XML-based localization file format. It is mainly used to exchange translations between tools. Soluling Desktop and Soluling Cloud support XLIFF 1.x (1.0, 1.1, and 1.2) and XLIFF 2.x files.

Only a few development tools use XLIFF as their native resource format. Angular is the most common one, and Xcode exports its strings as XLIFF inside .xcloc files. Usually, the native resources are first exported to XLIFF, then the XLIFF file is translated, and finally the translations are imported back into the native resources. This process requires two format conversions (native to XLIFF and XLIFF to native), and each conversion may lose some information. This is why it is recommended to localize the native resources directly. Soluling supports dozens of native formats. If your native format is supported, do not use XLIFF, but let Soluling handle the native format directly. For example, if you use Xcode, read iOS/macOS localization.

XLIFF file format

An XLIFF file contains one or more trans-unit (1.x) or unit (2.x) elements. Each element contains a string to be localized. The following XLIFF 1.2 file contains one string:

<xliff version="1.2">
  <file original="Simple.txt" datatype="plaintext" source-language="en">
    <body>
      <trans-unit id="one">
        <source>One</source>
      </trans-unit>
    </body>
  </file>
</xliff>

When the file has been localized, the file element has a target-language attribute, and each trans-unit contains a target element that contains the translated value.

<xliff version="1.2">
  <file original="Simple.txt" datatype="plaintext" source-language="en" target-language="fi">
    <body>
      <trans-unit id="one">
        <source>One</source>
        <target>Yksi</target>
      </trans-unit>
    </body>
  </file>
</xliff>

XLIFF 2.0 uses a different structure. The languages are attributes of the xliff element (srcLang and trgLang), and the source and target elements are inside a segment element.

<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="fi">
  <file id="f1">
    <unit id="sample">
      <segment>
        <source>This is a sample</source>
        <target>Tämä on esimerkki</target>
      </segment>
    </unit>
  </file>
</xliff>

How Soluling reads and writes XLIFF

Item Description
Strings Each trans-unit (1.x) or unit (2.x) becomes a row in the project. The source element contains the original value.
Context By default, the context is the value of the resname attribute, or the id attribute if there is no resname attribute. You can change this on the Options sheet.
Existing translations If the original file already contains target elements, Soluling imports them into the project when you create it. Use the Options sheet to specify if and how translations are imported later.
Notes The note (1.x) and notes (2.x) elements become comments that the translator sees. See the Features samples.
Segments A unit can contain more than one segment: mrk elements with mtype="seg" in 1.2 and several segment elements in 2.0. See the Segments samples.
Output When building, Soluling creates one XLIFF file for each language. The localized file has the same structure as the original, the target language set, and a target element for each translated string. Use the Write options sheet to configure how the files are written.

Note! If your XLIFF file was created by Angular's extract tool (e.g., messages.xlf), use the Angular resource file type instead of the generic XLIFF type. It understands Angular's placeholders, plurals, and meanings. See Angular localization.

Localization process

You can localize an XLIFF file either in Soluling Desktop or in Soluling Cloud.

Desktop process Desktop process

  1. Start Soluling. Drag the XLIFF file (e.g., Simple.xlf) on Soluling or click the New from File or Files button and select the file.
  2. If Soluling asks what kind of file it is, select XLIFF file (or Angular resource file for an Angular file) and click OK.
  3. Project Wizard appears. Select the original language and the target languages, for example, Finnish, and complete the wizard.
  4. Translate the project.
  5. Choose Home | Build All to build the localized XLIFF files. By default, Soluling creates them in language-specific subdirectories, for example, fi\Simple.xlf.

Cloud process Cloud process

With Soluling Cloud, you translate the XLIFF file in your browser: upload the file, translate it in Translate, and download the localized files. You need a Soluling account. See the available Cloud plans.

Create a project

  1. Sign in at www.soluling.com and open Cloud > Dashboard for Projects, Users and Terminology.
  2. Click Add a new project, then Select files and pick your XLIFF file (e.g., Simple.xlf), or drag and drop the file onto the page. Click Create.
  3. On the next page, check the project's Name. It defaults to the file's name.
  4. Check that the Original language matches the source language of the file, for example, English.
  5. Under Target languages, check the languages you want to translate to, for example, Finnish and German.
  6. Under Source type, select XLIFF file (.xlf, .xliff), or Angular resource file (.xlf, .xmb) for an Angular file.
  7. Click Create. The project appears on the dashboard, and its status changes to Ready once the file has been processed.

Translate the project

Click the project's green Translate button on the dashboard. Translate opens the project, and you can type the translations into the grid. Machine translation suggestions, translation memory, and spell checking are available there. You do not have to finish every language before moving on to the next step.

Notes are shown as comments.

Get the localized files

  1. In Translate's top bar, click the project's name. It opens the project's Manage page, the same page that the project's Manage button on the dashboard opens.
  2. If you have translated something since the localized files were last built, the page says Localized files need to be built. Click Build localized files and wait until it finishes.
  3. The Files section lists the XLIFF file with a download button for each target language. Download the localized XLIFF files and return them to the tool that created the original file.

Update the project

When you get a new version of the XLIFF file, upload it, translate what is new or changed, and download the localized files again. On the dashboard, click the project's Update file button (the upload arrow), select the new file or drop it onto the page, and click Update. Existing translations are kept, so you only translate the strings that were added or changed.

The dashboard is one of four ways to use Soluling Cloud. You can also use the SoluCLI command-line tool, Soluling Desktop, or SoluMake, which can run the update and build steps in your build pipeline. See the Cloud tutorial for all of them.

Samples

GitHub and <data-dir>\Samples\XLIFF contain XLIFF samples in two directories: 1.2 for XLIFF 1.2 and 2.0 for XLIFF 2.0. They contain the following samples:

File Description 1.2 2.0
Simple.xlf A simple file that contains a few strings. Study this first. yes yes
Features.xlf A file that contains notes (comments for the translator). yes yes
Segments.xlf A file whose units contain more than one segment. SegmentsEnFi.xlf (1.2) and SegmentsEn.xlf (2.0) are variants of it. yes yes
Sport\Sport.xlf A file that contains information about some sports. yes yes
Dialog.xlf A Windows dialog resource exported to XLIFF. Contains restype and resname attributes and the coordinates of the controls. yes -
messages12.xlf (1.2)
messages.xlf (2.0)
XLIFF files created by Angular's extract tool. Use the Angular type for these. yes yes
Tests\*.xlf Test files that contain existing translations, alternative translations (alt-trans), and language codes with a script subtag (e.g., en-Latn). yes -

The localized Finnish files are in the fi subdirectories.

Configuring XLIFF localization

You can configure how to localize your XLIFF file (.xliff, .xlf) by selecting the item in the project tree, right-clicking, and choosing the Options menu. A source dialog appears that lets you edit the options. This source uses the following option sheets.

Read more about other data files such as XML, XSL, JSON, YAML, INI, Excel, SVG, TMX, XLIFF, text and binary files.