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

signavio-i18n

Package Overview
Dependencies
Maintainers
4
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 to 2.1.1

2

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

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

exports.ids = [1];
exports.modules = {
/***/ 31:
/***/ 29:
/***/ (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 = 8);
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ })

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

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

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

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

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

module.exports = require("chai-files");
module.exports = require("react");
/***/ }),
/* 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");
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./specs/i18n.spec.js": 13,
"./specs/scripts/config.spec.js": 14,
"./specs/scripts/extract.spec.js": 15,
"./specs/scripts/updateSources.spec.js": 16
"./specs/i18n.spec.js": 10,
"./specs/scripts/config.spec.js": 11,
"./specs/scripts/extract.spec.js": 12
};

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

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

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

/***/ }),
/* 9 */
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* 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 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 export (immutable) */ __webpack_exports__["c"] = init;

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

var config = {};

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

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

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

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

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

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

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

__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

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

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);

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

function loadBundle(resolve) {
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());
__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());
waitForLangChunk(function (messages) {
singleton.messages = messages;
__WEBPACK_IMPORTED_MODULE_1_lodash_forEach___default()(changeLocaleListeners, function (listener) {
changeLocaleListeners.forEach(function (listener) {
return listener();

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

/***/ }),
/* 10 */
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* 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 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 export (immutable) */ __webpack_exports__["a"] = getConfig;
var I18NRC_FILENAME = '.i18nrc';

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

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

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

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

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

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

@@ -390,7 +364,4 @@ 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]) {

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

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

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

/***/ }),
/* 11 */
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* 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_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_5_lodash_forEach___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_lodash_forEach__);
/* 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_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_9_marked___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9_marked__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_react__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_react__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_react__);

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

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

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

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

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

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

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

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

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

if (finalPlural && needsPlural(finalOptions)) {
translation = translatedPlural && __WEBPACK_IMPORTED_MODULE_2_lodash_isString___default()(translatedPlural) ? translatedPlural : finalPlural;
__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;
} else {
translation = translatedSingular && __WEBPACK_IMPORTED_MODULE_2_lodash_isString___default()(translatedSingular) ? translatedSingular : text;
translation = translatedSingular && typeof translatedSingular === 'string' ? translatedSingular : text;
} // apply markdown processing if necessary

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

};
});
function needsPlural(options) {
return __WEBPACK_IMPORTED_MODULE_3_lodash_isNumber___default()(options.count) && Math.abs(options.count) !== 1;
}
function needsPlural(options) {
return __WEBPACK_IMPORTED_MODULE_7_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 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 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
return finalTranslation.replace(/\\_/g, '_');
}
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 htmlStringToReactComponent(html) {
// eslint-disable-next-line react/no-danger
return __WEBPACK_IMPORTED_MODULE_10_react___default.a.createElement("span", {
dangerouslySetInnerHTML: {
__html: html
}
});
}
return finalTranslation.replace(/\\_/g, '_');
}
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;
}
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
}
});
}
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
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;
}
while ((match = placeholderRegex.exec(translation)) !== null) {
if (!match) {
break;
}
function insertReactComponentInterpolations(translation, options) {
var result = [];
var match;
var substr;
var start = 0;
var interpolationRegExp = new RegExp(singleton.interpolationPattern, 'g');
var key = match[1];
var component = options[key];
while ((match = interpolationRegExp.exec(translation)) !== null) {
var key = match[1];
var component = options[key];
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr) : substr);
}
if (match.index > 0) {
substr = translation.substring(start, match.index);
result.push(options.markdown ? htmlStringToReactComponent(substr, {
key: result.length
}) : substr);
}
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 (__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 = placeholderRegex.lastIndex;
} // append part after last match
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];
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);
}
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;
}, []);
}
return acc;
}, []);
}
});
/***/ }),
/* 12 */
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

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

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

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

Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* 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);
/* 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);

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

function getLangLoader(locale) {

@@ -648,23 +613,24 @@ // 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__(19)("./" + locale + '.po');
return __webpack_require__(15)("./" + locale + '.po');
}
describe('i18n', function () {
beforeEach(__WEBPACK_IMPORTED_MODULE_4__src__["a" /* reset */]);
beforeEach(__WEBPACK_IMPORTED_MODULE_3__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_4__src__["b" /* setLocale */])('de_DE'); // return a promise and use mocha's built in promises support
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["b" /* setLocale */])('de_DE'); // return a promise and use mocha's built in promises support
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');
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');
});
});
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
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
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');
__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();
});

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

