Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

signavio-i18n

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signavio-i18n - npm Package Compare versions

Comparing version 2.1.0-1 to 2.1.0

.tmp/mocha-webpack/3c4b27a37d71fbceeb8024b7f06332a9-entry.js

2

.tmp/mocha-webpack/7198eedda8454a60f1b410c3e1950df4/0.7198eedda8454a60f1b410c3e1950df4-output.js
exports.ids = [0];
exports.modules = {
/***/ 30:
/***/ 32:
/***/ (function(module, exports) {

@@ -6,0 +6,0 @@

exports.ids = [1];
exports.modules = {
/***/ 29:
/***/ 31:
/***/ (function(module, exports) {

@@ -6,0 +6,0 @@

@@ -94,3 +94,3 @@ /******/ (function(modules) { // webpackBootstrap

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ return __webpack_require__(__webpack_require__.s = 8);
/******/ })

@@ -108,3 +108,3 @@ /************************************************************************/

module.exports = require("invariant");
module.exports = require("fs");

@@ -115,3 +115,3 @@ /***/ }),

module.exports = require("fs");
module.exports = require("@babel/runtime/helpers/objectSpread");

@@ -122,12 +122,31 @@ /***/ }),

module.exports = require("chai-files");
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = require("child_process");
/***/ }),
/* 5 */
/***/ (function(module, exports) {
module.exports = require("lodash/forEach");
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = require("react");
/***/ }),
/* 4 */
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./specs/i18n.spec.js": 10,
"./specs/scripts/config.spec.js": 11,
"./specs/scripts/extract.spec.js": 12
"./specs/i18n.spec.js": 13,
"./specs/scripts/config.spec.js": 14,
"./specs/scripts/extract.spec.js": 15,
"./specs/scripts/updateSources.spec.js": 16
};

@@ -148,9 +167,9 @@ function webpackContext(req) {

module.exports = webpackContext;
webpackContext.id = 4;
webpackContext.id = 7;
/***/ }),
/* 5 */
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
var testsContext = __webpack_require__(4);
var testsContext = __webpack_require__(7);

@@ -161,9 +180,11 @@ var runnable = testsContext.keys();

/***/ }),
/* 6 */
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_invariant__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_invariant___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_invariant__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__translate__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_isFunction__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_isFunction___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_isFunction__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lodash_forEach__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lodash_forEach___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_lodash_forEach__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__translate__ = __webpack_require__(11);
/* harmony export (immutable) */ __webpack_exports__["c"] = init;

@@ -177,2 +198,3 @@ /* harmony export (immutable) */ __webpack_exports__["b"] = setLocale;

var config = {};

@@ -183,3 +205,4 @@ var specifiedLocale;

var singleton = {
messages: {}
messages: {},
interpolationPattern: '__(\\w+)__'
/**

@@ -193,3 +216,3 @@ * The translate function

};
var translate = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__translate__["a" /* default */])(singleton);
var translate = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__translate__["a" /* default */])(singleton);
/* harmony default export */ __webpack_exports__["d"] = (translate);

@@ -210,2 +233,7 @@ /**

config = configObj;
if (config.interpolationPattern) {
singleton.interpolationPattern = configObj.interpolationPattern;
}
return new Promise(loadBundle);

@@ -251,3 +279,2 @@ }

__WEBPACK_IMPORTED_MODULE_0_invariant___default()(config, 'could not determine default local due to missing configuration.');
return mapLocale(config.default || 'en_US'); // fall back to default

@@ -285,3 +312,2 @@ }

try {
__WEBPACK_IMPORTED_MODULE_0_invariant___default()(typeof getLangLoader === 'function', 'Cannot load a bundle as no valid getLangLoader function has been set');
waitForLangChunk = getLangLoader(forLocale);

@@ -296,7 +322,10 @@ } catch (e) {

function loadBundle(resolve) {
__WEBPACK_IMPORTED_MODULE_0_invariant___default()(typeof getLangLoader === 'function', 'Cannot load a bundle as no valid getLangLoader function has been set');
var waitForLangChunk = getLangLoader(locale());
if (!__WEBPACK_IMPORTED_MODULE_0_lodash_isFunction___default()(getLangLoader)) {
throw new Error('Cannot load a bundle as no valid getLangLoader function has been set');
}
var waitForLangChunk = tryToGetLangLoader(locale());
waitForLangChunk(function (messages) {
singleton.messages = messages;
changeLocaleListeners.forEach(function (listener) {
__WEBPACK_IMPORTED_MODULE_1_lodash_forEach___default()(changeLocaleListeners, function (listener) {
return listener();

@@ -309,16 +338,13 @@ });

/***/ }),
/* 7 */
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fs__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_fs__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_path__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_path___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_path__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_invariant__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_invariant___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_invariant__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_path__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_fs__);
/* harmony export (immutable) */ __webpack_exports__["a"] = getConfig;
var I18NRC_FILENAME = '.i18nrc';

@@ -330,3 +356,3 @@ var existsCache = {};

if (existsCache[fileName] == null) {
existsCache[fileName] = __WEBPACK_IMPORTED_MODULE_0_fs___default.a.existsSync(fileName);
existsCache[fileName] = __WEBPACK_IMPORTED_MODULE_1_fs___default.a.existsSync(fileName);
}

@@ -344,8 +370,8 @@

if (!__WEBPACK_IMPORTED_MODULE_1_path___default.a.isAbsolute(location)) {
location = __WEBPACK_IMPORTED_MODULE_1_path___default.a.join(process.cwd(), location);
if (!__WEBPACK_IMPORTED_MODULE_0_path___default.a.isAbsolute(location)) {
location = __WEBPACK_IMPORTED_MODULE_0_path___default.a.join(process.cwd(), location);
}
do {
var configLoc = __WEBPACK_IMPORTED_MODULE_1_path___default.a.join(location, I18NRC_FILENAME);
var configLoc = __WEBPACK_IMPORTED_MODULE_0_path___default.a.join(location, I18NRC_FILENAME);

@@ -355,3 +381,3 @@ if (exists(configLoc)) {

}
} while (location !== (location = __WEBPACK_IMPORTED_MODULE_1_path___default.a.dirname(location)));
} while (location !== (location = __WEBPACK_IMPORTED_MODULE_0_path___default.a.dirname(location)));

@@ -364,4 +390,7 @@ return null;

var loc = findConfig(filename);
__WEBPACK_IMPORTED_MODULE_2_invariant___default()(loc, 'Could not find .i18nrc');
if (!loc) {
throw new Error('Could not find .i18nrc');
}
if (configCache[loc]) {

@@ -371,3 +400,3 @@ return configCache[loc];

var content = __WEBPACK_IMPORTED_MODULE_0_fs___default.a.readFileSync(loc, 'utf8');
var content = __WEBPACK_IMPORTED_MODULE_1_fs___default.a.readFileSync(loc, 'utf8');

@@ -385,27 +414,27 @@ try {

/***/ }),
/* 8 */
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_typeof__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_typeof___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_typeof__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_slicedToArray__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_slicedToArray___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_slicedToArray__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__babel_runtime_helpers_objectSpread__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__babel_runtime_helpers_objectSpread___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__babel_runtime_helpers_objectSpread__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_invariant__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_invariant___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_invariant__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lodash_escape__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lodash_escape___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_lodash_escape__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_lodash_forEach__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_slicedToArray__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_slicedToArray___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_slicedToArray__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_objectSpread__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_objectSpread___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_objectSpread__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_lodash_isString__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_lodash_isString___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_lodash_isString__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_lodash_isNumber__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_lodash_isNumber___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_lodash_isNumber__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lodash_isPlainObject__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lodash_isPlainObject___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_lodash_isPlainObject__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_lodash_forEach__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_lodash_forEach___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_lodash_forEach__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_lodash_has__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_lodash_has___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_lodash_has__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lodash_isNumber__ = __webpack_require__(24);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lodash_isNumber___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_lodash_isNumber__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_lodash_pickBy__ = __webpack_require__(25);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_lodash_pickBy___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_lodash_pickBy__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_marked__ = __webpack_require__(26);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_lodash_pickBy__ = __webpack_require__(27);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_lodash_pickBy___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_lodash_pickBy__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lodash_has__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lodash_has___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_lodash_has__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_lodash_escape__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_lodash_escape___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_lodash_escape__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_marked__ = __webpack_require__(28);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_marked___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9_marked__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_react__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_react__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_react__);

