This guide is intended for unix based OS, the script provided won't work on Windows terminal. If you'd like to contribute to improve and complete this guide, please write to us on the chat.

You can use the Import module to copy documents from a locale to another. Let's take the example where you want to duplicate all documents of the locale "en-us" into the "fr-fr" locale.

The Export module lets you download JSON files for your published document. The Import module allows you to import translations for existing documents. To achieve this, you need to import JSON files with this naming convention: tranlate_{grouplang}_{target_locale}.json

Plus the JSON files need to hold the target locale code, i.e., "lang":"fr-fr"

The example below will help you bulk duplicate documents from a locale to another by:

  • quickly isolating the exported JSON documents for the source locale (i.e., en-us)
  • bulk changing the value of the lang property (basically bulk editing the JSON file to replace "lang":"en-us" with "lang":"fr-fr")
  • renaming JSON files in bulk with the expected file naming convention, so it can be imported as translations of existing documents

Going back to our example, to duplicate all documents of the locale "en-us" into the "fr-fr" locale:

1. First thing if not done yet, create the "fr-fr" locale from the settings of your repository

2. Head to the settings, export your repository content: you will get a ZIP archive containing a JSON file for each published documents in your repository

3. If you already have content in multiple languages in your repository, you might want to isolate the JSON files of the main locale (in our example, say "en-us"). As you cannot filter while exporting from the Prismic UI, you'll have to run this simple command locally to isolate "en-us" document into a specific folder

4. Install "json" (a CLI tool to work with JSON):
npm install -g json

5. Create a file with this script in the local folder where the JSON files you want to copy are stored, call it

sed -i '' -e 's/"lang":"en-us"/"lang":"fr-fr"/g' *.json
for filename in ./*.json; do
grouplang=$(json -f $filename grouplang)
mv "$filename" "$prefix$grouplang$targetlocale$filetype"

5. Allow execution of this script chmod +x

6. Run the script: ./

Your files should be renamed and look like this: translate_XvN5jxAAACEANAzk_fr-fr.json

7. Select all the files and compress them into a ZIP archive

8. Head to the Import section of your repository, upload that archive, launch the import

Imported documents are always staged into an import release. This helps you check the correctness of the import before publishing the release (have a careful check as you can not rollback the publication of a release).

Before publishing that release, check that the imported documents are correctly associated with the original version (just open some documents, and switch the language dropdown to verify it's associated with their corresponding "en-us" version)

To ease the translators workflow, they can work on the duplicated documents by directly by picking them in the Import release. Once they are done with the translation of one document, they can either publish it or move it into another release (for approval or preview for instance).

If you'd like to contribute to improve and complete this guide, please write to us on the chat.

Did this answer your question?