Package Exports
- riw
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (riw) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
riw
riw ("react-intl workflow") is a set of command-line tools and a library to help you work with react-intl in a React app. Use it to:
- Define target locales for your app: the locales into which you translate the app.
- Extract
react-intlmessage descriptors from your React components, directly or indirectly. - Check for duplicates in your
react-intlmessage descriptor ids. - Manage translations for each target locale.
- Generate JSON files for your translations, to include in your app.
This project is not associated with the react-intl project.
The word "riw" seems to be Welsh for slope or hill, and rhymes with the English word "drew".
There's an example repository, riw-example, showing (in its commit history) how to migrate a simple React app with hard-coded strings to react-intl, and then how to use riw with it.
Which problems doesn't riw solve?
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 a mechanism for generating unique
react-intlmessage descriptor ids. How you define these depends on your app's requirements. However, it does let you identify any duplicate ids. (See the FAQ for a possible naming scheme.)riw doesn't import the generated JSON locale files into your app or plug them into
react-intl'sIntlProvider. You implement this behaviour yourself.
Assumptions
riw assumes you're familiar with react-intl, and that your app already uses a build system of some kind (for example, webpack).
TL;DR
yarn add --dev riw- Add to
package.json:"riw": { "defaultLocale": "en-US", // locale of the source strings "targetLocales": ["fr-FR", "pt-BR", ...], // other locales the app should support } yarn run riw db init– initialise empty db atsrc/locale/riw-db.jsonyarn run riw app translate– outputssrc/locale/[locale].jsonandsrc/locale/TODO-untranslated.json(might need to add a.babelrcin your app)- Update your app to import strings from
src/locale/[locale].jsonfor each target locale, and plug them intoreact-intl'sIntlProviderat the appropriate time. - LOOP:
- Translate everything in the
TODO-untranslated.jsonfile. Meanwhile, keep developing your app in the usual way. yarn run riw db import TODO-with-translations.jsonif 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- Go to LOOP.
Check everything into source control. There are no temporary files.