XLIFF 1.2 is a standard format for exchanging localization data between tools. It is widely used in the localization industry and is supported by many translation management systems.
It is an XML-based format that allows you to store translations, comments, and other localization-related information in a structured way. XLIFF 1.2 is also widely used in Xcode projects for iOS and macOS applications,
you can find it in .xcloc files.
XLIFF 1.2 is currently in beta phase, and it may not fully support all standard features. We encourage you to test it and provide feedback to us.
Format structure
The XLIFF 1.2 format consists of a root <xliff> element, which contains one or more <file> elements. Each <file> element represents a single translation file and contains one or more <body> elements.
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2">
<file source-language="en" target-language="pl" datatype="plaintext" original="messages">
<body>
<trans-unit id="hello_world" xml:space="preserve">
<source>Hello World</source>
<target>Witaj Świecie</target>
<note>My comment</note>
</trans-unit>
</body>
</file>
</xliff>
The file usually contains translations for two languages, the source language and the target language.
The source-language attribute specifies the source language, and the target-language attribute specifies the target language.
Attributes
source-language: The language code of the source language.target-language: The language code of the target language.datatype: The type of data in the file. It can beplaintext,html, orxhtml.original: The name of the original file.xml:space: Thexml:spaceattribute specifies how whitespace should be handled. It can bepreserveordefault.
Comments
You can add comments and description to your translation units using the <note> element. The <note> element can be used to provide additional information about the translation, such as context or usage notes.
Limitations
Currently, the XLIFF 1.2 format is not fully supported in SimpleLocalize. The following limitations apply:
- The
xml:spaceattribute is always set topreservein the exported file. It will be ignored during import. - The
datatypeattribute is always set toplaintextin the exported file. It will be ignored during import. - The
originalattribute can have up to 128 characters. If it exceeds this limit, it will be skipped during import/export.
Upload source translations
To upload source translations to SimpleLocalize, use the upload command with the --uploadFormat xliff:1.2 parameter, and provide the path to your en.xliff file using the --uploadPath parameter,
and the language key using the --languageKey parameter.
simplelocalize upload \
--apiKey PROJECT_API_KEY \
--uploadLanguageKey en \
--uploadFormat xliff:1.2 \
--uploadPath ./en.xliff
Learn more about upload command.
Add
--overwriteflag to update existing translations in SimpleLocalize from the imported file. Otherwise, only new translations will be added.
Export translations
To export translations from SimpleLocalize to the Android Strings file format, use the download command with the --downloadFormat xliff:1.2 parameter, and provide the path to the output file using the --downloadPath parameter.
simplelocalize download \
--apiKey PROJECT_API_KEY \
--downloadFormat xliff:1.2 \
--downloadLanguageKeys pl,de \
--downloadPath ./{lang}.xliff
Please note that the --downloadLanguageKeys parameter is optional.
If you don't provide it, all translations will be downloaded.
However, it's recommended to provide it to download only the necessary translations.