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

i18next-parser

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-parser - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

19

bin/cli.js

@@ -18,3 +18,3 @@ #!/usr/bin/env node

program
.version('0.7.0')
.version('0.8.0')
.option( '-r, --recursive' , 'Parse sub directories' )

@@ -61,3 +61,3 @@ .option( '-p, --parser <string>' , 'A custom regex to use to parse your code' )

if ( ! fs.existsSync(input) ) {
console.log( "\n" + "Error: ".red + input + " is not a file or directory\n" );
console.log( '\n' + 'Error: '.red + input + ' is not a file or directory\n' );
process.exit( 1 );

@@ -82,7 +82,7 @@ }

// ===============
var intro = "\n"+
"i18next Parser".yellow + "\n" +
"--------------".yellow + "\n" +
"Input: ".green + input + "\n" +
"Output: ".green + program.output + "\n\n";
var intro = '\n'+
'i18next Parser'.yellow + '\n' +
'--------------'.yellow + '\n' +
'Input: '.green + input + '\n' +
'Output: '.green + program.output + '\n\n';

@@ -129,2 +129,5 @@ console.log(intro);

var parser = Parser(program);
parser.on('error', function (message, region) {
console.log('[error] '.red + message + ': ' + region.trim());
});

@@ -147,3 +150,3 @@ stream

}))
.pipe(parser.on('reading', function(path) { console.log("[parse] ".green + path) }))
.pipe(parser.on('reading', function(path) { console.log('[parse] '.green + path) }))
.pipe(through( { objectMode: true }, function (file, encoding, done) {

@@ -150,0 +153,0 @@

# Changelog
## 0.7.0 - latest
## 0.8.0 - latest
- Throw an error when the translation function use a variable instead of a string
## 0.7.0
- Add --attributes option (cli & gulp)

@@ -6,0 +10,0 @@

@@ -120,4 +120,17 @@ var gutil = require('gulp-util');

// and we parse for functions with variables instead of string literals
// ====================================================================
var noStringLiteralPattern = '[^a-zA-Z0-9_]((?:'+fnPattern+')(?:\\(|\\s)\\s*(?:[^\'"`\)]+\\)))';
var matches = new RegExp( noStringLiteralPattern, 'g' ).exec( fileContent );
if (matches && matches.length) {
this.emit(
'error',
'i18next-parser does not support variables in translation functions, use a string literal',
matches[1]
);
}
// and we parse for attributes in html
// =============================================
// ===================================
const attributes = '(?:' + this.attributes.join('|') + ')';

@@ -124,0 +137,0 @@ var attributeWithValueRegex = new RegExp( '(?:\\s+' + attributes + '=")([^"]*)(?:")', 'gi' );

@@ -5,3 +5,3 @@ {

"name": "i18next-parser",
"version": "0.7.0",
"version": "0.8.0",
"bin": {

@@ -8,0 +8,0 @@ "i18next": "./bin/cli.js"

@@ -146,2 +146,6 @@ # i18next Parser

### Errors
- `i18next-parser does not support variables in translation functions, use a string literal`: i18next-parser can't parse keys if you use variables like `t(variable)`, you need to use strings like `t('string')`.
---

@@ -148,0 +152,0 @@

@@ -411,2 +411,18 @@ describe('parser', function () {

});
it('fails to parse translation function with a variable', function (done) {
var i18nextParser = Parser();
var fakeFile = new File({
contents: new Buffer("asd t(firstVar)\n")
});
i18nextParser.on('error', function (message, region) {
assert.equal( message, 'i18next-parser does not support variables in translation functions, use a string literal' );
assert.equal( region, 't(firstVar)' );
done();
});
i18nextParser.end(fakeFile);
});
});
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