Skip to content
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.

FormatFileExport in the applocize-cli --format
JSON nested, JSON flat.jsonfor your codejson, nested, flat
YAML nested, YAML flat.yaml, .ymlfor your codeyaml, yaml-nested, yaml-rails, yaml-rails-ns (or yml…)
Gettext PO, Gettext PO (i18next).pofor your codepo, po_i18next
Android resource strings.xmlfor your codeandroid
Apple strings.stringsfor your codestrings
Apple String Catalog.xcstringsfor translators, all languagesxcstrings
.NET RESX.resxfor your coderesx
Java properties.propertiesfor your codeproperties
Laravel.phpfor your codelaravel
Fluent.ftlfor your codefluent
XLIFF 1.2, 2.0, 2.1, 2.2.xliff, .xlffor translators, also with all namespaces in one filexliff12, xliff2, xliff21, xliff22 (or xlf…)
CSV.csvfor translators, all languagescsv
Excel (XLSX).xlsxfor translators, all languagesxlsx
TMX.tmxall languagestmx

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:

json
{ "button": { "save": "Save" } }
json
{ "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.

yaml
button:
  save: Save

Gettext PO

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 holds msgid and msgctxt, and the msgctxt also becomes the key's context. Gettext PO (i18next) turns the msgctxt into i18next's context suffix: msgctxt "menu" with msgid "Open" becomes the key Open_menu, which t('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 #, fuzzy when you export in the app, or download with --unpublished true.

Android resource strings

xml
<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

xml
<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

properties
button.save = Save

Laravel

php
<?php
return [
  'button' => ['save' => 'Save'],
];

Laravel files nest like JSON nested.

Fluent

ftl
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 its original attribute is the namespace's name.
  • A <note> becomes the key's context, and sizeRestriction its 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.
xml
<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:

csv
"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.

csv
"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 key and the column of the language you import.
  • The column names must match exactly: context, not Context. A wrong context, tags or maxCharacters column is ignored without an error; a wrong key or namespace column 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, key is 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).