Extract gettext string with babel support syntax JSX, ES6, ... It is based on node-gettext.
npm install babel-gettext-plugin
Support version node 6 and Babel 7. (Tested version)
var babel = require("babel");
babel.transform(code, {
plugins: ["babel-gettext-plugin"]
});
babel --plugins babel-gettext-plugin code.js
You can pass options as extra in babel options :
plugins: [
["babel-gettext-plugin", {
headers: <Object>,
functionNames: <Object>,
fileName: <String>,
defaultTranslate: <Boolean>
}]
]
The headers to put in the po file.
headers: {
"content-type": "text/plain; charset=UTF-8",
"plural-forms": "nplurals=2; plural=(n!=1);"
}
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"]
}
The file name where found all extracted strings.
Add in msgstr the value of msgid, if the defaultTranslate is true.