i18next-scanner
Advanced tools
Comparing version 0.5.4 to 0.5.5
{ | ||
"name": "i18next-scanner", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "i18next-scanner is a transfrom stream that can scan your code, extract translation keys/values, and merge them into i18n resource files.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/cheton/i18next-scanner", |
@@ -5,3 +5,3 @@ # i18next-scanner [![build status](https://travis-ci.org/cheton/i18next-scanner.svg?branch=master)](https://travis-ci.org/cheton/i18next-scanner) | ||
i18next-scanner is a transfrom stream that can scan your code, extract translation keys/values, and merge them into i18n resource files. | ||
i18next-scanner is a transform stream that can scan your code, extract translation keys/values, and merge them into i18n resource files. | ||
@@ -30,3 +30,3 @@ It's available as both Gulp and Grunt plugins. | ||
.pipe(i18next()) | ||
.pipe(vfs.dest('path/to/dest'); | ||
.pipe(vfs.dest('path/to/dest')); | ||
``` | ||
@@ -52,3 +52,3 @@ | ||
resSetPath: 'i18n/__lng__/__ns__.json' | ||
}) | ||
})) | ||
.pipe(gulp.dest('assets')); | ||
@@ -105,3 +105,3 @@ }); | ||
```javascript | ||
i18n\._\(("[^"]*"|'[^']*')\s*[\,\)] | ||
i18n\._\(("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*[\,\)] | ||
``` | ||
@@ -119,6 +119,6 @@ | ||
(function() { | ||
var results = content.match(/i18n\._\(("[^"]*"|'[^']*')\s*[\,\)]/igm) || ''; | ||
var results = content.match(/i18n\._\(("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*[\,\)]/igm) || ''; | ||
_.each(results, function(result) { | ||
var key, value; | ||
var r = result.match(/i18n\._\(("[^"]*"|'[^']*')/); | ||
var r = result.match(/i18n\._\(("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*[\,\)]/) || ''; | ||
@@ -347,2 +347,4 @@ if (r) { | ||
```javascript | ||
var i18next = require('i18next-scanner'); | ||
var vfs = require('vinyl-fs'); | ||
var customTransform = function _transform(file, enc, done) { | ||
@@ -353,6 +355,9 @@ var parser = this.parser; | ||
// add custom code | ||
// add your code | ||
done(); | ||
}; | ||
vfs.src(['path/to/src']) | ||
.pipe(i18next(options, customTransform)) | ||
.pipe(vfs.dest('path/to/dest')); | ||
``` | ||
@@ -370,3 +375,2 @@ | ||
// parse the content and loop over the results | ||
_.each(results, function(result) { | ||
@@ -391,3 +395,2 @@ var key = result.key; | ||
// parse the content and loop over the results | ||
_.each(results, function(result) { | ||
@@ -406,2 +409,4 @@ var key = result.defaultKey || hash(result.value); | ||
var _ = require('lodash'); | ||
var i18next = require('i18next-scanner'); | ||
var vfs = require('vinyl-fs'); | ||
var customFlush = function _flush(done) { | ||
@@ -416,3 +421,3 @@ var that = this; | ||
_.each(namespaces, function(obj, ns) { | ||
// add custom code | ||
// add your code | ||
}); | ||
@@ -423,2 +428,6 @@ }); | ||
}; | ||
vfs.src(['path/to/src']) | ||
.pipe(i18next(options, customTransform, customFlush)) | ||
.pipe(vfs.dest('path/to/dest')); | ||
``` | ||
@@ -425,0 +434,0 @@ |
49055
428