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 1.0.0-beta33 to 1.0.0-beta34

5

dist/helpers.js

@@ -12,3 +12,6 @@ 'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {return typeof obj;} : function (obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;};function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;} /**

var separator = options.separator || '.';
var newValue = entry.defaultValue || options.value || '';
var newValue = entry.defaultValue || entry.defaultValue || options.value || '';
if (options.useKeysAsDefaultValue) {
newValue = entry.key.substring(entry.key.indexOf('.') + 1, entry.key.length);
}

@@ -15,0 +18,0 @@ if (path.endsWith(separator)) {

4

dist/transform.js

@@ -35,2 +35,3 @@ 'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var _helpers = require('./helpers');

sort: false,
useKeysAsDefaultValue: false,
verbose: false };

@@ -114,3 +115,4 @@

separator: this.options.keySeparator,
value: this.options.defaultValue }),duplicate = _dotPathToHash.duplicate,conflict = _dotPathToHash.conflict;
value: this.options.defaultValue,
useKeysAsDefaultValue: this.options.useKeysAsDefaultValue }),duplicate = _dotPathToHash.duplicate,conflict = _dotPathToHash.conflict;

@@ -117,0 +119,0 @@

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

"name": "i18next-parser",
"version": "1.0.0-beta33",
"version": "1.0.0-beta34",
"license": "MIT",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

@@ -46,3 +46,3 @@ # i18next Parser [![Build Status](https://travis-ci.org/i18next/i18next-parser.svg?branch=master)](https://travis-ci.org/i18next/i18next-parser)

**IMPORTANT NOTE**: If you pass the globs as CLI argument, they must be relative to where you run the command (aka relative to `process.cwd()`). If you pass the globs via the `input` option of the config file, they must be relative to the config file.
**IMPORTANT NOTE**: If you pass the globs as CLI argument, they must be relative to where you run the command (aka relative to `process.cwd()`). If you pass the globs via the `input` option of the config file, they must be relative to the config file.

@@ -183,2 +183,6 @@ - **-c, --config <path>**: Path to the config file (default: i18next-parser.config.js).

useKeysAsDefaultValue: false,
// Whether to use the keys as the default value; ex. "Hello": "Hello", "World": "World"
// The option `defaultValue` will not work if this is set to true
verbose: false

@@ -185,0 +189,0 @@ // Display info about the parsing including some stats

@@ -12,3 +12,6 @@ /**

const separator = options.separator || '.'
const newValue = entry.defaultValue || options.value || ''
let newValue = entry.defaultValue || entry.defaultValue || options.value || ''
if (options.useKeysAsDefaultValue) {
newValue = entry.key.substring(entry.key.indexOf('.') + 1, entry.key.length)
}

@@ -93,3 +96,3 @@ if (path.endsWith(separator)) {

const singularKey = key.replace(pluralRegex, '')
// support for context in keys

@@ -99,3 +102,3 @@ const contextRegex = /_([^_]+)?$/;

const rawKey = singularKey.replace(contextRegex, '')
if (

@@ -102,0 +105,0 @@ (contextMatch && target[rawKey] !== undefined) ||

@@ -35,3 +35,4 @@ import { dotPathToHash, mergeHashes, transferValues } from './helpers'

sort: false,
verbose: false
useKeysAsDefaultValue: false,
verbose: false,
}

@@ -114,3 +115,4 @@

separator: this.options.keySeparator,
value: this.options.defaultValue
value: this.options.defaultValue,
useKeysAsDefaultValue: this.options.useKeysAsDefaultValue
}

@@ -216,3 +218,3 @@ )

}
return null

@@ -219,0 +221,0 @@ }

@@ -836,2 +836,33 @@ import { assert } from 'chai'

it.only('supports useKeysAsDefaultValue', (done) => {
let result
const i18nextParser = new i18nTransform({
useKeysAsDefaultValue: true,
})
const fakeFile = new Vinyl({
contents: Buffer.from(
"t('first'); \n t('second and third'); t('$fourth %fifth%'); t('six.seven');"
),
path: 'file.js'
})
i18nextParser.once('data', file => {
if (file.relative.endsWith(enLibraryPath)) {
result = JSON.parse(file.contents)
}
})
i18nextParser.on('end', () => {
assert.deepEqual(result, {
first: 'first',
'second and third': 'second and third',
'$fourth %fifth%': '$fourth %fifth%',
six: {
seven: 'six.seven'
}
})
done()
})
i18nextParser.end(fakeFile)
})
describe('lexers', () => {

@@ -838,0 +869,0 @@ it('support custom lexers options', (done) => {

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