babel-gettext-plugin

3.0.0 • Public • Published

babel-gettext-plugin

Extract gettext string with babel support syntax JSX, ES6, ... It is based on node-gettext.

Installation

npm install babel-gettext-plugin

Support version node 6 and Babel 7. (Tested version)

Node use

var babel = require("babel");
 
babel.transform(code, {
                plugins: ["babel-gettext-plugin"]
            });

Command line use

babel --plugins babel-gettext-plugin code.js

Options

You can pass options as extra in babel options :

plugins: [
    ["babel-gettext-plugin", {
        headers: <Object>,
        functionNames: <Object>,
        fileName: <String>,
        defaultTranslate: <Boolean>
    }]
]

headers

The headers to put in the po file.

headers: {
    "content-type": "text/plain; charset=UTF-8",
    "plural-forms": "nplurals=2; plural=(n!=1);"
}

functionNames

All function names to be extract. You have to precise where found the parameters ("domain", "msgctxt", "msgid", "msgid_plural" and "count") to be extract.

example:

functionNames: {
        myfunction: ["msgid"]
    }

fileName

The file name where found all extracted strings.

defaultTranslate

Add in msgstr the value of msgid, if the defaultTranslate is true.

License

MIT License.

Dependents (0)

Package Sidebar

Install

npm i babel-gettext-plugin

Weekly Downloads

461

Version

3.0.0

License

MIT

Unpacked Size

16 kB

Total Files

6

Last publish

Collaborators

  • jruchaud
  • smaisonneuve