i18next-parser
Advanced tools
Comparing version 1.0.0-beta7 to 1.0.0-beta8
# Changelog | ||
## 1.0.0-beta7 - latest | ||
## 1.0.0-beta8 - latest | ||
- See [release](https://github.com/i18next/i18next-parser/releases/tag/1.0.0-beta8) | ||
## 1.0.0-beta7 | ||
- See [release](https://github.com/i18next/i18next-parser/releases/tag/1.0.0-beta7) | ||
@@ -6,0 +10,0 @@ |
@@ -35,4 +35,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 _htmlLexer = require('./html-lexer');var _htmlLexer2 = _interopRequireDefault(_htmlLexer);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: 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 | ||
var matches = void 0; | ||
var closingTagPattern = '(?:<Trans([^>]*\\s' + this.attr + '[^>]*?)\\/>)'; | ||
var selfClosingTagPattern = '(?:<Trans([^>]*\\s' + this.attr + '[^>]*?)>((?:\\s|.)*?)<\\/Trans>)'; | ||
var regex = new RegExp( | ||
'<Trans([^>]*\\s' + this.attr + '[^>]*)>(?:((?:\\s|.)*?)<\\/Trans>)?', | ||
[closingTagPattern, selfClosingTagPattern].join('|'), | ||
'gi'); | ||
@@ -42,7 +44,7 @@ | ||
while (matches = regex.exec(content)) { | ||
var attrs = this.parseAttributes(matches[1]); | ||
var attrs = this.parseAttributes(matches[1] || matches[2]); | ||
var key = attrs.keys; | ||
if (matches[2] && !attrs.options.defaultValue) { | ||
attrs.options.defaultValue = matches[2].trim(); | ||
if (matches[3] && !attrs.options.defaultValue) { | ||
attrs.options.defaultValue = matches[3].trim(); | ||
} | ||
@@ -49,0 +51,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"name": "i18next-parser", | ||
"version": "1.0.0-beta7", | ||
"version": "1.0.0-beta8", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "src/index.js", |
@@ -35,4 +35,6 @@ import HTMLLexer from './html-lexer' | ||
let matches | ||
const closingTagPattern = '(?:<Trans([^>]*\\s' + this.attr + '[^>]*?)\\/>)' | ||
const selfClosingTagPattern = '(?:<Trans([^>]*\\s' + this.attr + '[^>]*?)>((?:\\s|.)*?)<\\/Trans>)' | ||
const regex = new RegExp( | ||
'<Trans([^>]*\\s' + this.attr + '[^>]*)>(?:((?:\\s|.)*?)<\\/Trans>)?', | ||
[closingTagPattern, selfClosingTagPattern].join('|'), | ||
'gi' | ||
@@ -42,7 +44,7 @@ ) | ||
while (matches = regex.exec(content)) { | ||
const attrs = this.parseAttributes(matches[1]) | ||
const attrs = this.parseAttributes(matches[1] || matches[2]) | ||
const key = attrs.keys | ||
if (matches[2] && !attrs.options.defaultValue) { | ||
attrs.options.defaultValue = matches[2].trim() | ||
if (matches[3] && !attrs.options.defaultValue) { | ||
attrs.options.defaultValue = matches[3].trim() | ||
} | ||
@@ -49,0 +51,0 @@ |
@@ -189,3 +189,5 @@ import { assert } from 'chai' | ||
fourth: '', | ||
fifth: '' | ||
fifth: '', | ||
bar: '', | ||
foo: '' | ||
} | ||
@@ -577,3 +579,5 @@ | ||
fourth: '', | ||
fifth: '' | ||
fifth: '', | ||
bar: '', | ||
foo: '' | ||
} | ||
@@ -580,0 +584,0 @@ |
import React from 'react' | ||
import { translate, Trans, Interpolate } from 'react-i18next' | ||
const bar = () => ( | ||
<div> | ||
<span><Trans i18nKey="bar"></Trans></span> | ||
</div> | ||
); | ||
const foo = () => ( | ||
<div> | ||
<span><Trans i18nKey="foo" /></span> | ||
</div> | ||
); | ||
class Test extends React.Component { | ||
@@ -14,3 +26,3 @@ render () { | ||
</Trans> | ||
<Trans i18nKey="fifth" count={count} /> | ||
<span><Trans i18nKey="fifth" count={count} /></span> | ||
</div> | ||
@@ -17,0 +29,0 @@ ) |
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
210716
3069