- Notifications
You must be signed in to change notification settings - Fork23
🚀 Extract POT from react-intl and convert back to json.
License
evenchange4/react-intl-po
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Extract POT from react-intl and convert back to json.
messages.json → POT → PO → translation.json
Please take a look at standalone repo based on Create-React-App:https://github.com/evenchange4/react-intl-po-example
$ yarn add react-intl-po
- react-intl
^2.0.0 - babel-plugin-react-intl
^2.0.0
There are two sub-commands ofreact-intl-po orrip:
- json2pot: Convert the json files extracted frombabel-plugin-react-intl into one
.potfile. - po2json: Convert translated.po files back to
.jsonformat.
$ rip json2pot'_translations/src/**/*.json' \ -o ./mcs-public.pot| Arguments | Description |
|---|---|
srcPatterns | The pattern of.json files extracted frombabel-plugin-react-intl |
-o, --output <path> | The output pathname of.pot file to be translated |
-k, --message-key [key] | [Optional] Translation message key (default key isdefaultMessage) |
-c, --message-context [context] | [Optional] Translation message context (defaults to no context) |
$ 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 |
-m, --messages-pattern <path> | The pattern of.json files extracted frombabel-plugin-react-intl |
-o, --output <path> | The output pathname of a file / directory |
-k, --message-key [key] | [Optional] Translation message key (default key isdefaultMessage) |
-c, --message-context [context] | [Optional] Translation message context (defaults to no context) |
-l, --lang-mapper-pattern <pattern> | [Optional] Custom regex to use for lang mapping.PR#122 |
-i, --lang-mapper-pattern-index [index] | [Optional] When specifying a custom lang-mapper-pattern, the index of match to use for the lang mapping. Default is 1, index is ignored if not using a custom lang mapping regex.PR#122 |
--indentation <number|char> | [Optional] Specify a number of spaces or a set of characters to be used before each entry of the resulting json file. Defaults tonull, which means the entries are not prefixed with spaces. |
--sort-by-id | [Optional] If specified, the entries of each language are sorted by id before being output |
Set themessage-context (-c) to'id' of message object frombabel-plugin-react-intl (there is no context by default).
The advantage of this option over Option 2 (below) is that PO file editors that provide features such as translation suggestions or error-checking often expect the message key to bedefaultMessage.
$ rip po2json'./node_modules/mcs-translation/po/mcs-public*.po' \ -m'./_translations/src/**/*.json' \ -o'./translations' \ -c'id'$ rip po2json'./node_modules/mcs-translation/po/mcs-public*.po'\` -m'./_translations/src/**/*.json' \ -o'./translations.json' \ -c'id'
Example:https://github.com/evenchange4/react-intl-po-example#option
Set themessage-key (-k) to'id' of message object frombabel-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'
$ yarn install --pure-lockfile
You can useR.tap() for developing.
R.pipe( R.concat(...),+ R.tap(e => console.log(e)), R.mergeAll,);- node >= 9.11.1
- yarn >= 1.5.1
$ yarn run format$ yarn run eslint$ yarn run test:watch
Any git tags.
- Create a new git tag
- Update
CHANGELOG.md
$ npm version patch
- ⇄ 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 (
$ yarn run test).
About
🚀 Extract POT from react-intl and convert back to json.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.
