outlinejs-babel-jsxgettext

0.4.2 • Public • Published

outlinejs-babel-jsxgettext

NPM version build status Downloads

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

I have a blog post explain my translation workflow in an Electron app with React + Babel.

Usage

$ npm install outlinejs-babel-jsxgettext --save-dev

API

var parser = require('outlinejs-babel-jsxgettext')
 
/**
 * The parser function
 * @param  {String}   input  The path to source JavaScript file
 * @param  {String}   output The path of the output PO file
 * @param  {Function} cb     The callback function
 */
parser(inputs, output, function (err) {
  if (err) throw err
  console.log('Job completed!')
})

Command line usage

Install globally with npm npm install outlinejs-babel-jsxgettext -g

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

  Options
    --help                     Show this help
    --version                  Current version of package
    -i | --input               String - The path to soure JavaScript file
    -o | --output              String - The path of the output PO file

  Usage
    $ outlinejs-babel-jsxgettext --help
    $ outlinejs-babel-jsxgettext <input> <output>

  Examples
    $ outlinejs-babel-jsxgettext ./test/*.js ./test.po

Why

I'm Using Babel with React + JSX for most of my project, but there's no perfect and direct way to generate .po file from ES6 + JSX code(or from a directory).

acron-jsx support jsx but not all the feature I use in Babel(ES7 etc.,). So I grab the babylon parser from Babel and use it to generate .po file.

License

MIT

Package Sidebar

Install

npm i outlinejs-babel-jsxgettext

Weekly Downloads

1

Version

0.4.2

License

MIT

Last publish

Collaborators

  • xpicio