Socket
Socket
Sign inDemoInstall

i18next-scanner

Package Overview
Dependencies
5
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.5.0

test/fixtures/namespace.js

6

lib/parser.js

@@ -172,3 +172,2 @@ 'use strict';

// The resStore stores all translation keys including unused ones
function Parser(options) {

@@ -313,3 +312,3 @@ var _this = this;

// http://i18next.com/docs/options/
var supportedOptions = ['defaultValue', 'count', 'context'];
var supportedOptions = ['defaultValue', 'count', 'context', 'ns'];

@@ -490,2 +489,3 @@ props.forEach(function (prop) {

// @param {string} [options.context] used for contexts (eg. male)
// @param {string} [options.ns] namespace for the translation
// @param {string|boolean} [options.nsSeparator] The value used to override this.options.nsSeparator

@@ -512,3 +512,3 @@ // @param {string|boolean} [options.keySeparator] The value used to override this.options.keySeparator

var ns = this.options.defaultNs;
var ns = options.ns || this.options.defaultNs;

@@ -515,0 +515,0 @@ console.assert(_lodash2.default.isString(ns) && !!ns.length, 'ns is not a valid string', ns);

{
"name": "i18next-scanner",
"version": "1.4.1",
"version": "1.5.0",
"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",

# 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)
[![NPM](https://nodei.co/npm/i18next-scanner.png?downloads=true&stars=true)](https://nodei.co/npm/i18next-scanner/)
[![NPM](https://nodei.co/npm/i18next-scanner.png?downloads=true&stars=true)](https://www.npmjs.com/package/i18next-scanner)

@@ -68,2 +68,3 @@ Scan your code, extract translation keys/values, and merge them into i18n resource files.

var vfs = require('vinyl-fs');
var sort = require('gulp-sort');
var options = {

@@ -73,2 +74,3 @@ // See options at https://github.com/i18next/i18next-scanner#options

vfs.src(['/path/to/src'])
.pipe(sort()) // Sort files in stream by path
.pipe(scanner(options))

@@ -81,2 +83,3 @@ .pipe(vfs.dest('/path/to/dest'));

vfs.src(['/path/to/src'])
.pipe(sort()) // Sort files in stream by path
.pipe(scanner.createStream(options))

@@ -90,2 +93,3 @@ .pipe(vfs.dest('/path/to/dest'));

var gulp = require('gulp');
var sort = require('gulp-sort');
var scanner = require('i18next-scanner');

@@ -95,2 +99,3 @@

return gulp.src(['src/**/*.{js,html}'])
.pipe(sort()) // Sort files in stream by path
.pipe(scanner({

@@ -97,0 +102,0 @@ lngs: ['en', 'de'], // supported languages

@@ -149,3 +149,3 @@ /* eslint no-console: 0 */

options = _.assign({}, defaults);
// The resStore stores all translation keys including unused ones

@@ -273,3 +273,4 @@ resStore = {};

'count',
'context'
'context',
'ns'
];

@@ -435,2 +436,3 @@

// @param {string} [options.context] used for contexts (eg. male)
// @param {string} [options.ns] namespace for the translation
// @param {string|boolean} [options.nsSeparator] The value used to override this.options.nsSeparator

@@ -450,3 +452,3 @@ // @param {string|boolean} [options.keySeparator] The value used to override this.options.keySeparator

let ns = this.options.defaultNs;
let ns = options.ns || this.options.defaultNs;

@@ -453,0 +455,0 @@ console.assert(_.isString(ns) && !!ns.length, 'ns is not a valid string', ns);

@@ -330,2 +330,19 @@ import fs from 'fs';

test('Namespace', (t) => {
const parser = new Parser({
ns: ['translation', 'othernamespace']
});
const content = fs.readFileSync(path.resolve(__dirname, 'fixtures/namespace.js'), 'utf-8');
parser.parseFuncFromString(content);
t.same(parser.get(), {
en: {
othernamespace: {
"friend": ""
},
translation: {}
}
});
t.end();
})
test('Context', (t) => {

@@ -332,0 +349,0 @@ const parser = new Parser();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc