Extract POT from react-intl and convert back to json.
messages.json → POT → PO → translation.json
$ npm install react-intl-po --save
- react-intl
^2.0.0
- babel-plugin-react-intl
^2.0.0
There are two sub-commands of react-intl-po
or rip
:
- json2pot: Convert the json files extracted from babel-plugin-react-intl into one
.pot
file. - po2json: Convert translated .po files back to
.json
format.
$ rip json2pot '_translations/src/**/*.json' \
-o ./mcs-public.pot
Arguments | Description |
---|---|
srcPatterns |
The pattern of .json files extracted from babel-plugin-react-intl |
output (-o) |
The output pathname of .pot file to be translated |
message-key (-k) |
[Optional] Translation message key (default key is defaultMessage ) |
$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \
-m './_translations/src/**/*.json' \
-o './translations'
$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \`
-m './_translations/src/**/*.json' \
-o './translations.json'
Arguments | Description |
---|---|
srcPatterns |
The pattern of translated .po files |
messagesPattern (-m) |
The pattern of .json files extracted from babel-plugin-react-intl |
output (-o) |
The output pathname of a file / directory |
message-key (-k) |
[Optional] Translation message key (default key is defaultMessage ) |
Set the message-key (-k)
to 'id'
of message object from babel-plugin-react-intl (default key is 'defaultMessage'
). (#41)
$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \
-m './_translations/src/**/*.json' \
-o './translations' \
-k 'id'
$ rip po2json './node_modules/mcs-translation/po/mcs-public*.po' \`
-m './_translations/src/**/*.json' \
-o './translations.json' \
-k 'id'
$ npm run lint
$ npm run test:watch
- ⇄ Pull requests and ★ Stars are always welcome.
- For bugs and feature requests, please create an issue.
- Pull requests must be accompanied by passing automated tests (
$ npm test
).