i18next-parser
Advanced tools
Comparing version
@@ -11,2 +11,5 @@ '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 _javascriptLexer = require('./javascript-lexer');var _javascriptLexer2 = _interopRequireDefault(_javascriptLexer); | ||
}, | ||
JSXFragment: function JSXFragment(node, st, c) { | ||
node.children.forEach(function (child) {return c(child, st, child.type);}); | ||
}, | ||
JSXElement: function JSXElement(node, st, c) { | ||
@@ -13,0 +16,0 @@ node.openingElement.attributes.forEach(function (attr) {return c(attr, st, attr.type);}); |
@@ -23,3 +23,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 _get = function get(object, property, receiver) {if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) {var parent = Object.getPrototypeOf(object);if (parent === null) {return undefined;} else {return get(parent, property, receiver);}} else if ("value" in desc) {return desc.value;} else {var getter = desc.get;if (getter === undefined) {return undefined;}return getter.call(receiver);}};var _jsxLexer = require('./jsx-lexer');var _jsxLexer2 = _interopRequireDefault(_jsxLexer); | ||
this.tsOptions, { | ||
jsx: 'Preserve', | ||
jsx: extension === 'ts' ? false : 'Preserve', | ||
target: 'esnext' }) }); | ||
@@ -30,2 +30,2 @@ | ||
return _get(TypescriptLexer.prototype.__proto__ || Object.getPrototypeOf(TypescriptLexer.prototype), 'extract', this).call(this, transpiled.outputText); | ||
} }]);return TypescriptLexer;}(_jsxLexer2.default);exports.default = TypescriptLexer;module.exports = exports['default']; | ||
} }]);return TypescriptLexer;}(_jsxLexer2.default);exports.default = TypescriptLexer;module.exports = exports['default']; |
@@ -69,6 +69,6 @@ '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 _events = require('events');var _events2 = _interopRequireDefault(_events); | ||
Lexer.on('warning', function (warning) {return _this2.emit('warning', warning);}); | ||
keys = keys.concat(Lexer.extract(content)); | ||
keys = keys.concat(Lexer.extract(content, extension)); | ||
}} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator.return) {_iterator.return();}} finally {if (_didIteratorError) {throw _iteratorError;}}} | ||
return keys; | ||
} }]);return Parser;}(_events2.default);exports.default = Parser;module.exports = exports['default']; | ||
} }]);return Parser;}(_events2.default);exports.default = Parser;module.exports = exports['default']; |
@@ -5,3 +5,3 @@ { | ||
"name": "i18next-parser", | ||
"version": "1.0.0-beta30", | ||
"version": "1.0.0-beta31", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "dist/index.js", |
@@ -48,4 +48,4 @@ # i18next Parser [](https://travis-ci.org/i18next/i18next-parser) | ||
- **-c, --config <path>**: Path to the output directory (default: locales/$LOCALE/$NAMESPACE.json) | ||
- **-o, --output <path>**: Where to write the locale files. | ||
- **-c, --config <path>**: Path to the config file (default: i18next-parser.config.js). | ||
- **-o, --output <path>**: Path to the output directory (default: locales/$LOCALE/$NAMESPACE.json). | ||
- **-S, --silent**: Disable logging to stdout. | ||
@@ -52,0 +52,0 @@ |
@@ -11,2 +11,5 @@ import JavascriptLexer from './javascript-lexer' | ||
}, | ||
JSXFragment(node, st, c) { | ||
node.children.forEach(child => c(child, st, child.type)); | ||
}, | ||
JSXElement(node, st, c) { | ||
@@ -13,0 +16,0 @@ node.openingElement.attributes.forEach(attr => c(attr, st, attr.type)) |
@@ -23,3 +23,3 @@ import JsxLexer from './jsx-lexer' | ||
...this.tsOptions, | ||
jsx: 'Preserve', | ||
jsx: extension === 'ts' ? false : 'Preserve', | ||
target: 'esnext' | ||
@@ -26,0 +26,0 @@ } |
@@ -69,3 +69,3 @@ import EventEmitter from 'events' | ||
Lexer.on('warning', warning => this.emit('warning', warning)) | ||
keys = keys.concat(Lexer.extract(content)) | ||
keys = keys.concat(Lexer.extract(content, extension)) | ||
} | ||
@@ -72,0 +72,0 @@ |
@@ -106,2 +106,11 @@ import { assert, expect } from 'chai' | ||
}) | ||
it('handles jsx fragments', (done) => { | ||
const Lexer = new JsxLexer() | ||
const content = '<><Trans i18nKey="first" /></>' | ||
assert.deepEqual(Lexer.extract(content), [ | ||
{ key: 'first' } | ||
]) | ||
done() | ||
}) | ||
}) | ||
@@ -108,0 +117,0 @@ describe('supports additional plugins via injector option', () => { |
480537
0.12%4055
0.4%