xgettext-js-more-better
v0.0.6
Published
Extract gettext strings from Javascript source code
Downloads
153
Maintainers
Readme
xgettext-js-more-better
Extract gettext strings from Javascript source code, but more better than existing extractors
Install
Install with npm.
npm install --save xgettext-js-more-better
Example
var xgettext = require('xgettext-js-more-better');
xgettext('gettext("Hi")', {/* gettext options */}, {/* acorn options */});
API
xgettext-js-more-better
exports a single function, extract
, that takes
the following parameters:
source
A string of Javascript containing translatable to extract
gettextOptions
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'});
espreeOptions
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 } });
License
MIT