Socket
Socket
Sign inDemoInstall

i18next-scanner

Package Overview
Dependencies
Maintainers
1
Versions
92
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 2.3.0 to 2.3.1

lib/match-recursive-regexp.js

35

lib/parser.js

@@ -228,2 +228,9 @@ 'use strict';

var getStringFromAttribute = function getStringFromAttribute(attr) {
if (attr[0] === '"' || attr[1] === '\'') {
return attr.slice(1, -1);
}
throw new Error('attribute value must be a string');
};
/**

@@ -459,7 +466,20 @@ * Creates a new parser

var reTrans = new RegExp('<Trans([^]*?)>([^]*?)</\\s*Trans\\s*>', 'gim');
var reTransKey = new RegExp('[^]*i18nKey="([^"]+)"[^]*', 'im');
var reAttribute = /\b(\S+)\s*=\s*({.*?}|".*?"|'.*?')/gm;
var r = void 0;
while (r = reTrans.exec(content)) {
var transKey = (0, _ensureArray2.default)(String(r[1] || '').match(reTransKey))[1];
var attributes = {};
var ar = void 0;
while (ar = reAttribute.exec(r[1])) {
attributes[ar[1]] = ar[2];
}
var transKey = void 0;
try {
transKey = attributes.i18nKey ? getStringFromAttribute(attributes.i18nKey) : '';
} catch (e) {
this.log('i18next-scanner: i18nKey value must be a static string, saw ' + _chalk2.default.yellow(attributes.i18nKey));
continue;
}
var _key2 = _lodash2.default.trim(transKey || '');

@@ -471,2 +491,13 @@ var fragment = _lodash2.default.trim(r[2]).replace(/\s+/g, ' ');

};
if (attributes.count) {
_options.count = 1;
}
if (attributes.context) {
try {
_options.context = getStringFromAttribute(attributes.context);
} catch (e) {
this.log('i18next-scanner: Trans context attribute must be a string, saw ' + _chalk2.default.yellow(attributes.context));
continue;
}
}

@@ -473,0 +504,0 @@ if (customHandler) {

2

package.json
{
"name": "i18next-scanner",
"version": "2.3.0",
"version": "2.3.1",
"description": "Scan your code, extract translation keys/values, and merge them into i18n resource files.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/i18next/i18next-scanner",

@@ -125,3 +125,5 @@ # i18next-scanner [![build status](https://travis-ci.org/i18next/i18next-scanner.svg?branch=master)](https://travis-ci.org/i18next/i18next-scanner) [![Coverage Status](https://coveralls.io/repos/i18next/i18next-scanner/badge.svg?branch=master&service=github)](https://coveralls.io/github/i18next/i18next-scanner?branch=master)

loadPath: 'i18n/{{lng}}/{{ns}}.json',
savePath: 'i18n/{{lng}}/{{ns}}.json'
savePath: 'i18n/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n'
},

@@ -128,0 +130,0 @@ nsSeparator: false, // namespace separator

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