xgettext-regex

0.3.0 • Public • Published

xgettext-regex Build Status Dependency Status

Minimum viable xgettext .pot file generator. Uses a configurable regex to get translation keys.

Examples

cat foo.js | xgettext-regex # Output to stdout 
xgettext-regex foo.js -o foo.po # Output to foo.po 
xgettext-regex app-dir -o app.po # Recursive read directory 
var fs = require('fs')
var xgettext = require('xgettext-regex')
 
var src = '/path/to/file'
var dest = '/path/to/en-GB.po'
var opts = {}
 
fs.createReadStream(src)
  .pipe(xgettext(src, opts))
  .pipe(fs.createWriteStream(dest))
var fs = require('fs')
var xgettext = require('xgettext-regex')
 
var files = ['/path/to/file.js', '/path/to/html/dir']
var opts = {}
 
xgettext.createReadStream(files, opts))
  .pipe(fs.createWriteStream('/path/to/en-GB.po'))

Options

opts = {
    /* i18n function name */
    fn: '_',
    /* The regex used to match i18n function calls */
    regex: /_\(((["'])(?:(?=(\\?))\3.)*?\2)\)/g,
    /* Capture index for the i18n text in the above regex */
    regexTextCaptureIndex: 1,
    /* readdirp filters etc. */
    readdirp: {
      fileFilter: ['!.*', '!*.png', '!*.jpg', '!*.gif', , '!*.zip', , '!*.gz'],
      directoryFilter: ['!.*', '!node_modules', '!coverage']
    }
}

Package Sidebar

Install

npm i xgettext-regex

Weekly Downloads

18

Version

0.3.0

License

ISC

Unpacked Size

11.5 kB

Total Files

12

Last publish

Collaborators

  • alanshaw