Import and export
How translation files move in and out of Lingo.
Supported formats
| Format | Extensions | Notes |
|---|---|---|
| JSON (nested) | .json | Nested objects become dotted keys (home.hero.title), as in i18next. |
| JSON (flat) | .json | Dotted keys are kept exactly as written. |
| XLIFF 1.2 | .xlf, .xliff | One <file> with a flat list of <trans-unit> elements. |
| XLIFF 2.0 | .xlf, .xliff | One <file>, one <segment> per <unit>. |
| CSV | .csv | A key,value header row. source and note columns are optional. |
| gettext | .po, .pot | msgid is the key and msgstr is the value. ICU plurals become gettext plural forms. |
On the import and export screens you pick a format by name, for example "JSON (nested)" or "gettext (.po)". Import can also detect the format for you.
Namespaces and keys
You choose the namespace when you import. The file does not carry one, so an imported file is a flat set of keys and values. Nested JSON is flattened to dotted keys on the way in.
On export, the namespace path goes in front of each key, so title in the namespace marketing.hero is written as marketing.hero.title. Nested formats rebuild the tree from that.
JSON values that are not text
A key in Lingo holds one text. A JSON file can hold other kinds of value, and import treats each kind in a fixed way:
| Value in the file | What import does |
|---|---|
| Text | Imported. |
A number, true or false | Imported as text: the number 5 is stored as the text "5", and true as the text "true". An export writes it back in quotes ("5"). |
A list ([ ... ]) | Never imported and never turned into text, whatever it holds, empty or not. The rest of the file is imported. |
null | Treated as an empty value: it creates no key, changes nothing and is counted as Unchanged. |
An empty object ({}) in nested JSON | Creates nothing and is not counted. |
The import screen names every list it leaves out, by key, in the preview and again after you apply. A list is not a row of the preview and is not in its counts.
To import a list, rewrite it as numbered keys and import the file again. Number from 0, so each key matches the item's place in the list. In nested JSON,
{ "rating": ["Poor", "Good"] }
becomes
{ "rating": { "0": "Poor", "1": "Good" } }
which imports as the keys rating.0 and rating.1. In flat JSON, write "rating.0": "Poor" and "rating.1": "Good". An app then reads each item by its own key; Lingo does not hand the items back as a list.
Importing
You need the translator role or higher. See Roles and sign-in.
-
Upload. Open the project's import screen and drop a file on it, or click to browse. Lingo detects the format (Auto-detect in the Format menu) and, when it can, the Target language. Check both and change them if they are wrong. Pick a Namespace, or leave it on
(root).- XLIFF and
.pofiles name their own language, and Lingo uses it. For other formats Lingo guesses from the text, which needs a fair amount of text. If the guess fits several variants of one language, it asks you to choose the variant. - The language must already be one of the project's languages.
- A file can be up to 2 MB. A larger one is refused as soon as you choose it, with the message File is too large (2 MB max). Split a big file, for example by namespace or by language, and import the parts one after another. To update values for keys that already exist, you can also use
lingo pushfrom the CLI.
- XLIFF and
-
Choose how to resolve conflicts. Under On conflict, pick one option for the whole file. It decides what happens to a key that already has a different value.
Option What it does Skip (default) Keeps the existing value. Overwrite Replaces it with the imported value. Approved text that a translator overwrites goes back to draft. Merge Refreshes values that are not approved and keeps approved ones. A file has no per-key timestamps, so approval decides, not date. -
Preview. Click Preview changes. Nothing is written yet. Lingo compares the file with the current values for that language and namespace and sorts each row:
Row Meaning New The key has no value yet. It will be created. Conflicts A value already exists and differs from the file. The conflict option decides what happens. Unchanged The value is identical, or the file's value is empty or only whitespace. Nothing happens. The table shows up to 2000 rows, 100 per page. The counts above it always cover the whole file.
If a JSON file has lists, a notice between the counts and the table says how many, for example 2 lists will not be imported, and names the key of each one. It also says what to do: "A key in Lingo holds one text, so a list is skipped whatever it contains. To import one, rewrite it as numbered keys (a list named rating becomes rating.0, rating.1, …) and import the file again." You can still apply; everything else in the file is imported. See JSON values that are not text.
For a single conflicting row you can pick a different option in the Action column. That choice applies to that row only and keeps the preview.
A preview belongs to the file and the settings it was made with. If you choose another file, or change Format, Target language, Namespace or On conflict, the preview and your per-row choices are cleared and Apply import is switched off. Click Preview changes again.
-
Apply. Click Apply import. It is available only while a preview is on screen, and it imports with the settings of that preview. Lingo checks the plan again on the server and then writes it.
- New keys arrive as drafts. They also get an empty entry in each of the project's other languages.
- An existing value keeps its status, with one exception. An approved value that you overwrite stays approved only if you are an admin or owner. If a translator overwrites it, it goes back to draft until an admin or owner approves it, as with an edit in the editor. Merge leaves approved values alone.
- A value in the file that is empty or only whitespace (spaces, tabs, line breaks) never clears existing text and never creates a key. A value that is meant to be a single space cannot be imported.
- Replaced values are saved in the key's history, as with an edit in the editor.
- Lists in a JSON file are left out. A second message, for example 2 lists were not imported, names their keys again with the same advice. It stays on screen until you close it.
- If the request fails, for example because the connection drops, the screen says Import failed. Some rows may already be written. Preview again to see what is left. An import is written in batches, so preview the same file again: rows that were written now show as Unchanged.
Small imports finish at once and take you to the translations list. Big ones run in the background (see below).
Exporting
Anyone with access to the project can export, including viewers.
- Open the project's export screen.
- Tick the Languages you want. The source language is listed too.
- Keep All namespaces ticked to export every key, or untick it and tick the namespaces you want.
- (root) stands for the keys that are not in any namespace. Tick it alone to export only those, or together with namespaces.
- Each namespace is listed by its full path. Ticking one does not include the namespaces under it; tick those too if you want them.
- While nothing is ticked, Export is disabled and the list says "Pick at least one namespace."
- Choose a Format. The default is JSON (nested).
- Turn on Include drafts & in-review if you want unapproved text. It is off by default, so only approved values are exported.
- Click Export.
One language downloads as a single file named like fr.json. Several languages download as a zip with one file per language.
Missing values are never exported, whatever the toggle says. Machine-translated drafts count as ordinary drafts, so they only appear when Include drafts & in-review is on. See Machine translation.
Exports run straight away. Recent exports lists the last 10. Re-download runs the same export again with the same options, so it reflects the project's current translations, not a saved copy of the old file.
Each export is counted on the organisation's Settings → Statistics page under your name, one call per language file; admins and owners can see it.
To fetch translations in a build instead, use the CLI, which has its own setting for which statuses to include.
Large imports
An import that would change more than 1000 values runs in the background, as long as the app has a database connection configured (DATABASE_URL). Smaller imports run while you wait.
For a background import, the import screen shows a progress bar ("Applying import… 40%") and a message when it finishes or fails. The message that names lists left out of a JSON file appears as soon as the import starts. The background worker has to be running. Without it, the import stays queued and does not progress; it starts when the worker is running again. See Setup and deploy.
If an attempt fails partway, Lingo runs the import again after a short wait, up to three attempts in all. The import is reported as failed only when the last attempt has failed; until then the screen keeps showing progress, which may start again from a lower number. An import that was running when the worker stopped is started again once the worker is back, but no sooner than about 15 minutes after the interrupted attempt began. Running an import again is safe: values that were already written are left as they are.
What does not round-trip
Some details are lost when a file goes in and comes out.
- Plurals between ICU and gettext. Plural forms follow the target language's rules for common languages: English, major European languages, Russian, Ukrainian, Polish, Czech, Slovak, Arabic, and Chinese, Japanese and Korean. Other languages fall back to
oneandother. In a.poround trip the plural argument is renamed tocount, and complex nested arguments inside a plural branch are not kept. - XLIFF. Leading and trailing spaces in a value are trimmed. Only one
<file>per document and flat units are read. Groups and inline markup are not supported. - CSV. Only
key,value, and optionallysourceandnoteare read. Other columns are dropped. - JSON. A list is not imported (see JSON values that are not text). A list that you rewrote as numbered keys comes back from a nested JSON export as an object with the keys
0,1and so on, not as a list. Numbers,trueandfalsecome back as text in quotes. In nested JSON, a literal.in a key is read as nesting; flat JSON keeps it as written. - Namespaces. An export puts the namespace path in front of each key, and import does not remove it. If you import an exported file back into its namespace, the keys do not match the existing ones: the preview shows them as New, and applying creates new keys with the path repeated. Remove the namespace prefix from the keys before you re-import. Keys exported from the root namespace have no prefix, so they round-trip as they are.