i18next-parser
Advanced tools
Comparing version 1.0.0-beta34 to 1.0.0-beta35
@@ -12,5 +12,5 @@ '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 || entry.defaultValue || options.value || ''; | ||
var newValue = entry.defaultValue || options.value || ''; | ||
if (options.useKeysAsDefaultValue) { | ||
newValue = entry.key.substring(entry.key.indexOf('.') + 1, entry.key.length); | ||
newValue = entry.key.substring(entry.key.indexOf(separator) + separator.length, entry.key.length); | ||
} | ||
@@ -17,0 +17,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"name": "i18next-parser", | ||
"version": "1.0.0-beta34", | ||
"version": "1.0.0-beta35", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "dist/index.js", |
@@ -27,3 +27,3 @@ # i18next Parser [![Build Status](https://travis-ci.org/i18next/i18next-parser.svg?branch=master)](https://travis-ci.org/i18next/i18next-parser) | ||
## DISCLAMER: `1.0.0-beta` | ||
## DISCLAIMER: `1.0.0-beta` | ||
@@ -270,3 +270,3 @@ `1.x` is currently in beta. You can follow the pre-releases [here](https://github.com/i18next/i18next-parser/releases). It is a deep rewrite of this package that solves many issues, the main one being that it was slowly becoming unmaintainable. The [migration](docs/migration.md) contains all the breaking changes. Everything that follows is related to `1.x`. If you rely on a `0.x.x` version, you can still find the old documentation on its dedicated [branch](https://github.com/i18next/i18next-parser/tree/0.x.x). | ||
# or | ||
yarn add -D acorn-jsx | ||
yarn add -D acorn-jsx@4.1.1 | ||
``` | ||
@@ -296,5 +296,5 @@ | ||
```bash | ||
npm install -D typescript acorn-jsx | ||
npm install -D typescript acorn-jsx@4.1.1 | ||
# or | ||
yarn add -D typescript acorn-jsx | ||
yarn add -D typescript acorn-jsx@4.1.1 | ||
``` | ||
@@ -301,0 +301,0 @@ If you need additional plugins, you can install them in the same way as described in the Javascript lexer configuration. |
@@ -12,5 +12,5 @@ /** | ||
const separator = options.separator || '.' | ||
let newValue = entry.defaultValue || entry.defaultValue || options.value || '' | ||
let newValue = entry.defaultValue || options.value || '' | ||
if (options.useKeysAsDefaultValue) { | ||
newValue = entry.key.substring(entry.key.indexOf('.') + 1, entry.key.length) | ||
newValue = entry.key.substring(entry.key.indexOf(separator) + separator.length, entry.key.length) | ||
} | ||
@@ -143,14 +143,6 @@ | ||
class ParsingError extends Error { | ||
constructor(message) { | ||
super(message); | ||
this.name = 'ParsingError'; | ||
} | ||
} | ||
export { | ||
dotPathToHash, | ||
mergeHashes, | ||
transferValues, | ||
ParsingError | ||
transferValues | ||
} |
@@ -112,3 +112,3 @@ import JavascriptLexer from './javascript-lexer' | ||
case 'tag': return `<${index}>${elemsToString(child.children)}</${index}>` | ||
default: throw new ParsingError('Unknown parsed content: ' + child.type) | ||
default: throw new Error('Unknown parsed content: ' + child.type) | ||
} | ||
@@ -173,3 +173,3 @@ }).join('') | ||
else { | ||
throw new ParsingError('Unknown ast element when parsing jsx: ' + child.type) | ||
throw new Error('Unknown ast element when parsing jsx: ' + child.type) | ||
} | ||
@@ -176,0 +176,0 @@ }).filter(child => child.type !== 'text' || child.content) |
@@ -30,2 +30,22 @@ import { assert } from 'chai' | ||
it('supports custom separator', (done) => { | ||
const { target } = dotPathToHash( | ||
{ key: 'one-two' }, | ||
{}, | ||
{ separator: '-' } | ||
) | ||
assert.deepEqual(target, { one: { two: '' } }) | ||
done() | ||
}) | ||
it('supports custom separator when `useKeysAsDefaultValue` is true', (done) => { | ||
const { target } = dotPathToHash( | ||
{ key: 'namespace-two-three' }, | ||
{}, | ||
{ separator: '-', useKeysAsDefaultValue: true } | ||
) | ||
assert.deepEqual(target, { namespace: { two: { three: 'two-three' } } }) | ||
done() | ||
}) | ||
it('handles a target hash', (done) => { | ||
@@ -32,0 +52,0 @@ const { target, duplicate } = dotPathToHash( |
@@ -836,3 +836,3 @@ import { assert } from 'chai' | ||
it.only('supports useKeysAsDefaultValue', (done) => { | ||
it('supports useKeysAsDefaultValue', (done) => { | ||
let result | ||
@@ -839,0 +839,0 @@ const i18nextParser = new i18nTransform({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
483530
4135