Skip to content

Translations

Import each locale with its own template, and link every translated record to the entry it translates, so EmDash keeps them in one translation group.

A template imports into one locale. To import a site in English and French, you run two imports: the English records first, then the French ones, each with its own template. The French template names the column that holds the key of the English record each row translates. Flux Importer finds that English entry and creates the French entry as its translation.

  • i18n with at least two locales. Configure locales in Astro’s i18n settings, as EmDash’s internationalization guide explains. A template that links translations is refused without it (“translationOf needs i18n with at least two locales”), because EmDash only keeps shared values in sync across a translation group when i18n is on.
  • The original entries were imported by Flux Importer. The importer finds an original by its import key, the key of the record it was created from. Entries created by hand can’t be linked this way.
  • Import the original locale first. The originals must exist before the translations run, from an earlier, real import.
  1. On the Target step, choose the collection and the Locale of the records, for example fr.
  2. Check These records translate entries in and choose the Locale of the original entries, for example en. The checkbox appears only when the records’ locale isn’t the site’s default locale.
  3. On the Map step, drop the source key that holds each original’s key on the Translation of row.
  4. Map the translatable fields as usual, run the dry run, then import.

The same choice is the template’s translationOf mapping, next to key:

id,en_id,title,description
FR-1,SKU-1,Tasse bleue,<p>Une tasse en céramique.</p>
FR-2,SKU-2,Tasse rouge,<p>Une autre tasse.</p>
{
"version": 1,
"collection": "products",
"locale": "fr",
"key": { "from": "id" },
"translationOf": { "from": "en_id", "locale": "en" },
"fields": {
"title": { "from": "title", "type": "text" },
"body": { "from": "description", "type": "portableText", "format": "html" }
}
}

translationOf.locale is the locale of the originals. Left out, it’s the site’s default locale. It must differ from the template’s locale.

For each record with a translationOf value, Flux Importer looks for the entry imported with that key in the original locale and collection.

  • The original is found and the record has no entry yet: the entry is created with EmDash’s translationOf, so it joins the original’s translation group.
  • The original isn’t found and the record has no entry yet: the record fails with translation_source_not_found. It isn’t created on its own, because EmDash only links translations when it creates them. Import the original, then retry the failed records or run the import again.
  • The record’s entry exists and is already in the original’s group: it’s updated like any other entry. A re-run of the same data plans unchanged.
  • The record’s entry exists in another group (for example, an earlier run created it without a translationOf value): it’s updated, with a translation_not_linked warning. EmDash can’t move an entry into another group. To link it, move the entry to the trash, and the next run creates it as a translation.
  • The record’s entry exists but the original is gone: it’s updated, with a translation_source_not_found warning.
  • The original already has a translation in this locale that isn’t the record’s entry (an editor’s translation, say): the record fails with translation_exists. Flux Importer won’t take over an entry it didn’t create.

A record with an empty translationOf value is imported as an entry of its own, the first of a new group. If its existing entry is a translation, it fails with translation_of_missing: without a value, its shared fields would overwrite the whole group’s.

EmDash shares some values across a translation group: fields that aren’t translatable, taxonomy terms and reference fields. When a translated record names its original, Flux Importer skips those mappings for it. They aren’t read, converted or written, so a bad value in them can’t fail the record, and no term is created or file downloaded for them. EmDash copies non-translatable values from the original when it creates the translation, and keeps them in sync after.

The job warns once at creation when a template maps any of them, for example:

Records with a translationOf value leave these to EmDash, which shares them across the translation group: fields "sku", "price"; reference field "related"; taxonomy "category"

Written as usual for every record: translatable fields, the slug (slugs are per locale) and bylines (credits are per entry). EmDash doesn’t copy translatable values, so map every translatable field the translation needs.

A template without translationOf that maps a shared value can’t update an entry that is a translation: that record fails with translation_of_missing, because EmDash would sync the value to the whole group. Map translationOf, or drop the shared mappings.

  • A dry run can’t see another dry run. A dry run of the translations looks for originals that exist now. If the originals’ import was only a dry run, every record reports translation_source_not_found. Run the originals’ import for real first.
  • Publishing. EmDash creates a translation as a draft. With publishing on, Flux Importer publishes it like any other new entry. Each locale’s status is its own.
  • No fallback. Every lookup names one locale. A missing original is never taken from a fallback locale.
  • Terms in other locales. Terms and bylines are looked up in the template’s locale. See Taxonomies.

Record outcomes and warnings are listed in Job states and record outcomes.