- Use
<FormattedMessage id="newItem" defaultMessage="Add item" />
for adding text in your react components. - Use the babel plugin
babel-plugin-react-intl
to extract them from your source code. - Use
react-intl-webpack-plugin
to combine them into one message file calledreactIntlMessages.json
and put this file into the webpack output path. - Use CAT (Computer Aided Translation) tools (like the cloud based memsource.com or okapi) to translate this file into the translated file. These tools use a concept called Translation Memory (TM) . This is a separate file where all translations are stored and with this file all translations can be reapplied to a newly generated
reactIntlMessages.json
file. - Save the TM file and the translated json file in a separate directory of your source code.
- Use
reactIntlJson-loader
to load the translated files and convert them to messages.
npm install reactIntlJson-loader --save-dev
var messages_de = require("reactIntlJson!./translated-file-de.json");
// => returns content reformated as "id":"message"
If you have added the json-loader to your config, do not forget to exclude the directory where your translated files are
{test: /\.json$/, exclude:/src\/intl/, loader: "json-loader"}