JSON - SimpleLocalize

Last updated: October 16, 2024Author: Jakub Pomykała
simplelocalize-json
File format value
simplelocalize-json

SimpleLocalize JSON is a universal format that can be used to import and export translations from different localization programs. It works well with FormatJS CLI and can be used to import translations from different localization programs. Learn more about integrating FormatJS with SimpleLocalize.

File format example

Here is an example of a SimpleLocalize JSON file:

{
  "translation_key": {
    "message": "my localized message"
  },
  "second_translation_key": {
    "defaultMessage": "my localized message from FormatJS CLI output",
    "description": "Your message to translators. It will also show up in the translation editor"
  },
  "translation_key_with_pluralization": {
    "message": "You have {itemCount, plural, =0 {no items} one {1 item} other {{itemCount} items}}."
  }
}

Import default messages

If you want to import messages into SimpleLocalize using CLI, you need to pass a language key as an argument. The language key is used to determine the language of the imported messages. See an example CLI command below:

simplelocalize upload --apiKey <PROJECT_KEY> \
  --uploadFormat simplelocalize-json \
  --uploadPath ./extracted.json \
  --languageKey en

Add --overwrite argument to update the existing translations, otherwise, only new ones will be added.

Import descriptions

By default, CLI imports descriptions as Code Descriptions. Use --uploadOptions UPDATE_DESCRIPTIONS parameter to push values from 'description' fields as translator descriptions. See an example CLI command below:

simplelocalize upload --apiKey <PROJECT_KEY> \
  --uploadFormat simplelocalize-json \
  --uploadPath ./extracted.json \
  --languageKey en

Code descriptions differ from the descriptions in the translation editor. They are used to provide additional context for translators from the code perspective, and they cannot be edited or cleared in the translation editor. They are updated only by uploading new translations via CLI.

Learn more about uploading translations with CLI.

Resources

Was this helpful?