i18next-scanner
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -5,3 +5,2 @@ var fs = require('fs'); | ||
var colors = require('colors'); | ||
var debuglog = require('debuglog'); | ||
var _ = require('lodash'); | ||
@@ -17,2 +16,5 @@ var map = require('./map'); | ||
var defaults = { | ||
// Debug output | ||
debug: false, | ||
// Provides a list of supported languages by setting the lngs option. | ||
@@ -48,7 +50,18 @@ lngs: ['en'], | ||
}; | ||
var resStore; | ||
var that = this; | ||
this.options = _.clone(options); | ||
this.resStore = resStore = {}; | ||
var resStore = this.resStore = {}; | ||
var fn = this.fn = { | ||
debuglog: function() { | ||
var debug = !!this.options.debug; | ||
if (debug) { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
console.log.apply(this, args); | ||
} | ||
} | ||
}; | ||
_.defaults(this.options, defaults); | ||
@@ -95,3 +108,3 @@ | ||
catch (err) { | ||
debuglog('Unable to load ' + JSON.stringify(resPath)); | ||
fn.debuglog('Unable to load ' + JSON.stringify(resPath)); | ||
} | ||
@@ -101,6 +114,6 @@ }); | ||
debuglog(JSON.stringify({ | ||
options: this.options, | ||
resStore: this.resStore | ||
})); | ||
fn.debuglog({ | ||
options: options, | ||
resStore: resStore | ||
}); | ||
}; | ||
@@ -114,2 +127,3 @@ | ||
Parser.prototype.parse = function(key, defaultValue) { | ||
var fn = this.fn; | ||
var options = this.options; | ||
@@ -140,3 +154,3 @@ var resStore = this.resStore; | ||
lookupKey = '[' + lng + '][' + ns + '][' + keys.join('][') + ']'; | ||
debuglog('[v] resStore' + lookupKey + '="' + map(resStore, lookupKey) + '"'); | ||
fn.debuglog('[v] resStore' + lookupKey + '="' + map(resStore, lookupKey) + '"'); | ||
} else if (_.isObject(resStore[lng][ns])) { | ||
@@ -155,3 +169,3 @@ var res = resStore[lng][ns]; | ||
lookupKey = '[' + lng + '][' + ns + '][' + keys.join('][') + ']'; | ||
debuglog('[+] resStore' + lookupKey + '="' + map(resStore, lookupKey) + '"'); | ||
fn.debuglog('[+] resStore' + lookupKey + '="' + map(resStore, lookupKey) + '"'); | ||
} else { // skip the namespace that is not defined in the i18next options | ||
@@ -158,0 +172,0 @@ var msg = 'Please ensure the namespace "' + ns + '" exists in the ns.namespaces[] of your ' + pkg.name + ' options: ' + JSON.stringify({ |
{ | ||
"name": "i18next-scanner", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "i18next-scanner is a transfrom stream that can scan your code, extract translation keys/values, and merge them into i18n resource files.", | ||
@@ -41,3 +41,2 @@ "homepage": "https://github.com/cheton/i18next-scanner", | ||
"colors": "^1.0.3", | ||
"debuglog": "^1.0.1", | ||
"i18next": "^1.7.10", | ||
@@ -44,0 +43,0 @@ "i18next-text": "^0.5.2", |
@@ -243,2 +243,8 @@ # i18next-scanner [![build status](https://travis-ci.org/cheton/i18next-scanner.svg?branch=master)](https://travis-ci.org/cheton/i18next-scanner) | ||
#### debug | ||
Type: `Boolean` Default: `false` | ||
Set to `true` to trun on debug output. | ||
#### lngs | ||
@@ -252,3 +258,3 @@ | ||
Type: `Boolean` Default: `false` | ||
Type: `Boolean` Default: `false` | ||
@@ -255,0 +261,0 @@ Set to `true` if you want to sort translation keys in ascending order. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47644
7
864
409
- Removeddebuglog@^1.0.1
- Removeddebuglog@1.0.1(transitive)