po-extract
v2.1.9
Published
A CLI tool for creating `react-intl`-compatible dictionaries from gettext `.po`-files
Downloads
915
Maintainers
Readme
po-extract
A CLI tool for creating react-intl-compatible dictionaries from gettext .po
-files.
What for? Many translators and software translation companies prefer to work with standardized dictionaries in the .po
format, while developers are more comfortable working with language strings in a JavaScript or TypeScript compatible format.
Pre requirements
node.js
:>=8.*
Installation
Install it with yarn:
yarn add po-extract --dev
Or with npm:
npm install po-extract --save-dev
Usage
- Add
scripts
topackage.json
:
"scripts": {
+ "po:build": "po-extract",
+ "po:watch": "po-extract --watch",
Create
.po
-files (example). By default, the library looks for the directorydictionaries
in the root of the project, you can change it, see CLI Options.Create target directory. By default, the library uses the
src/dictionaries
directory in the root of the project, you can change it, see CLI Options.Run script to generate react-intl-compatible dictionaries:
yarn run po:build
Or with npm:
npm po:build
See full example.
CLI Options
| Option | Type | Default | Description |
| ------------- | ------- | -------------------- | ------------------------------------- |
| --fixPo
| boolean | false
| Fix translations order in .po
files |
| --outDir
| string | ./src/dictionaries
| Save output to the directory |
| --outExt
| string | .js
| Output files extensions |
| --targetDir
| string | ./dictionaries
| Target directory with .po
files |
| --watch
| boolean | false
| Run the extractor in watch mode |
License
MIT