Skip to content

gabegorelick/xgettext-js-more-better

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Extract gettext strings from Javascript source code, more better

Resources

License

Stars

Watchers

Forks

Packages

No packages published