po-extract

1.1.2 • Public • Published

po-extract

NPM version CI workflow

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

  1. Add scripts to package.json:
"scripts": {
  + "po:build": "po-extract",
  + "po:watch": "po-extract --watch",
  1. Create .po-files (example). By default, the library looks for the directory dictionaries in the root of the project, you can change it, see CLI Options.

  2. 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.

  3. 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

Package Sidebar

Install

npm i po-extract

Weekly Downloads

295

Version

1.1.2

License

MIT

Unpacked Size

13.4 kB

Total Files

15

Last publish

Collaborators

  • neruchev