Export formats
Translations can be downloaded in the formats below: in the editor under
Project settings → Export translations, with
localize pull, or from
GET /v1/export. Published releases on the CDN
are always nested i18next JSON.
| Format | For | Files for one namespace | Import |
|---|---|---|---|
i18next | i18next and react-i18next; the format published to the CDN. | en/common.jsonet/common.json | yes |
i18next-flat | i18next with keySeparator: false, or any tool that reads flat key/value JSON. | en/common.jsonet/common.json | yes |
icu | next-intl, and other FormatJS setups that nest messages by the dots in their names. | en/common.jsonet/common.json | yes |
icu-flat | react-intl and FormatJS: one level of message id to ICU message. | en/common.jsonet/common.json | yes |
android | Native Android apps: string and plurals resources with %1$s placeholders. | values/common.xmlvalues-et/common.xml | no |
xcstrings | Native iOS and macOS apps: one catalog per namespace with every language. | common.xcstrings | no |
The examples on this page are real output for one namespace with two keys:
greeting (“Hello {{name}}”) and the plural key cart.items.
How text is stored
Section titled “How text is stored”Text is stored once, in i18next’s notation: {{name}} marks a variable, and a
plural key has one text per plural form of the language (one, few, many,
other, …) with {{count}} for the number. Every other format is written
from that, so a translator works on one text whatever the app reads.
i18next
Section titled “i18next”{ "cart": { "items_one": "{{count}} toode", "items_other": "{{count}} toodet" }, "greeting": "Tere, {{name}}"}Key names are nested at their dots and plural forms get i18next’s suffixes.
i18next-flat writes the same names on one level, for keySeparator: false:
{ "cart.items_one": "{{count}} toode", "cart.items_other": "{{count}} toodet", "greeting": "Tere, {{name}}"}ICU (next-intl, react-intl)
Section titled “ICU (next-intl, react-intl)”{ "cart": { "items": "{count, plural, one {# toode} other {# toodet}}" }, "greeting": "Tere, {name}"}Messages are ICU MessageFormat as FormatJS reads it. icu nests them by the
dots in their names, as next-intl expects; icu-flat keeps one level of
message ids, as react-intl expects.
| Stored | ICU |
|---|---|
{{name}} |
{name} |
{{price, number}} |
{price, number} |
{{when, datetime}} |
{when, date} |
plural forms with {{count}} |
{count, plural, one {# item} other {# items}} |
<b>bold</b> |
unchanged, for rich text |
a literal {, } or ' |
quoted, such as '{' |
A variable name cannot contain spaces or punctuation such as . or -; those
become _, with a warning.
Importing older i18next v3 files
Section titled “Importing older i18next v3 files”Older i18next projects, and Locize projects that never moved to the v4 JSON
format, write plurals differently. Those suffixes are also ordinary key names
in a v4 file, so they are only read as plurals when you say the files are v3:
tick Plurals use the older i18next v3 keys in the editor’s importer, or
send "format": "i18next-v3" to POST /v1/imports. It is
an import format only; nothing is exported in it.
- Languages with one singular and one plural form (English, German, French …)
wrote
itemsanditems_plural: they become theoneandotherforms ofitems. - Other languages numbered their forms by i18next’s v3 rule:
items_0,items_1,items_2in Russian becomeone,fewandmany, and the only form of a Japanese or Chinese key,items_0, becomesother. English-style languages written withsimplifyPluralSuffix: false(items_0,items_1) are read the same way for keys known to be plural.
Every other key keeps its name exactly: a v3 file has no _one / _other
suffixes, so a key such as step_one stays a key of its own.
A numbered key such as step_1 can also be an ordinary key, so the import
decides once per namespace which keys are plurals, and every language follows
that decision. A key is read as a plural when a file of the namespace in the
same import has it as key_plural, when the project already has it as a
plural key, or when a numbered-language file has every form of it (items_0,
items_1 and items_2 in Russian) and nothing says those names are ordinary
keys: no English-style file in the import, and no plain key the project
already has, by the same names. Keys numbered without a gap past the forms a
language has (step_0 … step_3 in Russian, which has three) are a list in
every language of the namespace. A key the import or the project marks as a
plural stays one even so: its numbers within the language’s forms are read
as forms, the rest stay keys of their own, and the report says so. A stray
higher number next to a plural (days_7 next to days_0 … days_2) is a
key of its own. Other numbered keys import as they are, and the report says
how many.
Each form takes the text i18next v3 showed for its numbers, so one v3 text can
fill two forms where today’s rules split a v3 form (Maltese _1 becomes both
two and few), and a form only fractions use, such as Russian other
(1.5), takes the text v3 showed for fractions. A v3 form today’s rules no
longer use, such as Hebrew _2 (20, 30 …), is left out and listed in the
report. A regional file that overrides only some forms keeps just those.
The import report says how many plural keys were read this way.
Importing ICU files
Section titled “Importing ICU files”Import converts the other way. ICU can express things the stored model cannot. A message that uses one of these is skipped, and the import report says which and why:
selectandselectordinal- a plural on a variable other than
count - exact matches such as
=0, andoffset - a plural inside a plural, or two plurals in one message
- number and date styles or skeletons, and
time - a plural with an empty branch, such as
one {}: an empty text is not stored, so the branch would come back missing and show the text ofother
Text around a plural is kept by moving it into every form: “You have
{count, plural, one {# item} other {# items}}” is stored as “You have
{{count}} item” and “You have {{count}} items”.
Three things come back out written differently, with the same meaning:
- A plural that leaves forms to
other. In ICU,othercovers every form a message does not name. Stored plural forms have no such fallback, so the forms the language uses are filled with the text ofother:{count, plural, other {# items}}in English is stored as two forms and exported as{count, plural, one {# items} other {# items}}. - A branch for a form the language does not use, such as
zeroin English, is left out with a warning. ICU never selects it there; write=0cases as a separate message. {count}inside a plural is stored as{{count}}and exported as#, the usual ICU spelling. FormatJS formats#as a number of the language, so 1000 shows as 1,000.
Android
Section titled “Android”<?xml version="1.0" encoding="utf-8"?><resources> <plurals name="common_cart_items"> <item quantity="one">%1$d toode</item> <item quantity="other">%1$d toodet</item> </plurals> <!-- Shown at the top of the home screen --> <string name="common_greeting">Tere, %1$s</string></resources>One file per language, in values/ for the source language and
values-<qualifier>/ for the others (values-et, values-pt-rBR,
values-b+zh+Hant+TW). Pull them into app/src/main/res.
Hebrew, Indonesian and Yiddish go into values-iw, values-in and
values-ji. Android reads these languages from the folders of their old
codes and ignores values-he, values-id and values-yi.
- Names. Android resource names are shared by the whole app, while key
names here are unique within a namespace. So a name is the namespace and the
key joined with
_, and characters other than letters, digits and_become_: keycart.itemsin namespacecommonisR.plurals.common_cart_items. A namespace calledstringsis the exception: its keys keep their own names and land instrings.xml. - Placeholders are positional (
%1$s), numbered in the order the source text uses them, so every language passes arguments alike. The{{count}}of a plural key is%1$d. - Descriptions of keys are written as XML comments.
iOS and macOS
Section titled “iOS and macOS”{ "sourceLanguage" : "en", "strings" : { "cart.items" : { "extractionState" : "manual", "localizations" : { "en" : { "variations" : { "plural" : { "one" : { "stringUnit" : { "state" : "translated", "value" : "%lld item" } }, "other" : { "stringUnit" : { "state" : "translated", "value" : "%lld items" } } } } }, "et" : { "variations" : { "plural" : { "one" : { "stringUnit" : { "state" : "translated", "value" : "%lld toode" } }, "other" : { "stringUnit" : { "state" : "translated", "value" : "%lld toodet" } } } } } } }, "greeting" : { "comment" : "Shown at the top of the home screen", "extractionState" : "manual", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", "value" : "Hello %@" } }, "et" : { "stringUnit" : { "state" : "translated", "value" : "Tere, %@" } } } } }, "version" : "1.0"}One String Catalog per namespace, holding every language. A namespace is a
string table: Localizable is the table Xcode reads by default, and any other
is addressed with table: in code.
- Placeholders are
%@, or%1$@,%2$@when a text has several; the{{count}}of a plural key is%lld. - Review state. An approved translation is
translated; one that is not yet approved isneeds_review, which Xcode shows as needing review. - Descriptions of keys become the catalog’s comments.
Android and iOS files are export-only. React Native apps need neither: use i18next with the SDK.
What an export leaves out
Section titled “What an export leaves out”- Empty text. A key with no text in a language is absent from that language’s file, so the app falls back as it does for any missing key.
- A plural key without an
otherform, in formats that need it. - In a String Catalog, a plural that shows
{{count}}neither in its own forms nor in the source text while using other placeholders, such as “{{name}}has one file” and “{{name}}has several files” as the source: the catalog cannot say where the count is passed. A plural with no placeholders at all, such as “One survivor” and “Several survivors”, is written as a count substitution and takes the count as its argument. So is a translation that spells the number out where the source shows it; the count stays at the source’s position. - A key whose name cannot exist beside another in the format, such as
aanda.bin nested ICU, or two keys that become one Android resource name.
Each case is listed in the export’s warnings.