signavio-i18n
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -74,3 +74,3 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
if (isWrappedInPTag(finalTranslation)) { | ||
// last occurrence of <p> is at the start, first occurence of </p> is a the very end | ||
// last occurrence of <p> is at the start, first occurrence of </p> is a the very end | ||
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5); | ||
@@ -82,5 +82,7 @@ } | ||
function htmlStringToReactComponent(html) { | ||
function htmlStringToReactComponent(html, _ref) { | ||
var key = _ref.key; | ||
// eslint-disable-next-line react/no-danger | ||
return React.createElement("span", { | ||
key: key, | ||
dangerouslySetInnerHTML: { | ||
@@ -116,7 +118,11 @@ __html: html | ||
substr = translation.substring(start, match.index); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr, { | ||
key: result.length | ||
}) : substr); | ||
} | ||
if (React.isValidElement(component)) { | ||
result.push(result.indexOf(component) >= 0 ? React.cloneElement(component) : component); | ||
result.push(React.cloneElement(component, { | ||
key: result.length | ||
})); | ||
} else { | ||
@@ -133,3 +139,5 @@ // no interpolation specified, leave the placeholder unchanged | ||
substr = translation.substring(start); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr, { | ||
key: result.length | ||
}) : substr); | ||
} // re-concatenate all string elements | ||
@@ -136,0 +144,0 @@ |
@@ -97,3 +97,3 @@ "use strict"; | ||
if (isWrappedInPTag(finalTranslation)) { | ||
// last occurrence of <p> is at the start, first occurence of </p> is a the very end | ||
// last occurrence of <p> is at the start, first occurrence of </p> is a the very end | ||
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5); | ||
@@ -105,5 +105,7 @@ } | ||
function htmlStringToReactComponent(html) { | ||
function htmlStringToReactComponent(html, _ref) { | ||
var key = _ref.key; | ||
// eslint-disable-next-line react/no-danger | ||
return _react.default.createElement("span", { | ||
key: key, | ||
dangerouslySetInnerHTML: { | ||
@@ -139,7 +141,11 @@ __html: html | ||
substr = translation.substring(start, match.index); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr, { | ||
key: result.length | ||
}) : substr); | ||
} | ||
if (_react.default.isValidElement(component)) { | ||
result.push(result.indexOf(component) >= 0 ? _react.default.cloneElement(component) : component); | ||
result.push(_react.default.cloneElement(component, { | ||
key: result.length | ||
})); | ||
} else { | ||
@@ -156,3 +162,5 @@ // no interpolation specified, leave the placeholder unchanged | ||
substr = translation.substring(start); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr); | ||
result.push(options.markdown ? htmlStringToReactComponent(substr, { | ||
key: result.length | ||
}) : substr); | ||
} // re-concatenate all string elements | ||
@@ -159,0 +167,0 @@ |
{ | ||
"name": "signavio-i18n", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Minimalist gettext style i18n for JavaScript", | ||
@@ -23,3 +23,4 @@ "main": "lib/index.js", | ||
"dryrun": "node ./bin/i18n-extract.js test/fixtures/**/*.js", | ||
"lint": "eslint src specs", | ||
"format": "prettier --write --no-semi --single-quote --trailing-comma es5 \"{src,test}/**/*.js\"", | ||
"lint": "eslint src test/specs", | ||
"test": "cross-env NODE_ENV=es5 mocha-webpack", | ||
@@ -70,2 +71,3 @@ "pretest": "yarn build", | ||
"ajv": "^6.1.1", | ||
"babel-eslint": "9.x", | ||
"babel-loader": "^8.0.0", | ||
@@ -84,7 +86,12 @@ "babel-plugin-lodash": "^3.3.4", | ||
"enzyme-adapter-react-16": "^1.1.1", | ||
"eslint": "^3.12.2", | ||
"eslint": "5.x", | ||
"eslint-config-react-app": "^3.0.5", | ||
"eslint-config-signavio": "^1.4.1", | ||
"eslint-config-signavio-test": "^1.2.1", | ||
"eslint-plugin-chai-expect": "^1.1.1", | ||
"eslint-plugin-flowtype": "2.x", | ||
"eslint-plugin-import": "2.x", | ||
"eslint-plugin-jsx-a11y": "6.x", | ||
"eslint-plugin-mocha": "^4.7.0", | ||
"eslint-plugin-react": "7.x", | ||
"flow-bin": "^0.65.0", | ||
@@ -99,2 +106,3 @@ "istanbul-instrumenter-loader": "^2.0.0", | ||
"po2json": "^0.4.2", | ||
"prettier": "^1.15.3", | ||
"react": "^16.2.0", | ||
@@ -101,0 +109,0 @@ "react-dom": "^16.2.0", |
// THIS FILE NEEDS TO STAY IN THIS SHITTY FORMAT | ||
// init jsdom | ||
var jsdom = require('jsdom').jsdom; | ||
var doc = jsdom('<!doctype html><html><head><meta charset="utf-8"></head><body><script/></body></html>'); | ||
var win = doc.defaultView; | ||
var jsdom = require('jsdom').jsdom | ||
var doc = jsdom( | ||
'<!doctype html><html><head><meta charset="utf-8"></head><body><script/></body></html>' | ||
) | ||
var win = doc.defaultView | ||
// globalize some stuff | ||
global.document = doc; | ||
global.window = win; | ||
win.console = global.console; | ||
global.navigator = { userAgent: "Node.js" }; | ||
global.Blob = window.Blob; | ||
global.document = doc | ||
global.window = win | ||
win.console = global.console | ||
global.navigator = { userAgent: 'Node.js' } | ||
global.Blob = window.Blob | ||
// setup chai plugins | ||
var chai = require('chai'); | ||
var chaiEnzyme = require('chai-enzyme'); | ||
var chaiFiles = require('chai-files'); | ||
chai.use(chaiEnzyme()); | ||
var chai = require('chai') | ||
var chaiEnzyme = require('chai-enzyme') | ||
var chaiFiles = require('chai-files') | ||
chai.use(chaiEnzyme()) | ||
chai.use(chaiFiles) | ||
// other re-exports for testing so that other packages do not have to add all testing deps | ||
var enzyme = require('enzyme'); | ||
var enzyme = require('enzyme') | ||
// setup enzyme adapter (necessary since react v16) | ||
var Adapter = require('enzyme-adapter-react-16'); | ||
enzyme.configure({ adapter: new Adapter() }); | ||
var Adapter = require('enzyme-adapter-react-16') | ||
enzyme.configure({ adapter: new Adapter() }) | ||
@@ -34,2 +36,2 @@ // export preconfigured chai | ||
expect: chai.expect, | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
7
4
152247
60
61
2179