![]() |
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.
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>
| 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.
You can localize an XLIFF file either in Soluling Desktop or in Soluling Cloud.
Simple.xlf) on Soluling or click the New from File or Files button and select the file.fi\Simple.xlf.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.
Simple.xlf), or drag and drop the file onto the page. Click Create.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.
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.
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.
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.