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

react-i18next

Package Overview
Dependencies
Maintainers
2
Versions
316
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18next - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### 1.8.0
- allows to set a className on interpolate component
- update all dependencies and devDependencies
### 1.7.0

@@ -2,0 +6,0 @@ - add option to change t function name to something else [PR196](https://github.com/i18next/react-i18next/pull/196)

10

dist/commonjs/interpolate.js

@@ -43,2 +43,3 @@ 'use strict';

var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
var className = this.props.className;

@@ -58,3 +59,3 @@ // Set to true if you want to use raw HTML in translation values

format.split(REGEXP).reduce(function (memo, match, index) {
var child;
var child = void 0;

@@ -77,3 +78,3 @@ if (index % 2 === 0) {

return _react2.default.createElement.apply(this, [parent, null].concat(children));
return _react2.default.createElement.apply(this, [parent, { className: className }].concat(children));
}

@@ -85,2 +86,7 @@ }]);

Interpolate.propTypes = {
children: _react.PropTypes.node,
className: _react.PropTypes.string
};
Interpolate.contextTypes = {

@@ -87,0 +93,0 @@ i18n: _react.PropTypes.object.isRequired,

@@ -33,2 +33,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
var className = this.props.className;

@@ -48,3 +49,3 @@ // Set to true if you want to use raw HTML in translation values

format.split(REGEXP).reduce(function (memo, match, index) {
var child;
var child = void 0;

@@ -67,3 +68,3 @@ if (index % 2 === 0) {

return React.createElement.apply(this, [parent, null].concat(children));
return React.createElement.apply(this, [parent, { className: className }].concat(children));
}

@@ -75,2 +76,7 @@ }]);

