A console app and library to help you localise React apps in conjunction with react-intl
A console app and library to help you localise React apps in conjunction with
react-intl
Use riw to:
react-intl
message descriptors from your React components, directly or indirectly.react-intl
message descriptor ids if you need to.See Introducing riw on Medium for background and motivations.
There’s an example repository, riw-example
, showing a simple internationalised React app set up for use with riw.
The word “riw” seems to be Welsh for slope or hill, and rhymes with the English word drew.
This project is not associated with the react-intl
project.
riw assumes you’re familiar with react-intl
, and that your app already uses a build system of some kind (for example, webpack).
riw requires node 8.x or later.
riw doesn’t perform any automated text translation or interface with any translators or translation services. It tells you which messages need translating, lets you update its translations database with the translations once you have them, and produces shippable, react-intl
-compatible JSON files for each locale you want to support.
riw doesn’t provide its own mechanism for generating unique react-intl
message descriptor ids. However, by default riw uses babel-plugin-react-intl-auto
to autogenerate ids. (See the FAQ and https://github.com/akameco/babel-plugin-react-intl-auto for more.)
riw doesn’t import the generated JSON locale files into your app or plug them into react-intl
’s IntlProvider
. You implement this behaviour yourself.
$ yarn add --dev riw # OR: npm install --save-dev riw
Full tutorial: Installing, configuring and using riw
TL;DR:
package.json
:"riw": {
"defaultLocale": "en-US", // locale of source strings
"targetLocales": [ // other locales app should support
"fr-FR",
"pt-BR",
...
],
}
yarn run riw db init
– initialise empty db at src/locale/riw-db.json
yarn run riw app translate
– outputs src/locale/[locale].json
and src/locale/TODO-untranslated.json
(you might need to add a .babelrc
in your app)src/locale/[locale].json
for each target locale, and plug them into react-intl
’s IntlProvider
at the appropriate time.TODO-untranslated.json
file. Meanwhile, keep developing your app in the usual way.yarn run riw db import TODO-with-translations.json
if you have a file of them in the right format, oryarn run riw db update <opts...>
to update the db string by string.yarn run riw app translate
Check everything into source control. There are no temporary files.
David Smith (@avaragado)
Bug reports, feature requests and PRs are gratefully received. Add an issue or submit a PR.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
MIT © David Smith