it('should return a plain string whenever possible', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a __test__.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a __test__.', {
test: '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.');
__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.');
});
it('should not escape interpolations', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a __test__.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a __test__.', {
test: '<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>.');
__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>.');
});
it('should support using Markdown in translation messages', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a **__test__**.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a **__test__**.', {
test: 'success',
markdown: !0
});
__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>');
__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>');
});
it('should correctly escape interpolations when used with Markdown', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is a **__test__**.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is a **__test__**.', {
test: '<success>',
markdown: !0
});
__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>');
__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>');
});
it('should not replace "__markdown__" placeholders', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('This is __markdown__.', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('This is __markdown__.', {
markdown: !0
});
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>');
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>');
});
it.skip('should not be possible to break Markdown from interpolations', function () {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('**__foo__**', {
var t = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('**__foo__**', {
foo: 'bar** baz **baa',
markdown: !0
});
__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>');
__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>');
});
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
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
});
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');
__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');
});
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
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
});
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);
__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);
});
it('should keep HTML entities in translation messages unescaped', function () {
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')
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')
});
__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('>.');
__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('>.');
});
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 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 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 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 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', {
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', {
context: 'button label'
})).to.equal('Exportieren');
});
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 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 resolve plural', function () {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ day', '__count__ days', {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ day', '__count__ days', {
count: 0
});
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ day', '__count__ days', {
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ day', '__count__ days', {
count: 2
});
var t3 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ day', '__count__ days', {
var t3 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ day', '__count__ days', {
count: -2
});
__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');
__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');
});
it('should resolve singular', function () {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ case', '__count__ cases', {
var t1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ case', '__count__ cases', {
count: 1
});
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__src__["d" /* default */])('__count__ case', '__count__ cases', {
var t2 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__src__["d" /* default */])('__count__ case', '__count__ cases', {
count: -1
});
__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');
__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');
});
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');
});
});
});

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

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

@@ -862,3 +791,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__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_scripts_config__ = __webpack_require__(7);

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

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

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

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__ = __webpack_require__(20);
/* 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__ = __webpack_require__(2);
/* 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__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_chai_files___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_chai_files__);

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

/***/ }),
/* 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 */
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

import _each from "lodash/each";
import _toArray from "@babel/runtime/helpers/toArray";
import { exec } from 'child_process';
import path from 'path';
import { exec } from 'child_process';

@@ -9,6 +9,19 @@ if (process.argv.length < 4) {

var templatePath = path.resolve(process.cwd(), process.argv[2]);
var _process$argv = _toArray(process.argv),
cliArguments = _process$argv.slice(2);
_each(process.argv.slice(3), function (fileName) {
exec("msgmerge -o ".concat(fileName, " ").concat(fileName, " ").concat(templatePath), function (error, stdout, stderr) {
var flags = [];
var files = [];
cliArguments.forEach(function (arg) {
if (arg.startsWith('-')) {
flags.push(arg);
} else {
files.push(arg);
}
});
var potFile = files[0],
poFiles = files.slice(1);
var templatePath = path.resolve(process.cwd(), potFile);
poFiles.forEach(function (fileName) {
exec("msgmerge ".concat(flags.join(' '), " -o ").concat(fileName, " ").concat(fileName, " ").concat(templatePath), function (error, stdout, stderr) {
// eslint-disable-next-line no-console

@@ -15,0 +28,0 @@ if (error) {}

@@ -5,8 +5,8 @@ "use strict";

var _each2 = _interopRequireDefault(require("lodash/each"));
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
var _child_process = require("child_process");
var _path = _interopRequireDefault(require("path"));
var _child_process = require("child_process");
if (process.argv.length < 4) {

@@ -16,6 +16,21 @@ 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]);
var _process$argv = (0, _toArray2.default)(process.argv),
cliArguments = _process$argv.slice(2);
(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) {
var flags = [];
var files = [];
cliArguments.forEach(function (arg) {
if (arg.startsWith('-')) {
flags.push(arg);
} else {
files.push(arg);
}
});
var potFile = files[0],
poFiles = files.slice(1);
var templatePath = _path.default.resolve(process.cwd(), potFile);
poFiles.forEach(function (fileName) {
(0, _child_process.exec)("msgmerge ".concat(flags.join(' '), " -o ").concat(fileName, " ").concat(fileName, " ").concat(templatePath), function (error, stdout, stderr) {
// eslint-disable-next-line no-console

@@ -22,0 +37,0 @@ if (error) {}

{
"name": "signavio-i18n",
"version": "2.1.0",
"version": "2.1.1",
"description": "Minimalist gettext style i18n for JavaScript",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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