Import New Content in Multiple Languages

This article explains how to import new documents in multi-languages in your Prismic repository.


Let's say you have a repository with a Custom Type blog_post that has UID, Title, and Key text fields.
There are two languages: "en-gb" and "fr-fr" where "en-gb" is the default language.

To import new documents in multiple languages you need to prepare your JSON file in the alternate languages that you'll import.

First, create the files with this naming convention new_{groupid}_{lang}, here groupid is an arbitrary identifier that will be used to match a new document with its translations. Don't use underscore characters for groupid or else the import will fail.

In this case, filenames should look like:

  • new_myimports_en-gb
  • new_myimports_fr-fr

Then, add the corresponding fields in the Custom Type JSON and lang for each one. Please follow the Import JSON reference guide to prepare the JSON file for the import.

Here is an example of the new_myimports_en-gb.json file:

Make sure before importing a set of the localized documents, the corresponding languages/locales are available in your repository. The value of "lang" in JSON must be similar to the language/locale code in your repository.

Copy
{ 
  "uid": "post",
  "post_title": [
    { "type": "heading1", "content": { "text": "New blog in english", "spans": [] } }
  ],
  "key_text": "This is my Key text in English",
  "type": "blog_post",
  "tags": [],
  "lang": "en-gb"
}

Here is an example of the new_myimports_fr-fr.json file:

Copy
{ 
  "uid": "post",
  "post_title": [
    { "type": "heading1", "content": { "text": "New blog in french", "spans": [] } }
  ],
  "key_text": "This is my Key text in french",
  "type": "blog_post",
  "tags": [],
  "lang": "fr-fr"
}

Was this article helpful?
Not really
Yes, Thanks

Can't find what you're looking for? Get in touch with us on our Community Forum.