Skip to content

Extract your messages defined in your React app and auto merge existing translations for defined locales.

Notifications You must be signed in to change notification settings

alexandretrichot/formatjs-message-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

formatjs-message-extractor

Extract your messages defined in your React app and auto merge existing translations for defined locales.

Install

First, add this package as development dependency :

$ yarn add -D formatjs-message-extractor

Then, add this following line in "scripts" in your package.json file.

"intl": "formatjs-message-extractor src/lang -l en,fr"

This will create a src/lang directory with a json file for each locale specified by the -l option.

src/lang
├── en.json
└── fr.json

Later, when you have added other messages in your code, this same command will add the missing keys in the existing files and will delete the keys of the messages that no longer exist in your code.

Options

A few options are available :

-l, --locales

This allows you to choose the languages to be translated.

For example, the command:

$ formatjs-message-extractor src/lang -l en,de,it

will create three locales files: en.json, de.json and it.json.

-d, --defaultLocale

This define the locale used in default messages in your code.

By default this is set on en.