narp
A workflow utility to ease localization in JS(X) apps by automizing the following steps:
narp push
- Extraction of strings from source code (react-gettext-parser)
- Merging upstream and local translations in order to support translations in branches (pot-merge)
- Uploading POT resources to Transifex
narp pull
- Download PO translations from Transifex
- Converting PO to JSON (gettext-parser)
- Writing the JSON translations to where you want it
The JSON translations are formatted for node-gettext, so using this as the gettext frameform is a really good idea. :)
Installation
To use it easily, install narp globally with:
npm install -g narp
To use it in an automatization pipeline in your project, install it as a dev dependency:
npm install --save-dev narp
Usage
Using the CLI
narp -h
node push --password MY_TRANSIFEX_PASS
node pull --password MY_TRANSIFEX_PASS
--password
is also available as -p
.
Using the API
import { push, pull } from 'narp';
const configs = {
transifex: {
password: 'retrieve this somehow, don\'t check it in'
},
};
push(configs);
pull(configs);
Configuration in .narprc
.narprc
is narp's configuration file. There you specify configs for the different tasks that require so.
You only need to specify the configs that you want to overwrite.
The defaults are:
{
"transifex": {
"username": null,
"project": null,
"resource": null,
"sourceLang": "en"
},
"extract": {
"source": null,
"componentPropsMap": { },
"funcArgumentsMap": { }
},
"output": "messages.json"
}
Development
Creating builds
npm run build
npm run build -- --watch
Making it globally available while testing
cd path/to/narp && npm link
Releases
Follow semver when bumping the version number, commit it and run
npm publish