On this page
File formats
A file format is the file that holds your translations: JSON, XLIFF, gettext and others. Locize reads and writes these files when you import or export in the app, and when locize-cli syncs or downloads. The syntax of a message inside the file, such as its plurals and placeholders, is the i18n format; Locize does not convert it.
The formats
The export in the app groups the formats by what one file holds: For your code (one file per language and namespace), For translators (the source language beside each target language) and All languages in one file. The import reads every format below.
| Format | File | Export in the app | locize-cli --format |
|---|---|---|---|
| JSON nested, JSON flat | .json | for your code | json, nested, flat |
| YAML nested, YAML flat | .yaml, .yml | for your code | yaml, yaml-nested, yaml-rails, yaml-rails-ns (or yml…) |
| Gettext PO, Gettext PO (i18next) | .po | for your code | po, po_i18next |
| Android resource strings | .xml | for your code | android |
| Apple strings | .strings | for your code | strings |
| Apple String Catalog | .xcstrings | for translators, all languages | xcstrings |
| .NET RESX | .resx | for your code | resx |
| Java properties | .properties | for your code | properties |
| Laravel | .php | for your code | laravel |
| Fluent | .ftl | for your code | fluent |
| XLIFF 1.2, 2.0, 2.1, 2.2 | .xliff, .xlf | for translators, also with all namespaces in one file | xliff12, xliff2, xliff21, xliff22 (or xlf…) |
| CSV | .csv | for translators, all languages | csv |
| Excel (XLSX) | .xlsx | for translators, all languages | xlsx |
| TMX | .tmx | all languages | tmx |
The glossary has formats of its own: TBX and UTX, see glossary.
What Locize keeps of a file
Locize keeps the keys and their texts, not the file itself. The order of the entries and anything else outside a key and its text are not kept, unless the format's section below says so. An exported file is written anew from the keys.
JSON
JSON nested nests the keys at their dots, JSON flat keeps each key whole:
{ "button": { "save": "Save" } }{ "button.save": "Save" }With locize-cli, json nests like JSON nested but keeps a key whole that holds a space, a comma or a ?; nested always nests. Nesting cannot keep every key: a key below another key's text (button.tooltip next to button) or a key that ends in a dot (Saved.) is lost. The CLI warns about each such key, also for YAML, Laravel and Fluent, which nest too; use flat to keep them all.
YAML
As JSON: YAML nested nests at the dots, YAML flat keeps each key whole. With locize-cli, yaml-rails puts the language as the root (en:), as Ruby on Rails expects, and yaml-rails-ns the namespace below it.
button:
save: SaveGettext PO
msgid "button.save"
msgstr "Save"- Entries with
msgctxt. gettext tells two entries apart by their context, so "Open" in a menu and "Open" for a door can have different translations. Gettext PO keeps them apart: the key holdsmsgidandmsgctxt, and themsgctxtalso becomes the key's context. Gettext PO (i18next) turns themsgctxtinto i18next's context suffix:msgctxt "menu"withmsgid "Open"becomes the keyOpen_menu, whicht('Open', { context: 'menu' })looks up. #, fuzzy. A fuzzy entry in a target language arrives marked as needing review. A value marked as needing review goes out as#, fuzzywhen you export in the app, or download with--unpublished true.
Android resource strings
<resources>
<string name="button_save">Save</string>
</resources>A comment becomes the key's context, and the context goes out as the comment again.
Apple strings and String Catalog
Apple strings (.strings) hold one language per file:
"button.save" = "Save";Apple String Catalog (.xcstrings) holds all languages in one file. Import it as Apple String Catalog, all languages: it goes into the namespace named like the file (common.xcstrings into common). Locize converts the file, not the text in it: i18next plural keys (key_one, key_other) stay separate entries instead of becoming plural variations, placeholders like {{name}} stay as they are, and substitutions are not read. For a clean String Catalog, write the texts with its own plural variations and format specifiers.
.NET RESX
<data name="button.save" xml:space="preserve">
<value>Save</value>
</data>A <comment> becomes the key's context, and the context goes out as the comment again.
Java properties
button.save = SaveLaravel
<?php
return [
'button' => ['save' => 'Save'],
];Laravel files nest like JSON nested.
Fluent
button-save = Save
emails =
{ $count ->
[one] You have one unread email.
*[other] You have { $count } unread emails.
}In a project with the i18n format Fluent, Locize checks the values as Fluent: issue 242 flags variable names that differ from the source, issue 243 plural forms that do not fit the language.
XLIFF
XLIFF 1.2, 2.0, 2.1 and 2.2 are exchange formats for translators; Xcode's localization export (.xcloc) uses XLIFF 1.2. The export writes the source language beside a target language, one file per namespace, or all namespaces in one file.
- To import a file of one namespace, it holds one
<file>element, and itsoriginalattribute is the namespace's name. - A
<note>becomes the key's context, andsizeRestrictionits maximum length; both go out again on export. - Inline elements such as
<x>,<ph>or<pc>stay in the text as short tags, and the export writes them as inline elements again. A file imported as 1.2 and exported as 2.0 gets the tags of 2.0.
<trans-unit id="button.save">
<source>Save</source>
<target>Speichern</target>
</trans-unit>CSV and XLSX
CSV and Excel (XLSX) write the source language beside a target language, for translators who work in a spreadsheet:
"key","en","de"
"button.save","Save","Speichern"For the import, the first line names the languages with the codes of your project.
CSV, all languages and Excel (XLSX), all languages hold every language and also the columns namespace, tags, context and maxCharacters (the character limit that issue 310 checks). Each plural form is a row of its own. ###ignore### marks a key missing in the source language, or a plural form a language does not have.
"key","tags","context","maxCharacters","namespace","en","de"
"button.save","","Button in the toolbar","12","common","Save","Speichern"On import, the tags, context and character limits go to the source language, so the file can set them for many keys at once. When you build such a file yourself:
- Read it as CSV, all languages (or Excel (XLSX), all languages) when the import asks. Read as CSV, the import takes only
keyand the column of the language you import. - The column names must match exactly:
context, notContext. A wrongcontext,tagsormaxCharacterscolumn is ignored without an error; a wrongkeyornamespacecolumn imports nothing. - Tags, context and character limits apply only on rows with a text in the source language. Empty cells are skipped.
- In a CSV file,
keyis the first column. From an XLSX file, only the first sheet is imported.
TMX
TMX holds translations as pairs of languages, the usual format of a translation memory. The export writes a version's translations into one file with all languages; the import adds the translations of a TMX file to your project.
Glossary: TBX and UTX
The glossary imports TBX and UTX files with Import glossary, and exports TBX with Export glossary (TBX).