@@ -423,3 +452,2 @@

var placeholderRegex = /__(\w+)__/g;
var defaultOptions = {

@@ -435,3 +463,3 @@ markdown: !1

if (!finalOptions && typeof plural !== 'string') {
if (!finalOptions && __WEBPACK_IMPORTED_MODULE_4_lodash_isPlainObject___default()(finalPlural)) {
finalOptions = plural;

@@ -441,3 +469,3 @@ finalPlural = undefined;

finalOptions = __WEBPACK_IMPORTED_MODULE_2__babel_runtime_helpers_objectSpread___default()({}, defaultOptions, finalOptions, {
finalOptions = __WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_objectSpread___default()({}, defaultOptions, finalOptions, {
context: finalOptions && finalOptions.context ? "".concat(finalOptions.context, "\x04") : ''

@@ -447,3 +475,3 @@ });

var _slice = (singleton.messages[finalOptions.context + text] || [null, null, null]).slice(1),
_slice2 = __WEBPACK_IMPORTED_MODULE_1__babel_runtime_helpers_slicedToArray___default()(_slice, 2),
_slice2 = __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_slicedToArray___default()(_slice, 2),
translatedSingular = _slice2[0],

@@ -456,6 +484,5 @@ translatedPlural = _slice2[1]; // find the raw translation message

if (finalPlural && needsPlural(finalOptions)) {
__WEBPACK_IMPORTED_MODULE_3_invariant___default()(typeof finalPlural === 'string', "Expted plural to be a string but was ".concat(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_typeof___default()(finalPlural)));
translation = translatedPlural && typeof translatedPlural === 'string' ? translatedPlural : finalPlural;
translation = translatedPlural && __WEBPACK_IMPORTED_MODULE_2_lodash_isString___default()(translatedPlural) ? translatedPlural : finalPlural;
} else {
translation = translatedSingular && typeof translatedSingular === 'string' ? translatedSingular : text;
translation = translatedSingular && __WEBPACK_IMPORTED_MODULE_2_lodash_isString___default()(translatedSingular) ? translatedSingular : text;
} // apply markdown processing if necessary

@@ -474,99 +501,104 @@

};
});
function needsPlural(options) {
return __WEBPACK_IMPORTED_MODULE_7_lodash_isNumber___default()(options.count) && Math.abs(options.count) !== 1;
}
function needsPlural(options) {
return __WEBPACK_IMPORTED_MODULE_3_lodash_isNumber___default()(options.count) && Math.abs(options.count) !== 1;
}
function isWrappedInPTag(translation) {
return translation.lastIndexOf('<p>') === 0 && translation.indexOf('</p>') === translation.length - 5;
}
function applyMarkdown(translation) {
// Escape underscores.
// (Since we use underscores to denote interpolations, we have to
// exclude them from the markdown notation. Use asterisk (*) instead.)
var finalTranslation = __WEBPACK_IMPORTED_MODULE_9_marked___default()(translation.replace(/_/g, '\\_')); // remove single, outer wrapping <p>-tag
if (isWrappedInPTag(finalTranslation)) {
// last occurrence of <p> is at the start, first occurence of </p> is a the very end
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5);
function isWrappedInPTag(translation) {
return translation.lastIndexOf('<p>') === 0 && translation.indexOf('</p>') === translation.length - 5;
}
return finalTranslation.replace(/\\_/g, '_');
}
function applyMarkdown(translation) {
// Escape underscores.
// (Since we use underscores to denote interpolations, we have to
// exclude them from the markdown notation. Use asterisk (*) instead.)
var finalTranslation = __WEBPACK_IMPORTED_MODULE_9_marked___default()(translation.replace(/_/g, '\\_')); // remove single, outer wrapping <p>-tag
function htmlStringToReactComponent(html) {
// eslint-disable-next-line react/no-danger
return __WEBPACK_IMPORTED_MODULE_10_react___default.a.createElement("span", {
dangerouslySetInnerHTML: {
__html: html
if (isWrappedInPTag(finalTranslation)) {
// last occurrence of <p> is at the start, first occurrence of </p> is a the very end
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5);
}
});
}
function insertInterpolations(translation, options) {
var regularInterpolations = __WEBPACK_IMPORTED_MODULE_8_lodash_pickBy___default()(options, function (val, key) {
return !__WEBPACK_IMPORTED_MODULE_6_lodash_has___default()(defaultOptions, key) && !__WEBPACK_IMPORTED_MODULE_10_react___default.a.isValidElement(val);
});
var finalTranslation = translation;
__WEBPACK_IMPORTED_MODULE_5_lodash_forEach___default()(regularInterpolations, function (val, key) {
finalTranslation = finalTranslation.replace(new RegExp("__".concat(key, "__"), 'g'), options.markdown ? __WEBPACK_IMPORTED_MODULE_4_lodash_escape___default()(val) : val // only escape options when using markdown
);
});
return finalTranslation;
}
return finalTranslation.replace(/\\_/g, '_');
}
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
function htmlStringToReactComponent(html, _ref) {
var key = _ref.key;
// eslint-disable-next-line react/no-danger
return __WEBPACK_IMPORTED_MODULE_10_react___default.a.createElement("span", {
key: key,
dangerouslySetInnerHTML: {
__html: html
}
});
}
while ((match = placeholderRegex.exec(translation)) !== null) {
if (!match) {
break;
}
function insertInterpolations(translation, options) {
var regularInterpolations = __WEBPACK_IMPORTED_MODULE_6_lodash_pickBy___default()(options, function (val, key) {
return !__WEBPACK_IMPORTED_MODULE_7_lodash_has___default()(defaultOptions, key) && !__WEBPACK_IMPORTED_MODULE_10_react___default.a.isValidElement(val);
});
var finalTranslation = translation;
__WEBPACK_IMPORTED_MODULE_5_lodash_forEach___default()(regularInterpolations, function (val, key) {
finalTranslation = finalTranslation.replace(new RegExp(singleton.interpolationPattern.replace('(\\w+)', key), 'g'), options.markdown ? __WEBPACK_IMPORTED_MODULE_8_lodash_escape___default()(val) : val // only escape options when using markdown
);
});
return finalTranslation;
}
var key = match[1];
var component = options[key];
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
var interpolationRegExp = new RegExp(singleton.interpolationPattern, 'g');
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
}
while ((match = interpolationRegExp.exec(translation)) !== null) {
var key = match[1];
var component = options[key];
if (__WEBPACK_IMPORTED_MODULE_10_react___default.a.isValidElement(component)) {
result.push(result.indexOf(component) >= 0 ? __WEBPACK_IMPORTED_MODULE_10_react___default.a.cloneElement(component) : component);
} else {
// no interpolation specified, leave the placeholder unchanged
result.push(match[0]);
}
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
}
start = placeholderRegex.lastIndex;
} // append part after last match
if (__WEBPACK_IMPORTED_MODULE_10_react___default.a.isValidElement(component)) {
result.push(__WEBPACK_IMPORTED_MODULE_10_react___default.a.cloneElement(component, {
key: result.length
}));
} else {
// no interpolation specified, leave the placeholder unchanged
result.push(match[0]);
}
start = interpolationRegExp.lastIndex;
} // append part after last match
if (start < translation.length) {
substr = translation.substring(start);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
} // re-concatenate all string elements
if (start < translation.length) {
substr = translation.substring(start);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
} // re-concatenate all string elements
return result.reduce(function (acc, element) {
var lastAccumulatedElement = acc[acc.length - 1];
if (typeof element === 'string' && typeof lastAccumulatedElement === 'string') {
// eslint-disable-next-line no-param-reassign
acc[acc.length - 1] = lastAccumulatedElement + element;
} else {
acc.push(element);
}
return result.reduce(function (acc, element) {
var lastAccumulatedElement = acc[acc.length - 1];
return acc;
}, []);
}
if (__WEBPACK_IMPORTED_MODULE_2_lodash_isString___default()(element) && __WEBPACK_IMPORTED_MODULE_2_lodash_isString___default()(lastAccumulatedElement)) {
// eslint-disable-next-line no-param-reassign
acc[acc.length - 1] = lastAccumulatedElement + element;
} else {
acc.push(element);
}
return acc;
}, []);
}
});
/***/ }),
/* 9 */
/* 12 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -584,3 +616,3 @@

/***/ }),
/* 10 */
/* 13 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -590,10 +622,12 @@

Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom_server__ = __webpack_require__(28);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom_server___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react_dom_server__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_chai__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__config__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_react_dom_server__ = __webpack_require__(30);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_react_dom_server___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_react_dom_server__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_chai__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_chai___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_chai__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__config__ = __webpack_require__(12);

@@ -605,2 +639,3 @@

function getLangLoader(locale) {

@@ -613,24 +648,23 @@ // A runtime exception will be throw every time that the requested locale file

// eslint-disable-next-line global-require,import/no-dynamic-require,prefer-template
return __webpack_require__(15)("./" + locale + '.po');
return __webpack_require__(19)("./" + locale + '.po');
}
describe('i18n', function () {
beforeEach(__WEBPACK_IMPORTED_MODULE_3__src__["a" /* reset */]);
beforeEach(__WEBPACK_IMPORTED_MODULE_4__src__["a" /* reset */]);
describe('setLocale', function () {
it('should make sure the correct bundle will be loaded when init is called', function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('de_DE'); // return a promise and use mocha's built in promises support
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["b" /* setLocale */])('de_DE'); // return a promise and use mocha's built in promises support
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('for')).to.equal('für');
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('for')).to.equal('für');
});
});
it('should load the respective bundle if called after init', function (done) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('en_US'); // return a promise and use mocha's built in promises support
it('should load the respective bundle if called after init', function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["b" /* setLocale */])('en_US'); // return a promise and use mocha's built in promises support
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('for')).to.equal('for');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('de_DE');
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('for')).to.equal('für');
done();
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('for')).to.equal('for');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["b" /* setLocale */])('de_DE');
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('for')).to.equal('für');
});

