@vslutov/jsxgettext-stream

0.6.11 • Public • Published

@vslutov/jsxgettext-stream

NPM version build status Downloads js-standard-style

A tool like jsxgettext, but works for es6 + jsx that babel support.

Fork of fraserxu/babel-jsxgettext. Improvements:

  • Interface is compatible with gnu xgettext
  • Gulp stream support

Usage

$ npm install @vslutov/jsxgettext-stream --save-dev

Gulp usage

const xgettext = require("@vslutov/jsxgettext-stream")
const poConcat = require("gulp-po-concat")

gulp.task('i18n:pot', () =>
  gulp.src(['src/**/*.js', 'src/**/*.jsx'])
    .pipe(xgettext({plugins: ['flow', 'objectRestSpread']}))
    .pipe(poConcat({domain: 'messages'}))
    .pipe(gulp.dest('src/i18n'))
)

Program API

var parser = require('@vslutov/jsxgettext-stream/parser')

/**
 * The parser function
 * @param  {String}   input  The path to source JavaScript file
 * @param  {String}   plugins Babel parser plugins, separate by `,`
 * @param  {Function} cb     The callback function
 */
const main = async () {
  inputs = input_fnames.map(path => ({ path, contents: fs.readFileSync(path) }))
  const po_contents = await parser(inputs, [])
}

Command line usage

Install globally with npm npm install @vslutov/jsxgettext-stream -g

  A tool like jsxgettext, but works for es6 + jsx that babel support

  Options
    --help                     Show this help
    --version                  Current version of package
    -p | --plugins             String - Babel parser plugins list (`jsx` is always included)'
    -i | --input               String - The path to soure JavaScript file
    -o | --output              String - The path of the output PO file

  Usage
    $ jsxgettext-stream --help
    $ jsxgettext-stream <input> <output>

  Examples
    $ jsxgettext-stream ./test/*.js ./test.po
    $ jsxgettext-stream --plugins "classProperties,objectRestSpread" ./test/*.js test.po

License

MIT

Package Sidebar

Install

npm i @vslutov/jsxgettext-stream

Weekly Downloads

1

Version

0.6.11

License

MIT

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • vslutov