Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18next-scanner

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-scanner - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

54

lib/parser.js

@@ -53,7 +53,21 @@ var fs = require('fs');

_.defaults(this.options, defaults);
options = this.options;
var resStore = this.resStore = {};
var fn = this.fn = {
getResourcePath: function(lng, ns) {
var options = that.options;
var regex = {
'lng': new RegExp(_.escapeRegExp(options.interpolationPrefix + 'lng' + options.interpolationSuffix), 'g'),
'ns': new RegExp(_.escapeRegExp(options.interpolationPrefix + 'ns' + options.interpolationSuffix), 'g')
};
return options.resGetPath
.replace(regex.lng, lng)
.replace(regex.ns, ns);
},
debuglog: function() {
var debug = !!that.options.debug;
if (debug) {
var options = that.options;
if (!!options.debug) {
var args = Array.prototype.slice.call(arguments, 0);

@@ -65,6 +79,2 @@ console.log.apply(this, args);

_.defaults(this.options, defaults);
options = this.options;
if (_.isString(options.ns)) {

@@ -90,9 +100,3 @@ options.ns = {

_.each(options.ns.namespaces, function(ns) {
var regex = {
'lng': new RegExp(_.escapeRegExp(options.interpolationPrefix + 'lng' + options.interpolationSuffix), 'g'),
'ns': new RegExp(_.escapeRegExp(options.interpolationPrefix + 'ns' + options.interpolationSuffix), 'g')
};
var resPath = options.resGetPath
.replace(regex.lng, lng)
.replace(regex.ns, ns);
var resPath = fn.getResourcePath(lng, ns);

@@ -113,6 +117,6 @@ resStore[lng][ns] = {};

fn.debuglog({
options: options,
resStore: resStore
});
fn.debuglog('parser initialization:', JSON.stringify({
'options': options,
'resStore': resStore
}, null, 2));
};

@@ -150,6 +154,11 @@

if ( ! _.isUndefined(value)) {
// Reuse the key existed in the resStore
// Found a value associated with the key
lookupKey = '[' + lng + '][' + ns + '][' + keys.join('][') + ']';
fn.debuglog('[v] resStore' + lookupKey + '="' + map(resStore, lookupKey) + '"');
fn.debuglog('Found a value %s associated with the key %s in %s.',
JSON.stringify(map(resStore, lookupKey)),
JSON.stringify(keys.join(options.keyseparator)),
JSON.stringify(fn.getResourcePath(lng, ns))
);
} else if (_.isObject(resStore[lng][ns])) {
// Adding a new entry
var res = resStore[lng][ns];

@@ -165,5 +174,8 @@ _.each(keys, function(elem, index) {

// Add new key to the resStore
lookupKey = '[' + lng + '][' + ns + '][' + keys.join('][') + ']';
fn.debuglog('[+] resStore' + lookupKey + '="' + map(resStore, lookupKey) + '"');
fn.debuglog('Adding a new entry {%s:%s} to %s.',
JSON.stringify(keys.join(options.keyseparator)),
JSON.stringify(map(resStore, lookupKey)),
JSON.stringify(fn.getResourcePath(lng, ns))
);
} else { // skip the namespace that is not defined in the i18next options

@@ -170,0 +182,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.4.1",
"version": "0.5.0",
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc