FormatJS CLI

📦 Upload translation keys to translation editor

FormatJS (formerly known also as react-intl) provide JavaScript CLI tool for extracting i18n keys. Check links below to learn how to integrate realtime translation changes in your web application.

Resources:

💿 Installation

Install Format JS CLI

# Using NPM
npm i -D @formatjs/cli

# Using yarn
yarn add -D @formatjs/cli

Install SimpleLocalize CLI

curl -s https://get.simplelocalize.io/install | bash

Problems with CLI? Checkout troubleshooting section.

👩‍💻 Configuration

Add the following command to your package.json scripts:

{
  "scripts": {
    "extract": "formatjs extract 'src/**/*.{ts,js,tsx,jsx}' --out-file lang.json",
    "upload-i18n": "simplelocalize upload --apiKey <PROJECT_API_KEY> --uploadPath ./lang.json --uploadFormat simplelocalize-json --languageKey en",
    "download-i18n": "simplelocalize download --apiKey <PROJECT_API_KEY> --downloadPath ./messages.json --downloadFormat multi-language-json"
  }
}

🚀 Usage

Use extract script to start FormatJS CLI extraction. It will save all translation keys in lang.json file.

$ npm run extract

Run upload-i18n script to upload found translation keys

$ npm run upload-i18n

Run download-i18n script to download ready to use JSON file with all translations.

$ npm run download-i18n

💭 Translate messages in editor

Your translation keys should showup in translation editor.

translation editor