React-Setup uses React-Intl for internationalization.
Each component has a messages.js
file which contains i18n strings to use in the component.
Running $ npm run build-msg
will invoke babel-plugin-react-intl to go through all messages.js
files and generate messages.json
files under /dist
.
/server/libs/i18n.js
has a helper function called getLocaleMessages
which returns an object with all translated strings from messages.json
files.
This object then gets injected to the index page (see: index-page.js
) as a global variable so components can use them at runtime.