@@ -642,138 +676,175 @@ });

it('should return a plain string whenever possible', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a __test__.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a __test__.', {
test: 'success'
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.equal('This is a success.');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.equal('This is a success.');
});
it('should not escape interpolations', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a __test__.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a __test__.', {
test: '<success>'
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.equal('This is a <success>.');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.equal('This is a <success>.');
});
it('should support using Markdown in translation messages', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a **__test__**.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a **__test__**.', {
test: 'success',
markdown: !0
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__WEBPACK_IMPORTED_MODULE_0_react___default.a.isValidElement(t)).to.be.true;
var renderedHtml = __WEBPACK_IMPORTED_MODULE_1_react_dom_server___default.a.renderToStaticMarkup(t);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(renderedHtml).to.equal('<span>This is a <strong>success</strong>.</span>');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__WEBPACK_IMPORTED_MODULE_1_react___default.a.isValidElement(t)).to.be.true;
var renderedHtml = __WEBPACK_IMPORTED_MODULE_2_react_dom_server___default.a.renderToStaticMarkup(t);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(renderedHtml).to.equal('<span>This is a <strong>success</strong>.</span>');
});
it('should correctly escape interpolations when used with Markdown', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a **__test__**.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a **__test__**.', {
test: '<success>',
markdown: !0
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__WEBPACK_IMPORTED_MODULE_0_react___default.a.isValidElement(t)).to.be.true;
var renderedHtml = __WEBPACK_IMPORTED_MODULE_1_react_dom_server___default.a.renderToStaticMarkup(t);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(renderedHtml).to.equal('<span>This is a <strong>&lt;success&gt;</strong>.</span>');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__WEBPACK_IMPORTED_MODULE_1_react___default.a.isValidElement(t)).to.be.true;
var renderedHtml = __WEBPACK_IMPORTED_MODULE_2_react_dom_server___default.a.renderToStaticMarkup(t);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(renderedHtml).to.equal('<span>This is a <strong>&lt;success&gt;</strong>.</span>');
});
it('should not replace "__markdown__" placeholders', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is __markdown__.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is __markdown__.', {
markdown: !0
});
var renderedHtml = __WEBPACK_IMPORTED_MODULE_1_react_dom_server___default.a.renderToStaticMarkup(__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div", null, t));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(renderedHtml).to.equal('<div><span>This is </span>__markdown__<span>.</span></div>');
var renderedHtml = __WEBPACK_IMPORTED_MODULE_2_react_dom_server___default.a.renderToStaticMarkup(__WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement("div", null, t));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(renderedHtml).to.equal('<div><span>This is </span>__markdown__<span>.</span></div>');
});
it.skip('should not be possible to break Markdown from interpolations', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('**__foo__**', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('**__foo__**', {
foo: 'bar** baz **baa',
markdown: !0
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__WEBPACK_IMPORTED_MODULE_0_react___default.a.isValidElement(t)).to.be.true;
var renderedHtml = __WEBPACK_IMPORTED_MODULE_1_react_dom_server___default.a.renderToStaticMarkup(t);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(renderedHtml).to.equal('<span>foo <strong>bar** baz **baa</strong></span>');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__WEBPACK_IMPORTED_MODULE_1_react___default.a.isValidElement(t)).to.be.true;
var renderedHtml = __WEBPACK_IMPORTED_MODULE_2_react_dom_server___default.a.renderToStaticMarkup(t);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(renderedHtml).to.equal('<span>foo <strong>bar** baz **baa</strong></span>');
});
it('should support React components for interpolation values', function () {
var comp = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div", null, "comp content");
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('before __reactComp__ after', {
reactComp: comp
it('should support React elements as interpolation values', function () {
var element = __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement("div", null, "element content");
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('before __reactElement__ after', {
reactElement: element
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.be.an('array');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.have.length(3);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[0]).to.equal('before ');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[1]).to.equal(comp);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[2]).to.equal(' after');
var elementClone = __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread___default()({}, t[1], {
key: null
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.be.an('array');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.have.length(3);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t[0]).to.equal('before ');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(elementClone).to.deep.equal(element);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t[2]).to.equal(' after');
});
it('should support using the same React component multiple times', function () {
var comp = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div", null, "comp content");
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('before __reactComp__ within __reactComp__', {
reactComp: comp
it('should support using the same React element multiple times', function () {
var element = __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement("div", null, "element content");
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('before __reactElement__ within __reactElement__', {
reactElement: element
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.be.an('array');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.have.length(4);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[0]).to.equal('before ');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[1]).to.deep.equal(comp);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[2]).to.equal(' within ');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[3]).to.deep.equal(comp);
var elementClone1 = __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread___default()({}, t[1], {
key: null
});
var elementClone2 = __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread___default()({}, t[3], {
key: null
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.be.an('array');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.have.length(4);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t[0]).to.equal('before ');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(elementClone1).to.deep.equal(element);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t[2]).to.equal(' within ');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(elementClone2).to.deep.equal(element);
});
it('should keep HTML entities in translation messages unescaped', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a <__test__>.', {
test: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement('span', null, 'success')
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a <__test__>.', {
test: __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement('span', null, 'success')
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.be.an('array');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t).to.have.length(3);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[0]).to.equal('This is a <');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t[2]).to.equal('>.');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.be.an('array');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t).to.have.length(3);
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t[0]).to.equal('This is a <');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t[2]).to.equal('>.');
});
it('should keep original pattern for missing interpolations', function (done) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('1 __interpolation__ 2')).to.equal('1 __interpolation__ 2');
done();
}).catch(done);
it('should keep original pattern for missing interpolations', function () {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('1 __interpolation__ 2')).to.equal('1 __interpolation__ 2');
});
});
it('should fallback to the translation key, if no translation was found.', function (done) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is not translated')).to.equal('This is not translated');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('de_DE');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is not translated')).to.equal('This is not translated');
done();
}).catch(done);
it('should fallback to the translation key, if no translation was found.', function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is not translated')).to.equal('This is not translated');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["b" /* setLocale */])('de_DE');
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is not translated')).to.equal('This is not translated');
});
});
it('should consider the context option, if provided', function (done) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('de_DE');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('Export')).to.equal('Exportiere');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('Export', {
it('should consider the context option, if provided', function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["b" /* setLocale */])('de_DE');
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('Export')).to.equal('Exportiere');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('Export', {
context: 'button label'
})).to.equal('Exportieren');
done();
}).catch(done);
});
});
it('should use the translation key without any msgctxt, if no msgctxt is provided', function (done) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('de_DE');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_4__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('Export')).to.equal('Exportiere');
done();
}).catch(done);
it('should use the translation key without any msgctxt, if no msgctxt is provided', function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["b" /* setLocale */])('de_DE');
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */]).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('Export')).to.equal('Exportiere');
});
});
it('should resolve plural', function () {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ day', '__count__ days', {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ day', '__count__ days', {
count: 0
});
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ day', '__count__ days', {
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ day', '__count__ days', {
count: 2
});
var t3 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ day', '__count__ days', {
var t3 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ day', '__count__ days', {
count: -2
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t1).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t1).to.equal('0 days');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t2).to.equal('2 days');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t3).to.equal('-2 days');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t1).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t1).to.equal('0 days');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t2).to.equal('2 days');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t3).to.equal('-2 days');
});
it('should resolve singular', function () {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ case', '__count__ cases', {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ case', '__count__ cases', {
count: 1
});
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ case', '__count__ cases', {
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ case', '__count__ cases', {
count: -1
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t1).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t1).to.equal('1 case');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai__["expect"])(t2).to.equal('-1 case');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t1).to.be.a('string');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t1).to.equal('1 case');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(t2).to.equal('-1 case');
});
it('should assign unique keys to all React element interpolations', function () {
var result = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This __button__ is used twice: __button__. __foo__', {
button: __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement('button'),
foo: __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement('span', {
key: 'will-be-overridden'
})
});
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(result[1].key).to.equal('1');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(result[3].key).to.equal('3');
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(result[5].key).to.equal('5');
var resultMarkdown = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('A __button__ and a [link](#foo)', {
button: __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement('button'),
markdown: !0
});
resultMarkdown.forEach(function (element) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(element).to.have.property('key');
});
});
it('should allow defining a custom syntax for interpolations', function () {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["c" /* init */])(getLangLoader, __WEBPACK_IMPORTED_MODULE_0__babel_runtime_helpers_objectSpread___default()({}, __WEBPACK_IMPORTED_MODULE_5__config__["a" /* default */], {
interpolationPattern: '\\{\\{(\\w+)\\}\\}'
})).then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a {{interpolation}}', {
interpolation: 'green test'
})).to.equal('This is a green test');
});
});
});

