xgettext-regex
Minimum viable xgettext .po file generator. Uses a configurable regex to get translation keys.
Last updated a month ago by alanshaw .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install xgettext-regex 
SYNC missed versions from official npm registry.

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']
    }
}

Current Tags

  • 0.3.0                                ...           latest (a month ago)

4 Versions

  • 0.3.0                                ...           a month ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 28
Dependencies (7)
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |