CLI: Upload translations

Last updated: March 17, 2023Author: Jakub Pomykała

Upload existing translations or translation keys from your local project files. The uploaded translations and translations keys you can find in the translation editor.

Table of contents

Usage

Before you start, you need to install the CLI. Follow the CLI installation guide.

simplelocalize upload --apiKey <MY_API_KEY> ...

How to upload translation files with command-line tool

Additional parameters:

  • --overwrite allows you to replace existing translations with new ones.
  • --delete allows you to delete translations that are not present in uploaded files.
  • --dryRun allows you to check what translation files will be uploaded without actually uploading them.
  • --uploadOptions allows you to pass additional options to the upload command. Eg.: --uploadOptions TRIM_LEADING_TRAILING_SPACES. To pass multiple options, use comma as a separator.

Example: Upload translations from one file

.
└── locales
    └── english-translations.json
simplelocalize upload \
 --apiKey MY_API_KEY \
 --languageKey en \
 --uploadPath ./locales/english-translations.json \
 --uploadFormat single-language-json

Learn more about single-language-json.

Example: Upload translations from one file with all languages

.
└── locales
    └── all-translations.json
simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./locales/all-translations.json \
 --uploadFormat multi-language-json

Learn more about multi-language-json.

Example: Upload translations from multiple directories

.
├── ca
│   └── translations.json
├── en
│   └── translations.json
└── es
    └── translations.json
simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./{lang}/translations.json \
 --uploadFormat single-language-json

Example: Upload translations from multiple directories and files

.
├── ca
│   ├── common.json
│   └── home.json
├── en
│   ├── common.json
│   └── home.json
└── es
    ├── common.json
    └── home.json
simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./{lang}/{ns}.json \
 --uploadFormat single-language-json

See all available upload formats

Example: Upload customer translations

This option is only available with a Business plan.

.
└── locales
    └── ikea-translations.json
simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./locales/ikea-translations.json \
 --customerId ikea \
 --uploadFormat multi-language-json

Upload options

Many upload formats offer additional options. You can activate them using --uploadOptions parameter.

simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./translations.json \
 --uploadFormat multi-language-json \
 --uploadOptions UNESCAPE_NEW_LINES,PUBLISH_AFTER_IMPORT

See all available upload options

Override translations from file

If you want to override translations existing translations in translation editor you can use --overwrite option. This option won't clear translations that are not present in the file.

simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./translations.json \
 --uploadFormat multi-language-json \
 --overwrite

This option is useful when you want to update translations from a file for a given language, instead of managing them via the translation editor.

Delete translations that are not present in uploaded files

If you want to delete all other translations from the translation editor and keep only those from uploaded files you can use --delete option. Make sure you know what you are doing, you can create a backup of your project before using this option.

simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./translations.json \
 --uploadFormat multi-language-json \
 --delete

Check what translations will be uploaded

If you want to check what translations will be uploaded without actually uploading them you can use --dryRun option.

simplelocalize upload \
 --apiKey MY_API_KEY \
 --uploadPath ./translations/{ns}/{lang}.json \
 --uploadFormat single-language-json \
 --dryRun