@@ -783,3 +854,3 @@ });

/***/ }),
/* 11 */
/* 14 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -791,3 +862,3 @@

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_chai___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_chai__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_scripts_config__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_scripts_config__ = __webpack_require__(10);

@@ -816,3 +887,3 @@

/***/ }),
/* 12 */
/* 15 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -822,7 +893,7 @@

Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_child_process__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_child_process__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_child_process___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_child_process__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_fs__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai_files__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai_files__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai_files___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_chai_files__);

@@ -988,3 +1059,56 @@ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_chai__ = __webpack_require__(0);

/***/ }),
/* 13 */
/* 16 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_child_process__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_child_process___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_child_process__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_fs__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai_files__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai_files___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_chai_files__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_chai__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_chai___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_chai__);
var fixtureDir = "".concat(process.cwd(), "/test/fixtures");
var removeIfExists = function removeIfExists(fileName) {
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_fs__["existsSync"])(fileName)) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_fs__["unlinkSync"])(fileName);
}
};
var callForDir = function callForDir(dirName) {
__WEBPACK_IMPORTED_MODULE_0_child_process___default.a.execSync("node ".concat(process.cwd(), "/bin/i18n-update-sources.js \"").concat(dirName, "/indexCopy.js\""));
};
describe('updateSources', function () {
var dir = "".concat(fixtureDir, "/updateSources");
before(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_fs__["copyFileSync"])("".concat(dir, "/de_de.po"), "".concat(dir, "/de_deCopy.po"));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_fs__["copyFileSync"])("".concat(dir, "/en_us.po"), "".concat(dir, "/en_usCopy.po"));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_fs__["copyFileSync"])("".concat(dir, "/index.js"), "".concat(dir, "/indexCopy.js"));
__WEBPACK_IMPORTED_MODULE_0_child_process___default.a.execSync("node ".concat(process.cwd(), "/bin/i18n-update-sources.js -r \"").concat(dir, "/en_usCopy.po\" -p \"").concat(dir, "/*Copy.po\" -s \"").concat(dir, "/indexCopy.js\""));
});
after(function () {
removeIfExists("".concat(dir, "/de_deCopy.po"));
removeIfExists("".concat(dir, "/en_usCopy.po"));
removeIfExists("".concat(dir, "/indexCopy.js"));
});
it('update the msgid in all po files and in the source file', function () {
var messagesEn = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai_files__["file"])("".concat(dir, "/en_usCopy.po"));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(messagesEn).to.contain('msgid "message with a typo"');
var messagesDe = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai_files__["file"])("".concat(dir, "/de_deCopy.po"));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(messagesDe).to.contain('msgid "message with a typo"');
var source = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2_chai_files__["file"])("".concat(dir, "/indexCopy.js"));
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3_chai__["expect"])(source.split('\n')[0]).to.equal("const a = i18n('message with a typo')");
});
});
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

@@ -999,3 +1123,3 @@

__webpack_require__.e/* require.ensure */(1).then((function(require) {
data = __webpack_require__(29);
data = __webpack_require__(31);
var callbacks = cbs;

@@ -1009,3 +1133,3 @@ cbs = null;

/***/ }),
/* 14 */
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

@@ -1020,3 +1144,3 @@

__webpack_require__.e/* require.ensure */(0).then((function(require) {
data = __webpack_require__(30);
data = __webpack_require__(32);
var callbacks = cbs;

@@ -1030,8 +1154,8 @@ cbs = null;

/***/ }),
/* 15 */
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./de_DE.po": 13,
"./en_US.po": 14
"./de_DE.po": 17,
"./en_US.po": 18
};

@@ -1052,66 +1176,54 @@ function webpackContext(req) {

module.exports = webpackContext;
webpackContext.id = 15;
webpackContext.id = 19;
/***/ }),
/* 16 */
/* 20 */
/***/ (function(module, exports) {
module.exports = require("@babel/runtime/helpers/objectSpread");
/***/ }),
/* 17 */
/***/ (function(module, exports) {
module.exports = require("@babel/runtime/helpers/slicedToArray");
/***/ }),
/* 18 */
/* 21 */
/***/ (function(module, exports) {
module.exports = require("@babel/runtime/helpers/typeof");
module.exports = require("lodash/escape");
/***/ }),
/* 19 */
/* 22 */
/***/ (function(module, exports) {
module.exports = require("chai-files");
module.exports = require("lodash/has");
/***/ }),
/* 20 */
/* 23 */
/***/ (function(module, exports) {
module.exports = require("child_process");
module.exports = require("lodash/isFunction");
/***/ }),
/* 21 */
/* 24 */
/***/ (function(module, exports) {
module.exports = require("lodash/escape");
module.exports = require("lodash/isNumber");
/***/ }),
/* 22 */
/* 25 */
/***/ (function(module, exports) {
module.exports = require("lodash/forEach");
module.exports = require("lodash/isPlainObject");
/***/ }),
/* 23 */
/* 26 */
/***/ (function(module, exports) {
module.exports = require("lodash/has");
module.exports = require("lodash/isString");
/***/ }),
/* 24 */
/* 27 */
/***/ (function(module, exports) {
module.exports = require("lodash/isNumber");
/***/ }),
/* 25 */
/***/ (function(module, exports) {
module.exports = require("lodash/pickBy");
/***/ }),
/* 26 */
/* 28 */
/***/ (function(module, exports) {

@@ -1122,3 +1234,3 @@

/***/ }),
/* 27 */
/* 29 */
/***/ (function(module, exports) {

@@ -1129,3 +1241,3 @@

/***/ }),
/* 28 */
/* 30 */
/***/ (function(module, exports) {

@@ -1132,0 +1244,0 @@

@@ -1,2 +0,3 @@

import invariant from 'invariant';
import isFunction from 'lodash/isFunction';
import forEach from 'lodash/forEach';
import createTranslate from './translate';

@@ -8,3 +9,4 @@ var config = {};

var singleton = {
messages: {}
messages: {},
interpolationPattern: '__(\\w+)__'
/**

@@ -34,2 +36,7 @@ * The translate function

config = configObj;
if (config.interpolationPattern) {
singleton.interpolationPattern = configObj.interpolationPattern;
}
return new Promise(loadBundle);

@@ -75,3 +82,2 @@ }

invariant(config, 'could not determine default local due to missing configuration.');
return mapLocale(config.default || 'en_US'); // fall back to default

@@ -109,3 +115,2 @@ }

try {
invariant(typeof getLangLoader === 'function', 'Cannot load a bundle as no valid getLangLoader function has been set');
waitForLangChunk = getLangLoader(forLocale);

@@ -120,7 +125,10 @@ } catch (e) {

function loadBundle(resolve) {
invariant(typeof getLangLoader === 'function', 'Cannot load a bundle as no valid getLangLoader function has been set');
var waitForLangChunk = getLangLoader(locale());
if (!isFunction(getLangLoader)) {
throw new Error('Cannot load a bundle as no valid getLangLoader function has been set');
}
var waitForLangChunk = tryToGetLangLoader(locale());
waitForLangChunk(function (messages) {
singleton.messages = messages;
changeLocaleListeners.forEach(function (listener) {
forEach(changeLocaleListeners, function (listener) {
return listener();

@@ -127,0 +135,0 @@ });

import _objectSpread from "@babel/runtime/helpers/objectSpread";
import _typeof from "@babel/runtime/helpers/typeof";
import _find from "lodash/find";
import _last from "lodash/last";
import _find from "lodash/find";
import gettextParser from 'gettext-parser';
import fs from 'fs';
import gettextParser from 'gettext-parser';
import invariant from 'invariant';
var DEFAULT_FUNCTION_NAME = 'i18n';

@@ -41,7 +39,3 @@ var DEFAULT_FILE_NAME = 'messages.pot';

if (isStringConcatExpr(node)) {
var leftValue = getStringValue(node.left);
var rightValue = getStringValue(node.right);
invariant(leftValue, "Expected a string left value, but got ".concat(_typeof(leftValue), "."));
invariant(rightValue, "Expected a string right value, but got ".concat(_typeof(leftValue), "."));
return leftValue + rightValue;
return getStringValue(node.left) + getStringValue(node.right);
}

@@ -126,5 +120,3 @@

if (base) {
var match = base.match(/^(.*?)\/*$/);
invariant(match, 'Could not validate base directory');
base = "".concat(match[1], "/");
base = "".concat(base.match(/^(.*?)\/*$/)[1], "/");
}

@@ -131,0 +123,0 @@

@@ -0,4 +1,3 @@

import path from 'path';
import fs from 'fs';
import path from 'path';
import invariant from 'invariant';
var I18NRC_FILENAME = '.i18nrc';

@@ -41,4 +40,7 @@ var existsCache = {};

var loc = findConfig(filename);
invariant(loc, 'Could not find .i18nrc');
if (!loc) {
throw new Error('Could not find .i18nrc');
}
if (configCache[loc]) {

@@ -45,0 +47,0 @@ return configCache[loc];

import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import _objectSpread from "@babel/runtime/helpers/objectSpread";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _each from "lodash/each";
import glob from 'glob';
import invariant from 'invariant';
import ProgressBar from 'progress';

@@ -10,3 +10,7 @@ import { transformFileSync } from '@babel/core';

import getConfig from './config';
invariant(process.argv.length >= 3, "Invalid arguments, expected: 'node i18n/scripts/extract.js \"source_file_pattern\"', got: ".concat(process.argv.join(' ')));
if (process.argv.length < 3) {
throw new Error("Invalid arguments, expected: 'node i18n/scripts/extract.js \"source_file_pattern\"', got: ".concat(process.argv.join(' ')));
}
var files = glob.sync(process.argv[2]);

@@ -17,3 +21,4 @@ var progressBar = new ProgressBar(' extracting [:bar] :percent :fileName', {

});
files.forEach(function (fileName) {
_each(files, function (fileName) {
// eslint-disable-next-line no-console

@@ -20,0 +25,0 @@ progressBar.tick(1, {

@@ -0,7 +1,12 @@

import _each from "lodash/each";
import path from 'path';
import { exec } from 'child_process';
import path from 'path';
import invariant from 'invariant';
invariant(process.argv.length >= 4, 'Invalid arguments, expected: `node i18n/scripts/merge.js pot_file po_file ...`');
if (process.argv.length < 4) {
throw new Error('Invalid arguments, expected: `node i18n/scripts/merge.js pot_file po_file ...`');
}
var templatePath = path.resolve(process.cwd(), process.argv[2]);
process.argv.slice(3).forEach(function (fileName) {
_each(process.argv.slice(3), function (fileName) {
exec("msgmerge -o ".concat(fileName, " ").concat(fileName, " ").concat(templatePath), function (error, stdout, stderr) {

@@ -8,0 +13,0 @@ // eslint-disable-next-line no-console

@@ -1,13 +0,12 @@

import _typeof from "@babel/runtime/helpers/typeof";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _objectSpread from "@babel/runtime/helpers/objectSpread";
import invariant from 'invariant';
import escape from 'lodash/escape';
import isString from 'lodash/isString';
import isNumber from 'lodash/isNumber';
import isPlainObject from 'lodash/isPlainObject';
import forEach from 'lodash/forEach';
import pickBy from 'lodash/pickBy';
import has from 'lodash/has';
import isNumber from 'lodash/isNumber';
import pickBy from 'lodash/pickBy';
import escape from 'lodash/escape';
import marked from 'marked';
import React from 'react';
var placeholderRegex = /__(\w+)__/g;
var defaultOptions = {

@@ -23,3 +22,3 @@ markdown: !1

if (!finalOptions && typeof plural !== 'string') {
if (!finalOptions && isPlainObject(finalPlural)) {
finalOptions = plural;

@@ -42,6 +41,5 @@ finalPlural = undefined;

if (finalPlural && needsPlural(finalOptions)) {
invariant(typeof finalPlural === 'string', "Expted plural to be a string but was ".concat(_typeof(finalPlural)));
translation = translatedPlural && typeof translatedPlural === 'string' ? translatedPlural : finalPlural;
translation = translatedPlural && isString(translatedPlural) ? translatedPlural : finalPlural;
} else {
translation = translatedSingular && typeof translatedSingular === 'string' ? translatedSingular : text;
translation = translatedSingular && isString(translatedSingular) ? translatedSingular : text;
} // apply markdown processing if necessary

@@ -60,95 +58,100 @@

};
});
function needsPlural(options) {
return isNumber(options.count) && Math.abs(options.count) !== 1;
}
function needsPlural(options) {
return isNumber(options.count) && Math.abs(options.count) !== 1;
}
function isWrappedInPTag(translation) {
return translation.lastIndexOf('<p>') === 0 && translation.indexOf('</p>') === translation.length - 5;
}
function applyMarkdown(translation) {
// Escape underscores.
// (Since we use underscores to denote interpolations, we have to
// exclude them from the markdown notation. Use asterisk (*) instead.)
var finalTranslation = marked(translation.replace(/_/g, '\\_')); // remove single, outer wrapping <p>-tag
if (isWrappedInPTag(finalTranslation)) {
// last occurrence of <p> is at the start, first occurence of </p> is a the very end
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5);
function isWrappedInPTag(translation) {
return translation.lastIndexOf('<p>') === 0 && translation.indexOf('</p>') === translation.length - 5;
}
return finalTranslation.replace(/\\_/g, '_');
}
function applyMarkdown(translation) {
// Escape underscores.
// (Since we use underscores to denote interpolations, we have to
// exclude them from the markdown notation. Use asterisk (*) instead.)
var finalTranslation = marked(translation.replace(/_/g, '\\_')); // remove single, outer wrapping <p>-tag
function htmlStringToReactComponent(html) {
// eslint-disable-next-line react/no-danger
return React.createElement("span", {
dangerouslySetInnerHTML: {
__html: html
if (isWrappedInPTag(finalTranslation)) {
// last occurrence of <p> is at the start, first occurrence of </p> is a the very end
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5);
}
});
}
function insertInterpolations(translation, options) {
var regularInterpolations = pickBy(options, function (val, key) {
return !has(defaultOptions, key) && !React.isValidElement(val);
});
var finalTranslation = translation;
forEach(regularInterpolations, function (val, key) {
finalTranslation = finalTranslation.replace(new RegExp("__".concat(key, "__"), 'g'), options.markdown ? escape(val) : val // only escape options when using markdown
);
});
return finalTranslation;
}
return finalTranslation.replace(/\\_/g, '_');
}
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
function htmlStringToReactComponent(html, _ref) {
var key = _ref.key;
// eslint-disable-next-line react/no-danger
return React.createElement("span", {
key: key,
dangerouslySetInnerHTML: {
__html: html
}
});
}
while ((match = placeholderRegex.exec(translation)) !== null) {
if (!match) {
break;
}
function insertInterpolations(translation, options) {
var regularInterpolations = pickBy(options, function (val, key) {
return !has(defaultOptions, key) && !React.isValidElement(val);
});
var finalTranslation = translation;
forEach(regularInterpolations, function (val, key) {
finalTranslation = finalTranslation.replace(new RegExp(singleton.interpolationPattern.replace('(\\w+)', key), 'g'), options.markdown ? escape(val) : val // only escape options when using markdown
);
});
return finalTranslation;
}
var key = match[1];
var component = options[key];
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
var interpolationRegExp = new RegExp(singleton.interpolationPattern, 'g');
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
}
while ((match = interpolationRegExp.exec(translation)) !== null) {
var key = match[1];
var component = options[key];
if (React.isValidElement(component)) {
result.push(result.indexOf(component) >= 0 ? React.cloneElement(component) : component);
} else {
// no interpolation specified, leave the placeholder unchanged
result.push(match[0]);
}
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
}
start = placeholderRegex.lastIndex;
} // append part after last match
if (React.isValidElement(component)) {
result.push(React.cloneElement(component, {
key: result.length
}));
} else {
// no interpolation specified, leave the placeholder unchanged
result.push(match[0]);
}
start = interpolationRegExp.lastIndex;
} // append part after last match
if (start < translation.length) {
substr = translation.substring(start);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
} // re-concatenate all string elements
if (start < translation.length) {
substr = translation.substring(start);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
} // re-concatenate all string elements
return result.reduce(function (acc, element) {
var lastAccumulatedElement = acc[acc.length - 1];
if (typeof element === 'string' && typeof lastAccumulatedElement === 'string') {
// eslint-disable-next-line no-param-reassign
acc[acc.length - 1] = lastAccumulatedElement + element;
} else {
acc.push(element);
}
return result.reduce(function (acc, element) {
var lastAccumulatedElement = acc[acc.length - 1];
return acc;
}, []);
}
if (isString(element) && isString(lastAccumulatedElement)) {
// eslint-disable-next-line no-param-reassign
acc[acc.length - 1] = lastAccumulatedElement + element;
} else {
acc.push(element);
}
return acc;
}, []);
}
});

@@ -16,4 +16,6 @@ "use strict";

var _invariant = _interopRequireDefault(require("invariant"));
var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
var _forEach = _interopRequireDefault(require("lodash/forEach"));
var _translate = _interopRequireDefault(require("./translate"));

@@ -26,3 +28,4 @@

var singleton = {
messages: {}
messages: {},
interpolationPattern: '__(\\w+)__'
/**

@@ -54,2 +57,7 @@ * The translate function

config = configObj;
if (config.interpolationPattern) {
singleton.interpolationPattern = configObj.interpolationPattern;
}
return new Promise(loadBundle);

@@ -97,3 +105,2 @@ }

(0, _invariant.default)(config, 'could not determine default local due to missing configuration.');
return mapLocale(config.default || 'en_US'); // fall back to default

@@ -134,3 +141,2 @@ }

try {
(0, _invariant.default)(typeof getLangLoader === 'function', 'Cannot load a bundle as no valid getLangLoader function has been set');
waitForLangChunk = getLangLoader(forLocale);

@@ -145,7 +151,10 @@ } catch (e) {

function loadBundle(resolve) {
(0, _invariant.default)(typeof getLangLoader === 'function', 'Cannot load a bundle as no valid getLangLoader function has been set');
var waitForLangChunk = getLangLoader(locale());
if (!(0, _isFunction.default)(getLangLoader)) {
throw new Error('Cannot load a bundle as no valid getLangLoader function has been set');
}
var waitForLangChunk = tryToGetLangLoader(locale());
waitForLangChunk(function (messages) {
singleton.messages = messages;
changeLocaleListeners.forEach(function (listener) {
(0, _forEach.default)(changeLocaleListeners, function (listener) {
return listener();

@@ -152,0 +161,0 @@ });

@@ -12,14 +12,10 @@ "use strict";

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _find2 = _interopRequireDefault(require("lodash/find"));
var _last2 = _interopRequireDefault(require("lodash/last"));
var _find2 = _interopRequireDefault(require("lodash/find"));
var _gettextParser = _interopRequireDefault(require("gettext-parser"));
var _fs = _interopRequireDefault(require("fs"));
var _gettextParser = _interopRequireDefault(require("gettext-parser"));
var _invariant = _interopRequireDefault(require("invariant"));
var DEFAULT_FUNCTION_NAME = 'i18n';

@@ -58,7 +54,3 @@ var DEFAULT_FILE_NAME = 'messages.pot';

if (isStringConcatExpr(node)) {
var leftValue = getStringValue(node.left);
var rightValue = getStringValue(node.right);
(0, _invariant.default)(leftValue, "Expected a string left value, but got ".concat((0, _typeof2.default)(leftValue), "."));
(0, _invariant.default)(rightValue, "Expected a string right value, but got ".concat((0, _typeof2.default)(leftValue), "."));
return leftValue + rightValue;
return getStringValue(node.left) + getStringValue(node.right);
}

@@ -144,5 +136,3 @@

if (base) {
var match = base.match(/^(.*?)\/*$/);
(0, _invariant.default)(match, 'Could not validate base directory');
base = "".concat(match[1], "/");
base = "".concat(base.match(/^(.*?)\/*$/)[1], "/");
}

@@ -149,0 +139,0 @@

@@ -10,7 +10,5 @@ "use strict";

var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _invariant = _interopRequireDefault(require("invariant"));
var _fs = _interopRequireDefault(require("fs"));

@@ -54,4 +52,7 @@ var I18NRC_FILENAME = '.i18nrc';

var loc = findConfig(filename);
(0, _invariant.default)(loc, 'Could not find .i18nrc');
if (!loc) {
throw new Error('Could not find .i18nrc');
}
if (configCache[loc]) {

@@ -58,0 +59,0 @@ return configCache[loc];

@@ -11,6 +11,6 @@ "use strict";

var _each2 = _interopRequireDefault(require("lodash/each"));
var _glob = _interopRequireDefault(require("glob"));
var _invariant = _interopRequireDefault(require("invariant"));
var _progress = _interopRequireDefault(require("progress"));

@@ -24,3 +24,5 @@

(0, _invariant.default)(process.argv.length >= 3, "Invalid arguments, expected: 'node i18n/scripts/extract.js \"source_file_pattern\"', got: ".concat(process.argv.join(' ')));
if (process.argv.length < 3) {
throw new Error("Invalid arguments, expected: 'node i18n/scripts/extract.js \"source_file_pattern\"', got: ".concat(process.argv.join(' ')));
}

@@ -33,3 +35,3 @@ var files = _glob.default.sync(process.argv[2]);

});
files.forEach(function (fileName) {
(0, _each2.default)(files, function (fileName) {
// eslint-disable-next-line no-console

@@ -36,0 +38,0 @@ progressBar.tick(1, {

@@ -5,13 +5,15 @@ "use strict";

var _child_process = require("child_process");
var _each2 = _interopRequireDefault(require("lodash/each"));
var _path = _interopRequireDefault(require("path"));
var _invariant = _interopRequireDefault(require("invariant"));
var _child_process = require("child_process");
(0, _invariant.default)(process.argv.length >= 4, 'Invalid arguments, expected: `node i18n/scripts/merge.js pot_file po_file ...`');
if (process.argv.length < 4) {
throw new Error('Invalid arguments, expected: `node i18n/scripts/merge.js pot_file po_file ...`');
}
var templatePath = _path.default.resolve(process.cwd(), process.argv[2]);
process.argv.slice(3).forEach(function (fileName) {
(0, _each2.default)(process.argv.slice(3), function (fileName) {
(0, _child_process.exec)("msgmerge -o ".concat(fileName, " ").concat(fileName, " ").concat(templatePath), function (error, stdout, stderr) {

@@ -18,0 +20,0 @@ // eslint-disable-next-line no-console

@@ -10,4 +10,2 @@ "use strict";

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

@@ -17,14 +15,16 @@

var _invariant = _interopRequireDefault(require("invariant"));
var _isString = _interopRequireDefault(require("lodash/isString"));
var _escape = _interopRequireDefault(require("lodash/escape"));
var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
var _forEach = _interopRequireDefault(require("lodash/forEach"));
var _pickBy = _interopRequireDefault(require("lodash/pickBy"));
var _has = _interopRequireDefault(require("lodash/has"));
var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
var _escape = _interopRequireDefault(require("lodash/escape"));
var _pickBy = _interopRequireDefault(require("lodash/pickBy"));
var _marked = _interopRequireDefault(require("marked"));

@@ -34,3 +34,2 @@

var placeholderRegex = /__(\w+)__/g;
var defaultOptions = {

@@ -47,3 +46,3 @@ markdown: !1

if (!finalOptions && typeof plural !== 'string') {
if (!finalOptions && (0, _isPlainObject.default)(finalPlural)) {
finalOptions = plural;

@@ -66,6 +65,5 @@ finalPlural = undefined;

if (finalPlural && needsPlural(finalOptions)) {
(0, _invariant.default)(typeof finalPlural === 'string', "Expted plural to be a string but was ".concat((0, _typeof2.default)(finalPlural)));
translation = translatedPlural && typeof translatedPlural === 'string' ? translatedPlural : finalPlural;
translation = translatedPlural && (0, _isString.default)(translatedPlural) ? translatedPlural : finalPlural;
} else {
translation = translatedSingular && typeof translatedSingular === 'string' ? translatedSingular : text;
translation = translatedSingular && (0, _isString.default)(translatedSingular) ? translatedSingular : text;
} // apply markdown processing if necessary

@@ -84,97 +82,102 @@

};
};
exports.default = _default;
function needsPlural(options) {
return (0, _isNumber.default)(options.count) && Math.abs(options.count) !== 1;
}
function needsPlural(options) {
return (0, _isNumber.default)(options.count) && Math.abs(options.count) !== 1;
}
function isWrappedInPTag(translation) {
return translation.lastIndexOf('<p>') === 0 && translation.indexOf('</p>') === translation.length - 5;
}
function isWrappedInPTag(translation) {
return translation.lastIndexOf('<p>') === 0 && translation.indexOf('</p>') === translation.length - 5;
}
function applyMarkdown(translation) {
// Escape underscores.
// (Since we use underscores to denote interpolations, we have to
// exclude them from the markdown notation. Use asterisk (*) instead.)
var finalTranslation = (0, _marked.default)(translation.replace(/_/g, '\\_')); // remove single, outer wrapping <p>-tag
function applyMarkdown(translation) {
// Escape underscores.
// (Since we use underscores to denote interpolations, we have to
// exclude them from the markdown notation. Use asterisk (*) instead.)
var finalTranslation = (0, _marked.default)(translation.replace(/_/g, '\\_')); // remove single, outer wrapping <p>-tag
if (isWrappedInPTag(finalTranslation)) {
// last occurrence of <p> is at the start, first occurrence of </p> is a the very end
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5);
}
if (isWrappedInPTag(finalTranslation)) {
// last occurrence of <p> is at the start, first occurence of </p> is a the very end
finalTranslation = finalTranslation.substring(3, finalTranslation.length - 5);
return finalTranslation.replace(/\\_/g, '_');
}
return finalTranslation.replace(/\\_/g, '_');
}
function htmlStringToReactComponent(html, _ref) {
var key = _ref.key;
// eslint-disable-next-line react/no-danger
return _react.default.createElement("span", {
key: key,
dangerouslySetInnerHTML: {
__html: html
}
});
}
function htmlStringToReactComponent(html) {
// eslint-disable-next-line react/no-danger
return _react.default.createElement("span", {
dangerouslySetInnerHTML: {
__html: html
}
});
}
function insertInterpolations(translation, options) {
var regularInterpolations = (0, _pickBy.default)(options, function (val, key) {
return !(0, _has.default)(defaultOptions, key) && !_react.default.isValidElement(val);
});
var finalTranslation = translation;
(0, _forEach.default)(regularInterpolations, function (val, key) {
finalTranslation = finalTranslation.replace(new RegExp(singleton.interpolationPattern.replace('(\\w+)', key), 'g'), options.markdown ? (0, _escape.default)(val) : val // only escape options when using markdown
);
});
return finalTranslation;
}
function insertInterpolations(translation, options) {
var regularInterpolations = (0, _pickBy.default)(options, function (val, key) {
return !(0, _has.default)(defaultOptions, key) && !_react.default.isValidElement(val);
});
var finalTranslation = translation;
(0, _forEach.default)(regularInterpolations, function (val, key) {
finalTranslation = finalTranslation.replace(new RegExp("__".concat(key, "__"), 'g'), options.markdown ? (0, _escape.default)(val) : val // only escape options when using markdown
);
});
return finalTranslation;
}
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
var interpolationRegExp = new RegExp(singleton.interpolationPattern, 'g');
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
while ((match = interpolationRegExp.exec(translation)) !== null) {
var key = match[1];
var component = options[key];
while ((match = placeholderRegex.exec(translation)) !== null) {
if (!match) {
break;
}
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
}
var key = match[1];
var component = options[key];
if (_react.default.isValidElement(component)) {
result.push(_react.default.cloneElement(component, {
key: result.length
}));
} else {
// no interpolation specified, leave the placeholder unchanged
result.push(match[0]);
}
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
}
start = interpolationRegExp.lastIndex;
} // append part after last match
if (_react.default.isValidElement(component)) {
result.push(result.indexOf(component) >= 0 ? _react.default.cloneElement(component) : component);
} else {
// no interpolation specified, leave the placeholder unchanged
result.push(match[0]);
}
start = placeholderRegex.lastIndex;
} // append part after last match
if (start < translation.length) {
substr = translation.substring(start);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
} // re-concatenate all string elements
if (start < translation.length) {
substr = translation.substring(start);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
} // re-concatenate all string elements
return result.reduce(function (acc, element) {
var lastAccumulatedElement = acc[acc.length - 1];
if ((0, _isString.default)(element) && (0, _isString.default)(lastAccumulatedElement)) {
// eslint-disable-next-line no-param-reassign
acc[acc.length - 1] = lastAccumulatedElement + element;
} else {
acc.push(element);
}
return result.reduce(function (acc, element) {
var lastAccumulatedElement = acc[acc.length - 1];
return acc;
}, []);
}
};
if (typeof element === 'string' && typeof lastAccumulatedElement === 'string') {
// eslint-disable-next-line no-param-reassign
acc[acc.length - 1] = lastAccumulatedElement + element;
} else {
acc.push(element);
}
return acc;
}, []);
}
exports.default = _default;
{
"name": "signavio-i18n",
"version": "2.1.0-1",
"version": "2.1.0",
"description": "Minimalist gettext style i18n for JavaScript",

@@ -20,7 +20,7 @@ "main": "lib/index.js",

"build:es6": "cross-env NODE_ENV=production BABEL_ENV=es6 babel src --out-dir lib-es6",
"postbuild": "flow-copy-source src lib && flow-copy-source src lib-es6",
"clean": "rimraf lib lib-es6",
"coverage": "cross-env NODE_ENV=coverage nyc --reporter=lcov --reporter=text yarn test",
"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",

@@ -48,3 +48,2 @@ "pretest": "yarn build",

"glob": "^6.0.1",
"invariant": "^2.2.4",
"lodash": "^4.0.0",

@@ -73,2 +72,3 @@ "marked": "^0.3.5",

"ajv": "^6.1.1",
"babel-eslint": "9.x",
"babel-loader": "^8.0.0",

@@ -87,18 +87,22 @@ "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-mocha": "^4.7.0",
"flow-bin": "0.100.0",
"flow-copy-source": "2.0.6",
"eslint-plugin-flowtype": "2.x",
"eslint-plugin-import": "2.x",
"eslint-plugin-jsx-a11y": "6.x",
"eslint-plugin-mocha": "^6.2.1",
"eslint-plugin-react": "7.x",
"flow-bin": "^0.65.0",
"istanbul-instrumenter-loader": "^2.0.0",
"jsdom": "^9.12.0",
"json-loader": "^0.5.3",
"mocha": "^2.5.3",
"mocha-webpack": "^0.7.0",
"mocha": "^4.0.1",
"mocha-webpack": "^1.1.0",
"nyc": "^10.3.2",
"po-loader": "^0.3.1",
"po2json": "^0.4.2",
"prettier": "1.17.1",
"prettier": "^1.15.3",
"react": "^16.2.0",

@@ -109,3 +113,2 @@ "react-dom": "^16.2.0",

"webpack": "2.3.2",
"webpack-dev-server": "2.4.2",
"webpack-node-externals": "^1.5.4",

@@ -112,0 +115,0 @@ "xunit-file": "^1.0.0"

@@ -10,7 +10,7 @@ # signavio-i18n

* [Supports React components as interpolations](#interpolations)
* [Pluralization support](#pluralization) (ngettext style)
* [markdown support](#markdown)
* Compatible with [webpack po-loader](https://github.com/perchlayer/po-loader)
* Comes with scripts for extracting translation strings from JavaScript (Babel) sources and updating .pot and .po files
- [Supports React components as interpolations](#interpolations)
- [Pluralization support](#pluralization) (ngettext style)
- [markdown support](#markdown)
- Compatible with [webpack po-loader](https://github.com/perchlayer/po-loader)
- Comes with scripts for extracting translation strings from JavaScript (Babel) sources and updating .pot and .po files

@@ -30,6 +30,4 @@ ## Installation

"scripts": {
"i18n-init":
"cd src/locales && msginit --no-translator --input messages.pot --locale",
"i18n":
"i18n-extract \"src/**/*.js\" src/locales/messages.pot && i18n-merge src/locales/messages.pot src/locales/*.po"
"i18n-init": "cd src/locales && msginit --no-translator --input messages.pot --locale",
"i18n": "i18n-extract \"src/**/*.js\" src/locales/messages.pot && i18n-merge src/locales/messages.pot src/locales/*.po"
}

@@ -86,2 +84,4 @@ }

},
// optional regular expression pattern for custom interpolation syntax
interpolationPattern: '__(\\w+)__', // this is the default value
}

@@ -123,2 +123,10 @@

The default syntax for interpolations is a group of characters or numbers (`\w+`) wrapped in double underscores (`__`). If you require a different syntax this can be customized using the init option `interpolationPattern`. Internally, pattern value will be used to create a regular expression for matching interpolation placeholder like this:
```
new RegExp(interpolationPattern, 'g')
```
It must contain a capturing group (`(\w+)`) for capturing the interpolation key.
### Pluralization

@@ -160,3 +168,2 @@

[build-badge]: https://circleci.com/gh/signavio/i18n/tree/master.svg?style=shield&circle-token=:circle-token

@@ -163,0 +170,0 @@ [build]: https://circleci.com/gh/signavio/i18n/tree/master

// 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

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