Now that you've declared your messages, extracted them, sent them to your translation vendor and they have given you back the translated JSON of the same format, it's time to talk about how to distribute & consume the translated JSON.
Let's take the example from Message Extraction, assuming we are working with the French version and the file is called
We can use @formatjs/cli to compile this into a react-intl consumable JSON file:
Add the following command to your
and execute with
Parsing messages into AST
We recommending compiling your messages into AST as it allows us to skip parsing them during runtime. This makes your app more performant.
If your TMS/vendor has a different JSON format you can specify a custom formatter with
--format <formatFile> that converts that into
@formatjs/cli can understand. For example:
If your vendor accepts the format like
you can run
In the future we will provide formatters that work with popular TMSes by default.
While every application has a separate distribution pipeline, the common theme is the ability to map a locale to its translation file. In this example we'll assume your pipeline can understand dynamic