Interpolate.propTypes = {
children: PropTypes.node,
className: PropTypes.string
};
Interpolate.contextTypes = {

@@ -77,0 +83,0 @@ i18n: PropTypes.object.isRequired,

@@ -5,486 +5,496 @@ (function (global, factory) {

(factory((global.reactI18next = global.reactI18next || {}),global.React));
}(this, function (exports,React) { 'use strict';
}(this, (function (exports,React) { 'use strict';
var React__default = 'default' in React ? React['default'] : React;
var React__default = 'default' in React ? React['default'] : React;
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
function interopDefault(ex) {
return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex;
}
var index = createCommonjsModule(function (module) {
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var REACT_STATICS = {
childContextTypes: true,
contextTypes: true,
defaultProps: true,
displayName: true,
getDefaultProps: true,
mixins: true,
propTypes: true,
type: true
};
var index = createCommonjsModule(function (module) {
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
var KNOWN_STATICS = {
name: true,
length: true,
prototype: true,
caller: true,
arguments: true,
arity: true
};
var REACT_STATICS = {
childContextTypes: true,
contextTypes: true,
defaultProps: true,
displayName: true,
getDefaultProps: true,
mixins: true,
propTypes: true,
type: true
};
var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function';
var KNOWN_STATICS = {
name: true,
length: true,
prototype: true,
caller: true,
arguments: true,
arity: true
};
module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) {
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
var keys = Object.getOwnPropertyNames(sourceComponent);
var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function';
/* istanbul ignore else */
if (isGetOwnPropertySymbolsAvailable) {
keys = keys.concat(Object.getOwnPropertySymbols(sourceComponent));
}
module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) {
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
var keys = Object.getOwnPropertyNames(sourceComponent);
for (var i = 0; i < keys.length; ++i) {
if (!REACT_STATICS[keys[i]] && !KNOWN_STATICS[keys[i]] && (!customStatics || !customStatics[keys[i]])) {
try {
targetComponent[keys[i]] = sourceComponent[keys[i]];
} catch (error) {
/* istanbul ignore else */
if (isGetOwnPropertySymbolsAvailable) {
keys = keys.concat(Object.getOwnPropertySymbols(sourceComponent));
}
}
}
}
}
for (var i = 0; i < keys.length; ++i) {
if (!REACT_STATICS[keys[i]] && !KNOWN_STATICS[keys[i]] && (!customStatics || !customStatics[keys[i]])) {
try {
targetComponent[keys[i]] = sourceComponent[keys[i]];
} catch (error) {
return targetComponent;
};
});
}
}
}
}
var hoistStatics = (index && typeof index === 'object' && 'default' in index ? index['default'] : index);
return targetComponent;
};
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var hoistStatics = interopDefault(index);
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
return obj;
};
var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
return obj;
};
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
return target;
};
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
return target;
};
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
return _arr;
}
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
return _arr;
}
function getDisplayName(component) {
return component.displayName || component.name || 'Component';
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
function translate(namespaces) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _options$withRef = options.withRef;
var withRef = _options$withRef === undefined ? false : _options$withRef;
var _options$wait = options.wait;
var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
function getDisplayName(component) {
return component.displayName || component.name || 'Component';
}
function translate(namespaces) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _options$withRef = options.withRef;
var withRef = _options$withRef === undefined ? false : _options$withRef;
var _options$wait = options.wait;
var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
return function Wrapper(WrappedComponent) {
var Translate = function (_Component) {
inherits(Translate, _Component);
function Translate(props, context) {
classCallCheck(this, Translate);
return function Wrapper(WrappedComponent) {
var Translate = function (_Component) {
inherits(Translate, _Component);
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Translate).call(this, props, context));
function Translate(props, context) {
classCallCheck(this, Translate);
_this.i18n = context.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Translate).call(this, props, context));
_this.state = {
i18nLoadedAt: null,
ready: false
};
_this.i18n = context.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;
_this.onI18nChanged = _this.onI18nChanged.bind(_this);
return _this;
}
_this.state = {
i18nLoadedAt: null,
ready: false
};
createClass(Translate, [{
key: 'getChildContext',
value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
_this.onI18nChanged = _this.onI18nChanged.bind(_this);
return _this;
}
this.mounted = true;
this.i18n.loadNamespaces(namespaces, function () {
if (_this2.mounted) _this2.setState({ ready: true });
});
this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.mounted = false;
if (this.onI18nChanged) {
this.i18n.off('languageChanged', this.onI18nChanged);
this.i18n.off('loaded', this.onI18nChanged);
this.i18n.store.off('added', this.onI18nChanged);
this.i18n.store.off('removed', this.onI18nChanged);
}
}
}, {
key: 'onI18nChanged',
value: function onI18nChanged() {
if (!this.mounted) return;
createClass(Translate, [{
key: 'getChildContext',
value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
this.setState({ i18nLoadedAt: new Date() });
}
}, {
key: 'getWrappedInstance',
value: function getWrappedInstance() {
if (!withRef) {
// eslint-disable-next-line no-console
console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');
}
this.mounted = true;
this.i18n.loadNamespaces(namespaces, function () {
if (_this2.mounted) _this2.setState({ ready: true });
});
this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.mounted = false;
if (this.onI18nChanged) {
this.i18n.off('languageChanged', this.onI18nChanged);
this.i18n.off('loaded', this.onI18nChanged);
this.i18n.store.off('added', this.onI18nChanged);
this.i18n.store.off('removed', this.onI18nChanged);
}
}
}, {
key: 'onI18nChanged',
value: function onI18nChanged() {
if (!this.mounted) return;
return this.refs.wrappedInstance;
}
}, {
key: 'render',
value: function render() {
var _state = this.state;
var i18nLoadedAt = _state.i18nLoadedAt;
var ready = _state.ready;
this.setState({ i18nLoadedAt: new Date() });
}
}, {
key: 'getWrappedInstance',
value: function getWrappedInstance() {
if (!withRef) {
// eslint-disable-next-line no-console
console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');
}
var extraProps = defineProperty({ i18nLoadedAt: i18nLoadedAt }, translateFuncName, this[translateFuncName]);
return this.refs.wrappedInstance;
}
}, {
key: 'render',
value: function render() {
var _state = this.state;
var i18nLoadedAt = _state.i18nLoadedAt;
var ready = _state.ready;
if (withRef) {
extraProps.ref = 'wrappedInstance';
}
var extraProps = defineProperty({ i18nLoadedAt: i18nLoadedAt }, translateFuncName, this[translateFuncName]);
if (!ready && wait) return null;
if (withRef) {
extraProps.ref = 'wrappedInstance';
}
return React__default.createElement(WrappedComponent, _extends({}, this.props, extraProps));
}
}]);
return Translate;
}(React.Component);
if (!ready && wait) return null;
Translate.WrappedComponent = WrappedComponent;
return React__default.createElement(WrappedComponent, _extends({}, this.props, extraProps));
}
}]);
return Translate;
}(React.Component);
Translate.contextTypes = {
i18n: React.PropTypes.object.isRequired
};
Translate.WrappedComponent = WrappedComponent;
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);
Translate.contextTypes = {
i18n: React.PropTypes.object.isRequired
};
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);
Translate.namespaces = namespaces;
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
return hoistStatics(Translate, WrappedComponent);
};
}
Translate.namespaces = namespaces;
var Interpolate = function (_Component) {
inherits(Interpolate, _Component);
return hoistStatics(Translate, WrappedComponent);
};
}
function Interpolate(props, context) {
classCallCheck(this, Interpolate);
var Interpolate = function (_Component) {
inherits(Interpolate, _Component);
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Interpolate).call(this, props, context));
function Interpolate(props, context) {
classCallCheck(this, Interpolate);
_this.i18n = context.i18n;
_this.t = context.t;
return _this;
}
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Interpolate).call(this, props, context));
createClass(Interpolate, [{
key: 'render',
value: function render() {
var _this2 = this;
_this.i18n = context.i18n;
_this.t = context.t;
return _this;
}
var parent = this.props.parent || 'span';
var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
createClass(Interpolate, [{
key: 'render',
value: function render() {
var _this2 = this;
// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
var parent = this.props.parent || 'span';
var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
var className = this.props.className;
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });
var format = this.t(this.props.i18nKey, tOpts);
// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });
var format = this.t(this.props.i18nKey, tOpts);
var children = [];
if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);
format.split(REGEXP).reduce(function (memo, match, index) {
var child;
var children = [];
if (index % 2 === 0) {
if (match.length === 0) return memo;
if (useDangerouslySetInnerHTML) {
child = React__default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {
child = _this2.props[match];
if (!_this2.props[match]) _this2.i18n.services.logger.warn('interpolator: missed to pass in variable ' + match + ' for interpolating ' + format);
}
format.split(REGEXP).reduce(function (memo, match, index) {
var child = void 0;
memo.push(child);
return memo;
}, children);
if (index % 2 === 0) {
if (match.length === 0) return memo;
if (useDangerouslySetInnerHTML) {
child = React__default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {
child = _this2.props[match];
if (!_this2.props[match]) _this2.i18n.services.logger.warn('interpolator: missed to pass in variable ' + match + ' for interpolating ' + format);
}
return React__default.createElement.apply(this, [parent, null].concat(children));
}
}]);
return Interpolate;
}(React.Component);
memo.push(child);
return memo;
}, children);
Interpolate.contextTypes = {
i18n: React.PropTypes.object.isRequired,
t: React.PropTypes.func.isRequired
};
return React__default.createElement.apply(this, [parent, { className: className }].concat(children));
}
}]);
return Interpolate;
}(React.Component);
var I18nextProvider = function (_Component) {
inherits(I18nextProvider, _Component);
Interpolate.propTypes = {
children: React.PropTypes.node,
className: React.PropTypes.string
};
function I18nextProvider(props, context) {
classCallCheck(this, I18nextProvider);
Interpolate.contextTypes = {
i18n: React.PropTypes.object.isRequired,
t: React.PropTypes.func.isRequired
};
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(I18nextProvider).call(this, props, context));
var I18nextProvider = function (_Component) {
inherits(I18nextProvider, _Component);
_this.i18n = props.i18n;
return _this;
}
function I18nextProvider(props, context) {
classCallCheck(this, I18nextProvider);
createClass(I18nextProvider, [{
key: 'getChildContext',
value: function getChildContext() {
return { i18n: this.i18n };
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (this.props.i18n !== nextProps.i18n) {
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}
}
}, {
key: 'render',
value: function render() {
var children = this.props.children;
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(I18nextProvider).call(this, props, context));
return React.Children.only(children);
}
}]);
return I18nextProvider;
}(React.Component);
_this.i18n = props.i18n;
return _this;
}
I18nextProvider.propTypes = {
i18n: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired
};
createClass(I18nextProvider, [{
key: 'getChildContext',
value: function getChildContext() {
return { i18n: this.i18n };
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (this.props.i18n !== nextProps.i18n) {
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}
}
}, {
key: 'render',
value: function render() {
var children = this.props.children;
I18nextProvider.childContextTypes = {
i18n: React.PropTypes.object.isRequired
};
return React.Children.only(children);
}
}]);
return I18nextProvider;
}(React.Component);
// Borrowed from https://github.com/Rezonans/redux-async-connect/blob/master/modules/ReduxAsyncConnect.js#L16
function eachComponents(components, iterator) {
for (var i = 0, l = components.length; i < l; i++) {
// eslint-disable-line id-length
if (_typeof(components[i]) === 'object') {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
I18nextProvider.propTypes = {
i18n: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired
};
try {
for (var _iterator = Object.entries(components[i])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2);
I18nextProvider.childContextTypes = {
i18n: React.PropTypes.object.isRequired
};
var key = _step$value[0];
var value = _step$value[1];
// Borrowed from https://github.com/Rezonans/redux-async-connect/blob/master/modules/ReduxAsyncConnect.js#L16
function eachComponents(components, iterator) {
for (var i = 0, l = components.length; i < l; i++) {
// eslint-disable-line id-length
if (_typeof(components[i]) === 'object') {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
iterator(value, i, key);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
iterator(components[i], i);
}
}
}
try {
for (var _iterator = Object.entries(components[i])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2);
function filterAndFlattenComponents(components) {
var flattened = [];
eachComponents(components, function (Component) {
if (Component && Component.namespaces) {
var key = _step$value[0];
var value = _step$value[1];
Component.namespaces.forEach(function (namespace) {
if (flattened.indexOf(namespace) === -1) {
flattened.push(namespace);
}
});
}
});
return flattened;
}
iterator(value, i, key);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
iterator(components[i], i);
}
}
}
function loadNamespaces(_ref) {
var components = _ref.components;
var i18n = _ref.i18n;
function filterAndFlattenComponents(components) {
var flattened = [];
eachComponents(components, function (Component) {
if (Component && Component.namespaces) {
var allNamespaces = filterAndFlattenComponents(components);
Component.namespaces.forEach(function (namespace) {
if (flattened.indexOf(namespace) === -1) {
flattened.push(namespace);
}
});
}
});
return flattened;
}
return new Promise(function (resolve) {
i18n.loadNamespaces(allNamespaces, resolve);
});
}
function loadNamespaces(_ref) {
var components = _ref.components;
var i18n = _ref.i18n;
exports.loadNamespaces = loadNamespaces;
exports.translate = translate;
exports.Interpolate = Interpolate;
exports.I18nextProvider = I18nextProvider;
var allNamespaces = filterAndFlattenComponents(components);
Object.defineProperty(exports, '__esModule', { value: true });
return new Promise(function (resolve) {
i18n.loadNamespaces(allNamespaces, resolve);
});
}
}));
exports.loadNamespaces = loadNamespaces;
exports.translate = translate;
exports.Interpolate = Interpolate;
exports.I18nextProvider = I18nextProvider;
Object.defineProperty(exports, '__esModule', { value: true });
})));

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e,t){return t={exports:{}},e(t,t.exports),t.exports}function r(e){return e.displayName||e.name||"Component"}function o(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=n.withRef,i=void 0!==o&&o,a=n.wait,s=void 0!==a&&a,c=n.translateFuncName,l=void 0===c?"t":c;return function(n){var o=function(t){function r(t,n){f(this,r);var o=v(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),d(r,[{key:"getChildContext",value:function(){return h({},l,this[l])}},{key:"componentWillMount",value:function(){this[l]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store&&this.i18n.store.on("added removed",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(this.i18n.off("languageChanged",this.onI18nChanged),this.i18n.off("loaded",this.onI18nChanged),this.i18n.store.off("added",this.onI18nChanged),this.i18n.store.off("removed",this.onI18nChanged))}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return i||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e=this.state,t=e.i18nLoadedAt,r=e.ready,o=h({i18nLoadedAt:t},l,this[l]);return i&&(o.ref="wrappedInstance"),!r&&s?null:u.createElement(n,y({},this.props,o))}}]),r}(t.Component);return o.WrappedComponent=n,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes=h({},l,t.PropTypes.func.isRequired),o.displayName="Translate("+r(n)+")",o.namespaces=e,p(o,n)}}function i(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===l(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var c=g(s.value,2),p=c[0],f=c[1];t(f,n,p)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function a(e){var t=[];return i(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function s(e){var t=e.components,n=e.i18n,r=a(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var u="default"in t?t.default:t,c=n(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),p=c&&"object"==typeof c&&"default"in c?c.default:c,l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},d=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},v=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=function(e){function t(e,n){f(this,t);var r=v(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),d(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props.useDangerouslySetInnerHTML||!1,o=this.props.dangerouslySetInnerHTMLPartElement||"span",i=y({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),a=this.t(this.props.i18nKey,i);if(!a||"string"!=typeof a)return u.createElement("noscript",null);var s=[];return a.split(n).reduce(function(t,n,i){var s;if(i%2===0){if(0===n.length)return t;s=r?u.createElement(o,{dangerouslySetInnerHTML:{__html:n}}):n}else s=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+a);return t.push(s),t},s),u.createElement.apply(this,[t,null].concat(s))}}]),t}(t.Component);b.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var x=function(e){function n(e,t){f(this,n);var r=v(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),d(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);x.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},x.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=s,e.translate=o,e.Interpolate=b,e.I18nextProvider=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.translateFuncName,c=void 0===u?"t":u;return function(n){var r=function(t){function r(t,n){d(this,r);var o=g(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return v(r,t),h(r,[{key:"getChildContext",value:function(){return y({},c,this[c])}},{key:"componentWillMount",value:function(){this[c]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store&&this.i18n.store.on("added removed",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(this.i18n.off("languageChanged",this.onI18nChanged),this.i18n.off("loaded",this.onI18nChanged),this.i18n.store.off("added",this.onI18nChanged),this.i18n.store.off("removed",this.onI18nChanged))}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return i||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e=this.state,t=e.i18nLoadedAt,r=e.ready,o=y({i18nLoadedAt:t},c,this[c]);return i&&(o.ref="wrappedInstance"),!r&&s?null:p.createElement(n,m({},this.props,o))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object.isRequired},r.childContextTypes=y({},c,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=b(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},h=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),y=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},g=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},b=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x=function(e){function t(e,n){d(this,t);var r=g(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return v(t,e),h(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props.className,o=this.props.useDangerouslySetInnerHTML||!1,i=this.props.dangerouslySetInnerHTMLPartElement||"span",a=m({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),s=this.t(this.props.i18nKey,a);if(!s||"string"!=typeof s)return p.createElement("noscript",null);var u=[];return s.split(n).reduce(function(t,n,r){var a=void 0;if(r%2===0){if(0===n.length)return t;a=o?p.createElement(i,{dangerouslySetInnerHTML:{__html:n}}):n}else a=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+s);return t.push(a),t},u),p.createElement.apply(this,[t,{className:r}].concat(u))}}]),t}(t.Component);x.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},x.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var w=function(e){function n(e,t){d(this,n);var r=g(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return v(n,e),h(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);w.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},w.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=x,e.I18nextProvider=w,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "react-i18next",
"version": "1.7.0",
"version": "1.8.0",
"description": "React integration for i18next",

@@ -28,29 +28,28 @@ "main": "dist/commonjs/index.js",

"devDependencies": {
"babel-cli": "6.10.1",
"babel-core": "6.10.4",
"babel-cli": "6.11.4",
"babel-core": "6.13.2",
"babel-eslint": "6.1.2",
"babel-jest": "^14.0.0",
"babel-preset-es2015": "6.9.0",
"babel-preset-es2015-native-modules": "6.6.0",
"babel-preset-es2015-rollup": "1.1.1",
"babel-jest": "14.1.0",
"babel-preset-es2015": "6.13.2",
"babel-preset-es2015-rollup": "1.2.0",
"babel-preset-stage-0": "6.5.0",
"babel-register": "6.9.0",
"babel-register": "6.11.6",
"enzyme": "2.4.1",
"eslint": "2.10.2",
"eslint-config-airbnb": "9.0.1",
"eslint-plugin-import": "1.10.2",
"eslint-plugin-jsx-a11y": "1.5.5",
"eslint-plugin-react": "5.2.2",
"i18next": "3.3.1",
"jest": "14.0.0",
"jest-cli": "13.2.3",
"eslint": "3.3.1",
"eslint-config-airbnb": "10.0.1",
"eslint-plugin-import": "1.13.0",
"eslint-plugin-jsx-a11y": "2.1.0",
"eslint-plugin-react": "6.1.2",
"i18next": "3.4.1",
"jest": "14.1.0",
"jest-cli": "14.1.0",
"mkdirp": "0.5.1",
"react": "15.2.1",
"rimraf": "2.5.3",
"rollup": "0.33.2",
"react": "15.3.0",
"rimraf": "2.5.4",
"rollup": "0.34.10",
"rollup-plugin-babel": "2.6.1",
"rollup-plugin-commonjs": "3.1.0",
"rollup-plugin-node-resolve": "1.7.1",
"rollup-plugin-commonjs": "3.3.1",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-uglify": "1.0.1",
"yargs": "4.7.1"
"yargs": "5.0.0"
},

@@ -57,0 +56,0 @@ "scripts": {

@@ -5,486 +5,496 @@ (function (global, factory) {

(factory((global.reactI18next = global.reactI18next || {}),global.React));
}(this, function (exports,React) { 'use strict';
}(this, (function (exports,React) { 'use strict';
var React__default = 'default' in React ? React['default'] : React;
var React__default = 'default' in React ? React['default'] : React;
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
function interopDefault(ex) {
return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex;
}
var index = createCommonjsModule(function (module) {
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var REACT_STATICS = {
childContextTypes: true,
contextTypes: true,
defaultProps: true,
displayName: true,
getDefaultProps: true,
mixins: true,
propTypes: true,
type: true
};
var index = createCommonjsModule(function (module) {
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
'use strict';
var KNOWN_STATICS = {
name: true,
length: true,
prototype: true,
caller: true,
arguments: true,
arity: true
};
var REACT_STATICS = {
childContextTypes: true,
contextTypes: true,
defaultProps: true,
displayName: true,
getDefaultProps: true,
mixins: true,
propTypes: true,
type: true
};
var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function';
var KNOWN_STATICS = {
name: true,
length: true,
prototype: true,
caller: true,
arguments: true,
arity: true
};
module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) {
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
var keys = Object.getOwnPropertyNames(sourceComponent);
var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function';
/* istanbul ignore else */
if (isGetOwnPropertySymbolsAvailable) {
keys = keys.concat(Object.getOwnPropertySymbols(sourceComponent));
}
module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) {
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
var keys = Object.getOwnPropertyNames(sourceComponent);
for (var i = 0; i < keys.length; ++i) {
if (!REACT_STATICS[keys[i]] && !KNOWN_STATICS[keys[i]] && (!customStatics || !customStatics[keys[i]])) {
try {
targetComponent[keys[i]] = sourceComponent[keys[i]];
} catch (error) {
/* istanbul ignore else */
if (isGetOwnPropertySymbolsAvailable) {
keys = keys.concat(Object.getOwnPropertySymbols(sourceComponent));
}
}
}
}
}
for (var i = 0; i < keys.length; ++i) {
if (!REACT_STATICS[keys[i]] && !KNOWN_STATICS[keys[i]] && (!customStatics || !customStatics[keys[i]])) {
try {
targetComponent[keys[i]] = sourceComponent[keys[i]];
} catch (error) {
return targetComponent;
};
});
}
}
}
}
var hoistStatics = (index && typeof index === 'object' && 'default' in index ? index['default'] : index);
return targetComponent;
};
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var hoistStatics = interopDefault(index);
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
return obj;
};
var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
return obj;
};
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
return target;
};
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
return target;
};
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
return _arr;
}
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
return _arr;
}
function getDisplayName(component) {
return component.displayName || component.name || 'Component';
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
function translate(namespaces) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _options$withRef = options.withRef;
var withRef = _options$withRef === undefined ? false : _options$withRef;
var _options$wait = options.wait;
var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
function getDisplayName(component) {
return component.displayName || component.name || 'Component';
}
function translate(namespaces) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var _options$withRef = options.withRef;
var withRef = _options$withRef === undefined ? false : _options$withRef;
var _options$wait = options.wait;
var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
return function Wrapper(WrappedComponent) {
var Translate = function (_Component) {
inherits(Translate, _Component);
function Translate(props, context) {
classCallCheck(this, Translate);
return function Wrapper(WrappedComponent) {
var Translate = function (_Component) {
inherits(Translate, _Component);
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Translate).call(this, props, context));
function Translate(props, context) {
classCallCheck(this, Translate);
_this.i18n = context.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Translate).call(this, props, context));
_this.state = {
i18nLoadedAt: null,
ready: false
};
_this.i18n = context.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;
_this.onI18nChanged = _this.onI18nChanged.bind(_this);
return _this;
}
_this.state = {
i18nLoadedAt: null,
ready: false
};
createClass(Translate, [{
key: 'getChildContext',
value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
_this.onI18nChanged = _this.onI18nChanged.bind(_this);
return _this;
}
this.mounted = true;
this.i18n.loadNamespaces(namespaces, function () {
if (_this2.mounted) _this2.setState({ ready: true });
});
this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.mounted = false;
if (this.onI18nChanged) {
this.i18n.off('languageChanged', this.onI18nChanged);
this.i18n.off('loaded', this.onI18nChanged);
this.i18n.store.off('added', this.onI18nChanged);
this.i18n.store.off('removed', this.onI18nChanged);
}
}
}, {
key: 'onI18nChanged',
value: function onI18nChanged() {
if (!this.mounted) return;
createClass(Translate, [{
key: 'getChildContext',
value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
this.setState({ i18nLoadedAt: new Date() });
}
}, {
key: 'getWrappedInstance',
value: function getWrappedInstance() {
if (!withRef) {
// eslint-disable-next-line no-console
console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');
}
this.mounted = true;
this.i18n.loadNamespaces(namespaces, function () {
if (_this2.mounted) _this2.setState({ ready: true });
});
this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.mounted = false;
if (this.onI18nChanged) {
this.i18n.off('languageChanged', this.onI18nChanged);
this.i18n.off('loaded', this.onI18nChanged);
this.i18n.store.off('added', this.onI18nChanged);
this.i18n.store.off('removed', this.onI18nChanged);
}
}
}, {
key: 'onI18nChanged',
value: function onI18nChanged() {
if (!this.mounted) return;
return this.refs.wrappedInstance;
}
}, {
key: 'render',
value: function render() {
var _state = this.state;
var i18nLoadedAt = _state.i18nLoadedAt;
var ready = _state.ready;
this.setState({ i18nLoadedAt: new Date() });
}
}, {
key: 'getWrappedInstance',
value: function getWrappedInstance() {
if (!withRef) {
// eslint-disable-next-line no-console
console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');
}
var extraProps = defineProperty({ i18nLoadedAt: i18nLoadedAt }, translateFuncName, this[translateFuncName]);
return this.refs.wrappedInstance;
}
}, {
key: 'render',
value: function render() {
var _state = this.state;
var i18nLoadedAt = _state.i18nLoadedAt;
var ready = _state.ready;
if (withRef) {
extraProps.ref = 'wrappedInstance';
}
var extraProps = defineProperty({ i18nLoadedAt: i18nLoadedAt }, translateFuncName, this[translateFuncName]);
if (!ready && wait) return null;
if (withRef) {
extraProps.ref = 'wrappedInstance';
}
return React__default.createElement(WrappedComponent, _extends({}, this.props, extraProps));
}
}]);
return Translate;
}(React.Component);
if (!ready && wait) return null;
Translate.WrappedComponent = WrappedComponent;
return React__default.createElement(WrappedComponent, _extends({}, this.props, extraProps));
}
}]);
return Translate;
}(React.Component);
Translate.contextTypes = {
i18n: React.PropTypes.object.isRequired
};
Translate.WrappedComponent = WrappedComponent;
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);
Translate.contextTypes = {
i18n: React.PropTypes.object.isRequired
};
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);
Translate.namespaces = namespaces;
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
return hoistStatics(Translate, WrappedComponent);
};
}
Translate.namespaces = namespaces;
var Interpolate = function (_Component) {
inherits(Interpolate, _Component);
return hoistStatics(Translate, WrappedComponent);
};
}
function Interpolate(props, context) {
classCallCheck(this, Interpolate);
var Interpolate = function (_Component) {
inherits(Interpolate, _Component);
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Interpolate).call(this, props, context));
function Interpolate(props, context) {
classCallCheck(this, Interpolate);
_this.i18n = context.i18n;
_this.t = context.t;
return _this;
}
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(Interpolate).call(this, props, context));
createClass(Interpolate, [{
key: 'render',
value: function render() {
var _this2 = this;
_this.i18n = context.i18n;
_this.t = context.t;
return _this;
}
var parent = this.props.parent || 'span';
var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
createClass(Interpolate, [{
key: 'render',
value: function render() {
var _this2 = this;
// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
var parent = this.props.parent || 'span';
var REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
var className = this.props.className;
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });
var format = this.t(this.props.i18nKey, tOpts);
// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });
var format = this.t(this.props.i18nKey, tOpts);
var children = [];
if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);
format.split(REGEXP).reduce(function (memo, match, index) {
var child;
var children = [];
if (index % 2 === 0) {
if (match.length === 0) return memo;
if (useDangerouslySetInnerHTML) {
child = React__default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {
child = _this2.props[match];
if (!_this2.props[match]) _this2.i18n.services.logger.warn('interpolator: missed to pass in variable ' + match + ' for interpolating ' + format);
}
format.split(REGEXP).reduce(function (memo, match, index) {
var child = void 0;
memo.push(child);
return memo;
}, children);
if (index % 2 === 0) {
if (match.length === 0) return memo;
if (useDangerouslySetInnerHTML) {
child = React__default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {
child = _this2.props[match];
if (!_this2.props[match]) _this2.i18n.services.logger.warn('interpolator: missed to pass in variable ' + match + ' for interpolating ' + format);
}
return React__default.createElement.apply(this, [parent, null].concat(children));
}
}]);
return Interpolate;
}(React.Component);
memo.push(child);
return memo;
}, children);
Interpolate.contextTypes = {
i18n: React.PropTypes.object.isRequired,
t: React.PropTypes.func.isRequired
};
return React__default.createElement.apply(this, [parent, { className: className }].concat(children));
}
}]);
return Interpolate;
}(React.Component);
var I18nextProvider = function (_Component) {
inherits(I18nextProvider, _Component);
Interpolate.propTypes = {
children: React.PropTypes.node,
className: React.PropTypes.string
};
function I18nextProvider(props, context) {
classCallCheck(this, I18nextProvider);
Interpolate.contextTypes = {
i18n: React.PropTypes.object.isRequired,
t: React.PropTypes.func.isRequired
};
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(I18nextProvider).call(this, props, context));
var I18nextProvider = function (_Component) {
inherits(I18nextProvider, _Component);
_this.i18n = props.i18n;
return _this;
}
function I18nextProvider(props, context) {
classCallCheck(this, I18nextProvider);
createClass(I18nextProvider, [{
key: 'getChildContext',
value: function getChildContext() {
return { i18n: this.i18n };
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (this.props.i18n !== nextProps.i18n) {
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}
}
}, {
key: 'render',
value: function render() {
var children = this.props.children;
var _this = possibleConstructorReturn(this, Object.getPrototypeOf(I18nextProvider).call(this, props, context));
return React.Children.only(children);
}
}]);
return I18nextProvider;
}(React.Component);
_this.i18n = props.i18n;
return _this;
}
I18nextProvider.propTypes = {
i18n: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired
};
createClass(I18nextProvider, [{
key: 'getChildContext',
value: function getChildContext() {
return { i18n: this.i18n };
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (this.props.i18n !== nextProps.i18n) {
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}
}
}, {
key: 'render',
value: function render() {
var children = this.props.children;
I18nextProvider.childContextTypes = {
i18n: React.PropTypes.object.isRequired
};
return React.Children.only(children);
}
}]);
return I18nextProvider;
}(React.Component);
// Borrowed from https://github.com/Rezonans/redux-async-connect/blob/master/modules/ReduxAsyncConnect.js#L16
function eachComponents(components, iterator) {
for (var i = 0, l = components.length; i < l; i++) {
// eslint-disable-line id-length
if (_typeof(components[i]) === 'object') {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
I18nextProvider.propTypes = {
i18n: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired
};
try {
for (var _iterator = Object.entries(components[i])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2);
I18nextProvider.childContextTypes = {
i18n: React.PropTypes.object.isRequired
};
var key = _step$value[0];
var value = _step$value[1];
// Borrowed from https://github.com/Rezonans/redux-async-connect/blob/master/modules/ReduxAsyncConnect.js#L16
function eachComponents(components, iterator) {
for (var i = 0, l = components.length; i < l; i++) {
// eslint-disable-line id-length
if (_typeof(components[i]) === 'object') {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
iterator(value, i, key);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
iterator(components[i], i);
}
}
}
try {
for (var _iterator = Object.entries(components[i])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2);
function filterAndFlattenComponents(components) {
var flattened = [];
eachComponents(components, function (Component) {
if (Component && Component.namespaces) {
var key = _step$value[0];
var value = _step$value[1];
Component.namespaces.forEach(function (namespace) {
if (flattened.indexOf(namespace) === -1) {
flattened.push(namespace);
}
});
}
});
return flattened;
}
iterator(value, i, key);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
iterator(components[i], i);
}
}
}
function loadNamespaces(_ref) {
var components = _ref.components;
var i18n = _ref.i18n;
function filterAndFlattenComponents(components) {
var flattened = [];
eachComponents(components, function (Component) {
if (Component && Component.namespaces) {
var allNamespaces = filterAndFlattenComponents(components);
Component.namespaces.forEach(function (namespace) {
if (flattened.indexOf(namespace) === -1) {
flattened.push(namespace);
}
});
}
});
return flattened;
}
return new Promise(function (resolve) {
i18n.loadNamespaces(allNamespaces, resolve);
});
}
function loadNamespaces(_ref) {
var components = _ref.components;
var i18n = _ref.i18n;
exports.loadNamespaces = loadNamespaces;
exports.translate = translate;
exports.Interpolate = Interpolate;
exports.I18nextProvider = I18nextProvider;
var allNamespaces = filterAndFlattenComponents(components);
Object.defineProperty(exports, '__esModule', { value: true });
return new Promise(function (resolve) {
i18n.loadNamespaces(allNamespaces, resolve);
});
}
}));
exports.loadNamespaces = loadNamespaces;
exports.translate = translate;
exports.Interpolate = Interpolate;
exports.I18nextProvider = I18nextProvider;
Object.defineProperty(exports, '__esModule', { value: true });
})));

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e,t){return t={exports:{}},e(t,t.exports),t.exports}function r(e){return e.displayName||e.name||"Component"}function o(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=n.withRef,i=void 0!==o&&o,a=n.wait,s=void 0!==a&&a,c=n.translateFuncName,l=void 0===c?"t":c;return function(n){var o=function(t){function r(t,n){f(this,r);var o=v(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),d(r,[{key:"getChildContext",value:function(){return h({},l,this[l])}},{key:"componentWillMount",value:function(){this[l]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store&&this.i18n.store.on("added removed",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(this.i18n.off("languageChanged",this.onI18nChanged),this.i18n.off("loaded",this.onI18nChanged),this.i18n.store.off("added",this.onI18nChanged),this.i18n.store.off("removed",this.onI18nChanged))}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return i||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e=this.state,t=e.i18nLoadedAt,r=e.ready,o=h({i18nLoadedAt:t},l,this[l]);return i&&(o.ref="wrappedInstance"),!r&&s?null:u.createElement(n,y({},this.props,o))}}]),r}(t.Component);return o.WrappedComponent=n,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes=h({},l,t.PropTypes.func.isRequired),o.displayName="Translate("+r(n)+")",o.namespaces=e,p(o,n)}}function i(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===l(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var c=g(s.value,2),p=c[0],f=c[1];t(f,n,p)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function a(e){var t=[];return i(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function s(e){var t=e.components,n=e.i18n,r=a(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var u="default"in t?t.default:t,c=n(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),p=c&&"object"==typeof c&&"default"in c?c.default:c,l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},d=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},v=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),b=function(e){function t(e,n){f(this,t);var r=v(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),d(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props.useDangerouslySetInnerHTML||!1,o=this.props.dangerouslySetInnerHTMLPartElement||"span",i=y({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),a=this.t(this.props.i18nKey,i);if(!a||"string"!=typeof a)return u.createElement("noscript",null);var s=[];return a.split(n).reduce(function(t,n,i){var s;if(i%2===0){if(0===n.length)return t;s=r?u.createElement(o,{dangerouslySetInnerHTML:{__html:n}}):n}else s=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+a);return t.push(s),t},s),u.createElement.apply(this,[t,null].concat(s))}}]),t}(t.Component);b.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var x=function(e){function n(e,t){f(this,n);var r=v(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),d(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);x.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},x.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=s,e.translate=o,e.Interpolate=b,e.I18nextProvider=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.translateFuncName,c=void 0===u?"t":u;return function(n){var r=function(t){function r(t,n){d(this,r);var o=g(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return v(r,t),h(r,[{key:"getChildContext",value:function(){return y({},c,this[c])}},{key:"componentWillMount",value:function(){this[c]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store&&this.i18n.store.on("added removed",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(this.i18n.off("languageChanged",this.onI18nChanged),this.i18n.off("loaded",this.onI18nChanged),this.i18n.store.off("added",this.onI18nChanged),this.i18n.store.off("removed",this.onI18nChanged))}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return i||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e=this.state,t=e.i18nLoadedAt,r=e.ready,o=y({i18nLoadedAt:t},c,this[c]);return i&&(o.ref="wrappedInstance"),!r&&s?null:p.createElement(n,m({},this.props,o))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object.isRequired},r.childContextTypes=y({},c,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=b(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},h=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),y=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},g=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},b=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x=function(e){function t(e,n){d(this,t);var r=g(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return v(t,e),h(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props.className,o=this.props.useDangerouslySetInnerHTML||!1,i=this.props.dangerouslySetInnerHTMLPartElement||"span",a=m({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),s=this.t(this.props.i18nKey,a);if(!s||"string"!=typeof s)return p.createElement("noscript",null);var u=[];return s.split(n).reduce(function(t,n,r){var a=void 0;if(r%2===0){if(0===n.length)return t;a=o?p.createElement(i,{dangerouslySetInnerHTML:{__html:n}}):n}else a=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+s);return t.push(a),t},u),p.createElement.apply(this,[t,{className:r}].concat(u))}}]),t}(t.Component);x.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},x.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var w=function(e){function n(e,t){d(this,n);var r=g(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return v(n,e),h(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);w.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},w.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=x,e.I18nextProvider=w,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -14,2 +14,3 @@ import React, { Component, PropTypes } from 'react';

const REGEXP = this.props.regexp || this.i18n.services.interpolator.regexp;
const className = this.props.className;

@@ -21,16 +22,16 @@ // Set to true if you want to use raw HTML in translation values

let tOpts = {...{}, ...this.props.options, ...{interpolation: { prefix: '#$?', suffix: '?$#'}}}
let format = this.t(this.props.i18nKey, tOpts);
const tOpts = { ...{}, ...this.props.options, ...{ interpolation: { prefix: '#$?', suffix: '?$#' } } };
const format = this.t(this.props.i18nKey, tOpts);
if (!format || typeof format !== 'string') return React.createElement('noscript', null);
let children = [];
const children = [];
format.split(REGEXP).reduce((memo, match, index) => {
var child;
let child;
if (index % 2 === 0) {
if (match.length === 0) return memo;
if (match.length === 0) return memo;
if (useDangerouslySetInnerHTML) {
child = React.createElement(dangerouslySetInnerHTMLPartElement, {dangerouslySetInnerHTML: {__html: match}});
child = React.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {

@@ -41,3 +42,3 @@ child = match;

child = this.props[match];
if (!this.props[match]) this.i18n.services.logger.warn('interpolator: missed to pass in variable ' + match + ' for interpolating ' + format);
if (!this.props[match]) this.i18n.services.logger.warn(`interpolator: missed to pass in variable ${match} for interpolating ${format}`);
}

@@ -49,6 +50,11 @@

return React.createElement.apply(this, [parent, null].concat(children));
return React.createElement.apply(this, [parent, { className }].concat(children));
}
}
Interpolate.propTypes = {
children: PropTypes.node,
className: PropTypes.string
};
Interpolate.contextTypes = {

@@ -55,0 +61,0 @@ i18n: PropTypes.object.isRequired,

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