Extract gettext strings from Javascript source code, but more better than existing extractors
Install with npm.
npm install --save xgettext-js-more-better
var xgettext = require('xgettext-js-more-better');
xgettext('gettext("Hi")', {/* gettext options */}, {/* acorn options */});
xgettext-js-more-better
exports a single function, extract
, that takes
the following parameters:
A string of Javascript containing translatable to extract
Optional object containing options used by xgettext-js-more-better
.
These options are passed to gettext-catalog.
The most important option passed here is filename
, which is used for
generating references.
For example,
xgettext('gettext("Hi")', {filename: 'foo.js'});
Optional object containing options passed to espree (by way of falafel-espree). Use this to customize Javascript parsing behavior. For example, to customize supported ES6 features:
xgettext('let foo = gettext("Hi")', {}, { ecmaFeatures: { arrowFunctions: true } });
MIT