Socket
Socket
Sign inDemoInstall

react-i18next

Package Overview
Dependencies
Maintainers
2
Versions
313
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 4.8.0 to 5.0.0

33

CHANGELOG.md

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

### 5.0.0
- **[BREAKING]** we no longer accept wait to be specified on i18next init options like ``{ wait: true }`` -> all overrides for the translate hoc now have to be in child `react` like `{ react: { wait: true } }`
- you now can override all the default options for translate hoc by setting them on i18next.init (excluding `translateFuncName` as we need that upfront to define childContextTypes)
```
i18next.init({
// ... other options
react: {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
nsMode: 'default'
}
});
```
- you now can override all defaults for translate hoc options (including `translateFuncName`) by using:
```
import translate from 'react-i18next';
translate.setDefaults({
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
nsMode: 'default',
translateFuncName: 't'
});
```
### 4.8.0

@@ -2,0 +35,0 @@ - make trans component work with preact and preact-compat

58

dist/amd/react-i18next.js

@@ -206,2 +206,11 @@ define('reactI18next', ['exports', 'react', 'prop-types'], function (exports, React, PropTypes) { 'use strict';

var defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
};
function getDisplayName(component) {

@@ -215,12 +224,4 @@ return component.displayName || component.name || 'Component';

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$withRef = options.withRef,
withRef = _options$withRef === undefined ? false : _options$withRef,
_options$bindI18n = options.bindI18n,
bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n,
_options$bindStore = options.bindStore,
bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore,
_options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
var _options$wait = options.wait,
wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? defaultOptions.translateFuncName : _options$translateFun;

@@ -243,10 +244,9 @@

if (!wait && _this.i18n.options && (_this.i18n.options.wait || _this.i18n.options.react && _this.i18n.options.react.wait)) wait = true;
var i18nOptions = _this.i18n && _this.i18n.options.react || {};
_this.options = _extends({}, defaultOptions, i18nOptions, options);
_this.nsMode = options.nsMode || _this.i18n.options && _this.i18n.options.react && _this.i18n.options.react.nsMode || 'default';
// nextjs SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
wait = false; // we got all passed down already
_this.options.wait = false; // we got all passed down already
}

@@ -259,3 +259,3 @@ if (props.initialLanguage) {

if (_this.i18n.options.isInitialSSR) {
wait = false;
_this.options.wait = false;
}

@@ -283,3 +283,3 @@

value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, this.nsMode === 'fallback' ? namespaces : namespaces[0]);
this[translateFuncName] = this.i18n.getFixedT(null, this.options.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

@@ -292,4 +292,4 @@ }, {

var bind = function bind() {
if (bindI18n && _this2.i18n) _this2.i18n.on(bindI18n, _this2.onI18nChanged);
if (bindStore && _this2.i18n.store) _this2.i18n.store.on(bindStore, _this2.onI18nChanged);
if (_this2.options.bindI18n && _this2.i18n) _this2.i18n.on(_this2.options.bindI18n, _this2.onI18nChanged);
if (_this2.options.bindStore && _this2.i18n.store) _this2.i18n.store.on(_this2.options.bindStore, _this2.onI18nChanged);
};

@@ -301,3 +301,3 @@

if (_this2.mounted && !_this2.state.ready) _this2.setState({ ready: true });
if (wait && _this2.mounted) bind();
if (_this2.options.wait && _this2.mounted) bind();
};

@@ -320,3 +320,3 @@

if (!wait) bind();
if (!this.options.wait) bind();
}

@@ -330,4 +330,4 @@ }, {

if (this.onI18nChanged) {
if (bindI18n) {
var p = bindI18n.split(' ');
if (this.options.bindI18n) {
var p = this.options.bindI18n.split(' ');
p.forEach(function (f) {

@@ -337,4 +337,4 @@ return _this3.i18n.off(f, _this3.onI18nChanged);

}
if (bindStore) {
var _p = bindStore.split(' ');
if (this.options.bindStore) {
var _p = this.options.bindStore.split(' ');
_p.forEach(function (f) {

@@ -356,3 +356,3 @@ return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged);

value: function getWrappedInstance() {
if (!withRef) {
if (!this.options.withRef) {
// eslint-disable-next-line no-console

@@ -379,7 +379,7 @@ console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');

if (withRef) {
if (this.options.withRef) {
extraProps.ref = 'wrappedInstance';
}
if (!ready && wait) return null;
if (!ready && this.options.wait) return null;

@@ -416,2 +416,6 @@ // remove ssr flag set by provider - first render was done from now on wait if set to wait

translate.setDefaults = function set$$1(options) {
defaultOptions = _extends({}, defaultOptions, options);
};
var Interpolate = function (_Component) {

@@ -418,0 +422,0 @@ inherits(Interpolate, _Component);

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

define("reactI18next",["exports","react","prop-types"],function(t,e,n){"use strict";function i(t){return t.displayName||t.name||"Component"}function r(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.withRef,a=void 0!==o&&o,s=r.bindI18n,p=void 0===s?"languageChanged loaded":s,u=r.bindStore,c=void 0===u?"added removed":u,l=r.translateFuncName,d=void 0===l?"t":l,h=r.wait,y=void 0!==h&&h;return function(o){var s,u=function(e){function n(e,i){m(this,n);var o=x(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,i));return o.i18n=i.i18n||e.i18n||r.i18n,t=t||o.i18n.options.defaultNS,"string"==typeof t&&(t=[t]),!y&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(y=!0),o.nsMode=r.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",e.initialI18nStore&&(o.i18n.services.resourceStore.data=e.initialI18nStore,y=!1),e.initialLanguage&&o.i18n.changeLanguage(e.initialLanguage),o.i18n.options.isInitialSSR&&(y=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return j(n,e),b(n,[{key:"getChildContext",value:function(){var t;return t={},S(t,d,this[d]),S(t,"i18n",this.i18n),t}},{key:"componentWillMount",value:function(){this[d]=this.i18n.getFixedT(null,"fallback"===this.nsMode?t:t[0])}},{key:"componentDidMount",value:function(){var e=this,n=function(){p&&e.i18n&&e.i18n.on(p,e.onI18nChanged),c&&e.i18n.store&&e.i18n.store.on(c,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(t,function(){var t=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),y&&e.mounted&&n()};if(e.i18n.isInitialized)t();else{var i=function n(){setTimeout(function(){e.i18n.off("initialized",n)},1e3),t()};e.i18n.on("initialized",i)}}),y||n()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(p){p.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)})}if(c){c.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return a||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 t,e=this,n=this.state,i=n.i18nLoadedAt,r=n.ready,s=(t={i18nLoadedAt:i},S(t,d,this[d]),S(t,"i18n",this.i18n),t);return a&&(s.ref="wrappedInstance"),!r&&y?null:(this.i18n.options.isInitialSSR&&!w&&(w=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),f.createElement(o,O({},this.props,s)))}}]),n}(e.Component);return u.WrappedComponent=o,u.contextTypes={i18n:n.object},u.childContextTypes=(s={},S(s,d,n.func.isRequired),S(s,"i18n",n.object),s),u.displayName="Translate("+i(o)+")",u.namespaces=t,v(u,o)}}function o(t){return t&&(t.children||t.props&&t.props.children)}function a(t){return t&&t.children?t.children:t.props&&t.props.children}function s(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(o(e))t=t+"<"+i+">"+s("",a(e),n+1)+"</"+i+">";else if(f.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":g(e))){var r=O({},e),p=r.format;delete r.format;var u=Object.keys(r);p&&1===u.length?t=t+"<"+i+">{{"+u[0]+", "+p+"}}</"+i+">":1===u.length&&(t=t+"<"+i+">{{"+u[0]+"}}</"+i+">")}}),t}function p(t,e,n){function i(t,e){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);var r=e.split(_).reduce(function(t,e,n){return e&&t.push(e),t},[]);return r.reduce(function(e,s,p){var u=!isNaN(s),c=p>0&&!isNaN(r[p-1]);if(c){var l=t[parseInt(r[p-1],10)]||{};f.isValidElement(l)&&!o(l)&&(c=!1)}if(c)return e;if(u){var d=t[parseInt(s,10)]||{},h=f.isValidElement(d);if("string"==typeof d)e.push(d);else if(o(d)){var y=i(a(d),r[p+1]);e.push(f.cloneElement(d,O({},d.props,{key:p}),y))}else if("object"!==(void 0===d?"undefined":g(d))||h)e.push(d);else{var v=n.services.interpolator.interpolate(r[p+1],d,n.language);e.push(v)}}return u||c||e.push(s),e},[])}return i(t,e)}function u(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===g(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var u=I(s.value,2),c=u[0],l=u[1];e(l,n,c)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function c(t){var e=[];return u(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}function l(t){var e=t.components,n=t.i18n,i=c(e);return new Promise(function(t){n.loadNamespaces(i,t)})}var f="default"in e?e.default:e;n="default"in n?n.default:n;var d={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},h={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},y="function"==typeof Object.getOwnPropertySymbols,v=function(t,e,n){if("string"!=typeof e){var i=Object.getOwnPropertyNames(e);y&&(i=i.concat(Object.getOwnPropertySymbols(e)));for(var r=0;r<i.length;++r)if(!(d[i[r]]||h[i[r]]||n&&n[i[r]]))try{t[i[r]]=e[i[r]]}catch(t){}}return t},g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},b=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),S=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},O=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},j=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},x=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},I=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),w=!1,C=function(t){function e(t,n){m(this,e);var i=x(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return j(e,t),b(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=O({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return f.createElement("noscript",null);var c=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+u),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};u.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?f.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},c);var d={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(d["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(d.className=r),o&&(d.style=o),f.createElement.apply(this,[e,d].concat(c))}}]),e}(e.Component);C.propTypes={className:n.string},C.defaultProps={className:""},C.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var _=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),T=function(t){function e(t,n){m(this,e);var i=x(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return j(e,t),b(e,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=s("",e,0),o=this.props.i18nKey||r,a=this.t(o,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:r,count:n}),u={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){c=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(u["data-i18next-options"]=JSON.stringify({ns:c}))}return f.createElement(i,u,p(e,a,this.i18n))}}]),e}(f.Component);T.propTypes={count:n.number,parent:n.string,i18nKey:n.string},T.defaultProps={parent:"div"},T.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var P=function(t){function n(t,e){m(this,n);var i=x(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return j(n,t),b(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);P.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},P.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=r,t.Interpolate=C,t.I18nextProvider=P,t.Trans=T,Object.defineProperty(t,"__esModule",{value:!0})});
define("reactI18next",["exports","react","prop-types"],function(t,n,e){"use strict";function i(t){return t.displayName||t.name||"Component"}function o(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=o.translateFuncName,s=void 0===r?x.translateFuncName:r;return function(r){var a,p=function(n){function e(n,i){m(this,e);var r=O(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,n,i));r.i18n=i.i18n||n.i18n||o.i18n,"string"==typeof(t=t||r.i18n.options.defaultNS)&&(t=[t]);var s=r.i18n&&r.i18n.options.react||{};return r.options=w({},x,s,o),n.initialI18nStore&&(r.i18n.services.resourceStore.data=n.initialI18nStore,r.options.wait=!1),n.initialLanguage&&r.i18n.changeLanguage(n.initialLanguage),r.i18n.options.isInitialSSR&&(r.options.wait=!1),r.state={i18nLoadedAt:null,ready:!1},r.onI18nChanged=r.onI18nChanged.bind(r),r.getWrappedInstance=r.getWrappedInstance.bind(r),r}return I(e,n),b(e,[{key:"getChildContext",value:function(){var t;return t={},S(t,s,this[s]),S(t,"i18n",this.i18n),t}},{key:"componentWillMount",value:function(){this[s]=this.i18n.getFixedT(null,"fallback"===this.options.nsMode?t:t[0])}},{key:"componentDidMount",value:function(){var n=this,e=function(){n.options.bindI18n&&n.i18n&&n.i18n.on(n.options.bindI18n,n.onI18nChanged),n.options.bindStore&&n.i18n.store&&n.i18n.store.on(n.options.bindStore,n.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(t,function(){var t=function(){n.mounted&&!n.state.ready&&n.setState({ready:!0}),n.options.wait&&n.mounted&&e()};if(n.i18n.isInitialized)t();else{var i=function e(){setTimeout(function(){n.i18n.off("initialized",e)},1e3),t()};n.i18n.on("initialized",i)}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n){this.options.bindI18n.split(" ").forEach(function(n){return t.i18n.off(n,t.onI18nChanged)})}if(this.options.bindStore){this.options.bindStore.split(" ").forEach(function(n){return t.i18n.store&&t.i18n.store.off(n,t.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return this.options.withRef||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 t,n=this,e=this.state,i=e.i18nLoadedAt,o=e.ready,a=(t={i18nLoadedAt:i},S(t,s,this[s]),S(t,"i18n",this.i18n),t);return this.options.withRef&&(a.ref="wrappedInstance"),!o&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!C&&(C=!0,setTimeout(function(){delete n.i18n.options.isInitialSSR},100)),f.createElement(r,w({},this.props,a)))}}]),e}(n.Component);return p.WrappedComponent=r,p.contextTypes={i18n:e.object},p.childContextTypes=(a={},S(a,s,e.func.isRequired),S(a,"i18n",e.object),a),p.displayName="Translate("+i(r)+")",p.namespaces=t,v(p,r)}}function r(t){return t&&(t.children||t.props&&t.props.children)}function s(t){return t&&t.children?t.children:t.props&&t.props.children}function a(t,n,e){return"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),n.forEach(function(n,e){var i=""+e;if("string"==typeof n)t=""+t+n;else if(r(n))t=t+"<"+i+">"+a("",s(n),e+1)+"</"+i+">";else if(f.isValidElement(n))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===n?"undefined":g(n))){var o=w({},n),p=o.format;delete o.format;var u=Object.keys(o);p&&1===u.length?t=t+"<"+i+">{{"+u[0]+", "+p+"}}</"+i+">":1===u.length&&(t=t+"<"+i+">{{"+u[0]+"}}</"+i+">")}}),t}function p(t,n,e){function i(t,n){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);var o=n.split(N).reduce(function(t,n,e){return n&&t.push(n),t},[]);return o.reduce(function(n,a,p){var u=!isNaN(a),l=p>0&&!isNaN(o[p-1]);if(l){var c=t[parseInt(o[p-1],10)]||{};f.isValidElement(c)&&!r(c)&&(l=!1)}if(l)return n;if(u){var h=t[parseInt(a,10)]||{},d=f.isValidElement(h);if("string"==typeof h)n.push(h);else if(r(h)){var y=i(s(h),o[p+1]);n.push(f.cloneElement(h,w({},h.props,{key:p}),y))}else if("object"!==(void 0===h?"undefined":g(h))||d)n.push(h);else{var v=e.services.interpolator.interpolate(o[p+1],h,e.language);n.push(v)}}return u||l||n.push(a),n},[])}return i(t,n)}function u(t,n){for(var e=0,i=t.length;e<i;e++)if("object"===g(t[e])){var o=!0,r=!1,s=void 0;try{for(var a,p=Object.entries(t[e])[Symbol.iterator]();!(o=(a=p.next()).done);o=!0){var u=j(a.value,2),l=u[0],c=u[1];n(c,e,l)}}catch(t){r=!0,s=t}finally{try{!o&&p.return&&p.return()}finally{if(r)throw s}}}else n(t[e],e)}function l(t){var n=[];return u(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===n.indexOf(t)&&n.push(t)})}),n}function c(t){var n=t.components,e=t.i18n,i=l(n);return new Promise(function(t){e.loadNamespaces(i,t)})}var f="default"in n?n.default:n;e="default"in e?e.default:e;var h={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},d={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},y="function"==typeof Object.getOwnPropertySymbols,v=function(t,n,e){if("string"!=typeof n){var i=Object.getOwnPropertyNames(n);y&&(i=i.concat(Object.getOwnPropertySymbols(n)));for(var o=0;o<i.length;++o)if(!(h[i[o]]||d[i[o]]||e&&e[i[o]]))try{t[i[o]]=n[i[o]]}catch(t){}}return t},g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},b=function(){function t(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(n,e,i){return e&&t(n.prototype,e),i&&t(n,i),n}}(),S=function(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t},w=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},I=function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(t,n):t.__proto__=n)},O=function(t,n){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?t:n},j=function(){function t(t,n){var e=[],i=!0,o=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(e.push(s.value),!n||e.length!==n);i=!0);}catch(t){o=!0,r=t}finally{try{!i&&a.return&&a.return()}finally{if(o)throw r}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},C=!1;o.setDefaults=function(t){x=w({},x,t)};var _=function(t){function n(t,e){m(this,n);var i=O(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=e.i18n,i.t=e.t,i}return I(n,t),b(n,[{key:"render",value:function(){var t=this,n=this.props.parent||"span",e=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,o=i.className,r=i.style,s=this.props.useDangerouslySetInnerHTML||!1,a=this.props.dangerouslySetInnerHTMLPartElement||"span",p=w({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return f.createElement("noscript",null);var l=[],c=function(n,e){if(n.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===e[n]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+u),e[n];var i=n.split(t.i18n.options.interpolation.formatSeparator),o=i.shift().trim(),r=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===e[o]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+o+" for interpolating "+u),t.i18n.options.interpolation.format(e[o],r,t.i18n.language)};u.split(e).reduce(function(n,e,i){var o=void 0;if(i%2==0){if(0===e.length)return n;o=s?f.createElement(a,{dangerouslySetInnerHTML:{__html:e}}):e}else o=c(e,t.props);return n.push(o),n},l);var h={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var d="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){d=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(h["data-i18next-options"]=JSON.stringify({ns:d}))}return o&&(h.className=o),r&&(h.style=r),f.createElement.apply(this,[n,h].concat(l))}}]),n}(n.Component);_.propTypes={className:e.string},_.defaultProps={className:""},_.contextTypes={i18n:e.object.isRequired,t:e.func.isRequired};var N=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),T=function(t){function n(t,e){m(this,n);var i=O(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=e.i18n,i.t=e.t,i}return I(n,t),b(n,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var t=this.props,n=t.children,e=t.count,i=t.parent,o=a("",n,0),r=this.props.i18nKey||o,s=this.t(r,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:o,count:e}),u={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var l="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){l=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(u["data-i18next-options"]=JSON.stringify({ns:l}))}return f.createElement(i,u,p(n,s,this.i18n))}}]),n}(f.Component);T.propTypes={count:e.number,parent:e.string,i18nKey:e.string},T.defaultProps={parent:"div"},T.contextTypes={i18n:e.object.isRequired,t:e.func.isRequired};var P=function(t){function e(t,n){m(this,e);var i=O(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return I(e,t),b(e,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return n.Children.only(t)}}]),e}(n.Component);P.propTypes={i18n:e.object.isRequired,children:e.element.isRequired},P.childContextTypes={i18n:e.object.isRequired},t.loadNamespaces=c,t.translate=o,t.Interpolate=_,t.I18nextProvider=P,t.Trans=T,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -35,2 +35,11 @@ 'use strict';

var defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
};
function getDisplayName(component) {

@@ -44,12 +53,4 @@ return component.displayName || component.name || 'Component';

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$withRef = options.withRef,
withRef = _options$withRef === undefined ? false : _options$withRef,
_options$bindI18n = options.bindI18n,
bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n,
_options$bindStore = options.bindStore,
bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore,
_options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
var _options$wait = options.wait,
wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? defaultOptions.translateFuncName : _options$translateFun;

@@ -72,10 +73,9 @@

if (!wait && _this.i18n.options && (_this.i18n.options.wait || _this.i18n.options.react && _this.i18n.options.react.wait)) wait = true;
var i18nOptions = _this.i18n && _this.i18n.options.react || {};
_this.options = _extends({}, defaultOptions, i18nOptions, options);
_this.nsMode = options.nsMode || _this.i18n.options && _this.i18n.options.react && _this.i18n.options.react.nsMode || 'default';
// nextjs SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
wait = false; // we got all passed down already
_this.options.wait = false; // we got all passed down already
}

@@ -88,3 +88,3 @@ if (props.initialLanguage) {

if (_this.i18n.options.isInitialSSR) {
wait = false;
_this.options.wait = false;
}

@@ -112,3 +112,3 @@

value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, this.nsMode === 'fallback' ? namespaces : namespaces[0]);
this[translateFuncName] = this.i18n.getFixedT(null, this.options.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

@@ -121,4 +121,4 @@ }, {

var bind = function bind() {
if (bindI18n && _this2.i18n) _this2.i18n.on(bindI18n, _this2.onI18nChanged);
if (bindStore && _this2.i18n.store) _this2.i18n.store.on(bindStore, _this2.onI18nChanged);
if (_this2.options.bindI18n && _this2.i18n) _this2.i18n.on(_this2.options.bindI18n, _this2.onI18nChanged);
if (_this2.options.bindStore && _this2.i18n.store) _this2.i18n.store.on(_this2.options.bindStore, _this2.onI18nChanged);
};

@@ -130,3 +130,3 @@

if (_this2.mounted && !_this2.state.ready) _this2.setState({ ready: true });
if (wait && _this2.mounted) bind();
if (_this2.options.wait && _this2.mounted) bind();
};

@@ -149,3 +149,3 @@

if (!wait) bind();
if (!this.options.wait) bind();
}

@@ -159,4 +159,4 @@ }, {

if (this.onI18nChanged) {
if (bindI18n) {
var p = bindI18n.split(' ');
if (this.options.bindI18n) {
var p = this.options.bindI18n.split(' ');
p.forEach(function (f) {

@@ -166,4 +166,4 @@ return _this3.i18n.off(f, _this3.onI18nChanged);

}
if (bindStore) {
var _p = bindStore.split(' ');
if (this.options.bindStore) {
var _p = this.options.bindStore.split(' ');
_p.forEach(function (f) {

@@ -185,3 +185,3 @@ return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged);

value: function getWrappedInstance() {
if (!withRef) {
if (!this.options.withRef) {
// eslint-disable-next-line no-console

@@ -208,7 +208,7 @@ console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');

if (withRef) {
if (this.options.withRef) {
extraProps.ref = 'wrappedInstance';
}
if (!ready && wait) return null;
if (!ready && this.options.wait) return null;

@@ -244,2 +244,6 @@ // remove ssr flag set by provider - first render was done from now on wait if set to wait

};
}
}
translate.setDefaults = function set(options) {
defaultOptions = _extends({}, defaultOptions, options);
};

@@ -17,2 +17,11 @@ 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 defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
};
function getDisplayName(component) {

@@ -26,12 +35,4 @@ return component.displayName || component.name || 'Component';

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$withRef = options.withRef,
withRef = _options$withRef === undefined ? false : _options$withRef,
_options$bindI18n = options.bindI18n,
bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n,
_options$bindStore = options.bindStore,
bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore,
_options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
var _options$wait = options.wait,
wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? defaultOptions.translateFuncName : _options$translateFun;

@@ -54,10 +55,9 @@

if (!wait && _this.i18n.options && (_this.i18n.options.wait || _this.i18n.options.react && _this.i18n.options.react.wait)) wait = true;
var i18nOptions = _this.i18n && _this.i18n.options.react || {};
_this.options = _extends({}, defaultOptions, i18nOptions, options);
_this.nsMode = options.nsMode || _this.i18n.options && _this.i18n.options.react && _this.i18n.options.react.nsMode || 'default';
// nextjs SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
wait = false; // we got all passed down already
_this.options.wait = false; // we got all passed down already
}

@@ -70,3 +70,3 @@ if (props.initialLanguage) {

if (_this.i18n.options.isInitialSSR) {
wait = false;
_this.options.wait = false;
}

@@ -94,3 +94,3 @@

value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, this.nsMode === 'fallback' ? namespaces : namespaces[0]);
this[translateFuncName] = this.i18n.getFixedT(null, this.options.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

@@ -103,4 +103,4 @@ }, {

var bind = function bind() {
if (bindI18n && _this2.i18n) _this2.i18n.on(bindI18n, _this2.onI18nChanged);
if (bindStore && _this2.i18n.store) _this2.i18n.store.on(bindStore, _this2.onI18nChanged);
if (_this2.options.bindI18n && _this2.i18n) _this2.i18n.on(_this2.options.bindI18n, _this2.onI18nChanged);
if (_this2.options.bindStore && _this2.i18n.store) _this2.i18n.store.on(_this2.options.bindStore, _this2.onI18nChanged);
};

@@ -112,3 +112,3 @@

if (_this2.mounted && !_this2.state.ready) _this2.setState({ ready: true });
if (wait && _this2.mounted) bind();
if (_this2.options.wait && _this2.mounted) bind();
};

@@ -131,3 +131,3 @@

if (!wait) bind();
if (!this.options.wait) bind();
}

@@ -141,4 +141,4 @@ }, {

if (this.onI18nChanged) {
if (bindI18n) {
var p = bindI18n.split(' ');
if (this.options.bindI18n) {
var p = this.options.bindI18n.split(' ');
p.forEach(function (f) {

@@ -148,4 +148,4 @@ return _this3.i18n.off(f, _this3.onI18nChanged);

}
if (bindStore) {
var _p = bindStore.split(' ');
if (this.options.bindStore) {
var _p = this.options.bindStore.split(' ');
_p.forEach(function (f) {

@@ -167,3 +167,3 @@ return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged);

value: function getWrappedInstance() {
if (!withRef) {
if (!this.options.withRef) {
// eslint-disable-next-line no-console

@@ -190,7 +190,7 @@ console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');

if (withRef) {
if (this.options.withRef) {
extraProps.ref = 'wrappedInstance';
}
if (!ready && wait) return null;
if (!ready && this.options.wait) return null;

@@ -226,2 +226,6 @@ // remove ssr flag set by provider - first render was done from now on wait if set to wait

};
}
}
translate.setDefaults = function set(options) {
defaultOptions = _extends({}, defaultOptions, options);
};

@@ -210,2 +210,11 @@ (function (global, factory) {

var defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
};
function getDisplayName(component) {

@@ -219,12 +228,4 @@ return component.displayName || component.name || 'Component';

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$withRef = options.withRef,
withRef = _options$withRef === undefined ? false : _options$withRef,
_options$bindI18n = options.bindI18n,
bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n,
_options$bindStore = options.bindStore,
bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore,
_options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
var _options$wait = options.wait,
wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? defaultOptions.translateFuncName : _options$translateFun;

@@ -247,10 +248,9 @@

if (!wait && _this.i18n.options && (_this.i18n.options.wait || _this.i18n.options.react && _this.i18n.options.react.wait)) wait = true;
var i18nOptions = _this.i18n && _this.i18n.options.react || {};
_this.options = _extends({}, defaultOptions, i18nOptions, options);
_this.nsMode = options.nsMode || _this.i18n.options && _this.i18n.options.react && _this.i18n.options.react.nsMode || 'default';
// nextjs SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
wait = false; // we got all passed down already
_this.options.wait = false; // we got all passed down already
}

@@ -263,3 +263,3 @@ if (props.initialLanguage) {

if (_this.i18n.options.isInitialSSR) {
wait = false;
_this.options.wait = false;
}

@@ -287,3 +287,3 @@

value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, this.nsMode === 'fallback' ? namespaces : namespaces[0]);
this[translateFuncName] = this.i18n.getFixedT(null, this.options.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

@@ -296,4 +296,4 @@ }, {

var bind = function bind() {
if (bindI18n && _this2.i18n) _this2.i18n.on(bindI18n, _this2.onI18nChanged);
if (bindStore && _this2.i18n.store) _this2.i18n.store.on(bindStore, _this2.onI18nChanged);
if (_this2.options.bindI18n && _this2.i18n) _this2.i18n.on(_this2.options.bindI18n, _this2.onI18nChanged);
if (_this2.options.bindStore && _this2.i18n.store) _this2.i18n.store.on(_this2.options.bindStore, _this2.onI18nChanged);
};

@@ -305,3 +305,3 @@

if (_this2.mounted && !_this2.state.ready) _this2.setState({ ready: true });
if (wait && _this2.mounted) bind();
if (_this2.options.wait && _this2.mounted) bind();
};

@@ -324,3 +324,3 @@

if (!wait) bind();
if (!this.options.wait) bind();
}

@@ -334,4 +334,4 @@ }, {

if (this.onI18nChanged) {
if (bindI18n) {
var p = bindI18n.split(' ');
if (this.options.bindI18n) {
var p = this.options.bindI18n.split(' ');
p.forEach(function (f) {

@@ -341,4 +341,4 @@ return _this3.i18n.off(f, _this3.onI18nChanged);

}
if (bindStore) {
var _p = bindStore.split(' ');
if (this.options.bindStore) {
var _p = this.options.bindStore.split(' ');
_p.forEach(function (f) {

@@ -360,3 +360,3 @@ return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged);

value: function getWrappedInstance() {
if (!withRef) {
if (!this.options.withRef) {
// eslint-disable-next-line no-console

@@ -383,7 +383,7 @@ console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');

if (withRef) {
if (this.options.withRef) {
extraProps.ref = 'wrappedInstance';
}
if (!ready && wait) return null;
if (!ready && this.options.wait) return null;

@@ -420,2 +420,6 @@ // remove ssr flag set by provider - first render was done from now on wait if set to wait

translate.setDefaults = function set$$1(options) {
defaultOptions = _extends({}, defaultOptions, options);
};
var Interpolate = function (_Component) {

@@ -422,0 +426,0 @@ inherits(Interpolate, _Component);

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react","prop-types"],e):e(t.reactI18next=t.reactI18next||{},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){return t.displayName||t.name||"Component"}function r(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.withRef,a=void 0!==o&&o,s=r.bindI18n,p=void 0===s?"languageChanged loaded":s,u=r.bindStore,c=void 0===u?"added removed":u,l=r.translateFuncName,d=void 0===l?"t":l,h=r.wait,y=void 0!==h&&h;return function(o){var s,u=function(e){function n(e,i){m(this,n);var o=j(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,i));return o.i18n=i.i18n||e.i18n||r.i18n,t=t||o.i18n.options.defaultNS,"string"==typeof t&&(t=[t]),!y&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(y=!0),o.nsMode=r.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",e.initialI18nStore&&(o.i18n.services.resourceStore.data=e.initialI18nStore,y=!1),e.initialLanguage&&o.i18n.changeLanguage(e.initialLanguage),o.i18n.options.isInitialSSR&&(y=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return O(n,e),b(n,[{key:"getChildContext",value:function(){var t;return t={},S(t,d,this[d]),S(t,"i18n",this.i18n),t}},{key:"componentWillMount",value:function(){this[d]=this.i18n.getFixedT(null,"fallback"===this.nsMode?t:t[0])}},{key:"componentDidMount",value:function(){var e=this,n=function(){p&&e.i18n&&e.i18n.on(p,e.onI18nChanged),c&&e.i18n.store&&e.i18n.store.on(c,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(t,function(){var t=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),y&&e.mounted&&n()};if(e.i18n.isInitialized)t();else{var i=function n(){setTimeout(function(){e.i18n.off("initialized",n)},1e3),t()};e.i18n.on("initialized",i)}}),y||n()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(p){p.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)})}if(c){c.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return a||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 t,e=this,n=this.state,i=n.i18nLoadedAt,r=n.ready,s=(t={i18nLoadedAt:i},S(t,d,this[d]),S(t,"i18n",this.i18n),t);return a&&(s.ref="wrappedInstance"),!r&&y?null:(this.i18n.options.isInitialSSR&&!w&&(w=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),f.createElement(o,x({},this.props,s)))}}]),n}(e.Component);return u.WrappedComponent=o,u.contextTypes={i18n:n.object},u.childContextTypes=(s={},S(s,d,n.func.isRequired),S(s,"i18n",n.object),s),u.displayName="Translate("+i(o)+")",u.namespaces=t,v(u,o)}}function o(t){return t&&(t.children||t.props&&t.props.children)}function a(t){return t&&t.children?t.children:t.props&&t.props.children}function s(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(o(e))t=t+"<"+i+">"+s("",a(e),n+1)+"</"+i+">";else if(f.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":g(e))){var r=x({},e),p=r.format;delete r.format;var u=Object.keys(r);p&&1===u.length?t=t+"<"+i+">{{"+u[0]+", "+p+"}}</"+i+">":1===u.length&&(t=t+"<"+i+">{{"+u[0]+"}}</"+i+">")}}),t}function p(t,e,n){function i(t,e){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);var r=e.split(T).reduce(function(t,e,n){return e&&t.push(e),t},[]);return r.reduce(function(e,s,p){var u=!isNaN(s),c=p>0&&!isNaN(r[p-1]);if(c){var l=t[parseInt(r[p-1],10)]||{};f.isValidElement(l)&&!o(l)&&(c=!1)}if(c)return e;if(u){var d=t[parseInt(s,10)]||{},h=f.isValidElement(d);if("string"==typeof d)e.push(d);else if(o(d)){var y=i(a(d),r[p+1]);e.push(f.cloneElement(d,x({},d.props,{key:p}),y))}else if("object"!==(void 0===d?"undefined":g(d))||h)e.push(d);else{var v=n.services.interpolator.interpolate(r[p+1],d,n.language);e.push(v)}}return u||c||e.push(s),e},[])}return i(t,e)}function u(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===g(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var u=I(s.value,2),c=u[0],l=u[1];e(l,n,c)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function c(t){var e=[];return u(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}function l(t){var e=t.components,n=t.i18n,i=c(e);return new Promise(function(t){n.loadNamespaces(i,t)})}var f="default"in e?e.default:e;n="default"in n?n.default:n;var d={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},h={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},y="function"==typeof Object.getOwnPropertySymbols,v=function(t,e,n){if("string"!=typeof e){var i=Object.getOwnPropertyNames(e);y&&(i=i.concat(Object.getOwnPropertySymbols(e)));for(var r=0;r<i.length;++r)if(!(d[i[r]]||h[i[r]]||n&&n[i[r]]))try{t[i[r]]=e[i[r]]}catch(t){}}return t},g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},b=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),S=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},x=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},O=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},j=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},I=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),w=!1,C=function(t){function e(t,n){m(this,e);var i=j(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return O(e,t),b(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=x({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return f.createElement("noscript",null);var c=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+u),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};u.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?f.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},c);var d={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(d["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(d.className=r),o&&(d.style=o),f.createElement.apply(this,[e,d].concat(c))}}]),e}(e.Component);C.propTypes={className:n.string},C.defaultProps={className:""},C.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var T=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),_=function(t){function e(t,n){m(this,e);var i=j(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return O(e,t),b(e,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=s("",e,0),o=this.props.i18nKey||r,a=this.t(o,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:r,count:n}),u={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){c=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(u["data-i18next-options"]=JSON.stringify({ns:c}))}return f.createElement(i,u,p(e,a,this.i18n))}}]),e}(f.Component);_.propTypes={count:n.number,parent:n.string,i18nKey:n.string},_.defaultProps={parent:"div"},_.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var P=function(t){function n(t,e){m(this,n);var i=j(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return O(n,t),b(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);P.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},P.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=r,t.Interpolate=C,t.I18nextProvider=P,t.Trans=_,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react","prop-types"],e):e(t.reactI18next=t.reactI18next||{},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){return t.displayName||t.name||"Component"}function o(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=o.translateFuncName,s=void 0===r?j.translateFuncName:r;return function(r){var a,p=function(e){function n(e,i){g(this,n);var r=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,i));r.i18n=i.i18n||e.i18n||o.i18n,"string"==typeof(t=t||r.i18n.options.defaultNS)&&(t=[t]);var s=r.i18n&&r.i18n.options.react||{};return r.options=I({},j,s,o),e.initialI18nStore&&(r.i18n.services.resourceStore.data=e.initialI18nStore,r.options.wait=!1),e.initialLanguage&&r.i18n.changeLanguage(e.initialLanguage),r.i18n.options.isInitialSSR&&(r.options.wait=!1),r.state={i18nLoadedAt:null,ready:!1},r.onI18nChanged=r.onI18nChanged.bind(r),r.getWrappedInstance=r.getWrappedInstance.bind(r),r}return x(n,e),b(n,[{key:"getChildContext",value:function(){var t;return t={},S(t,s,this[s]),S(t,"i18n",this.i18n),t}},{key:"componentWillMount",value:function(){this[s]=this.i18n.getFixedT(null,"fallback"===this.options.nsMode?t:t[0])}},{key:"componentDidMount",value:function(){var e=this,n=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(t,function(){var t=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&n()};if(e.i18n.isInitialized)t();else{var i=function n(){setTimeout(function(){e.i18n.off("initialized",n)},1e3),t()};e.i18n.on("initialized",i)}}),this.options.wait||n()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n){this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)})}if(this.options.bindStore){this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return this.options.withRef||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 t,e=this,n=this.state,i=n.i18nLoadedAt,o=n.ready,a=(t={i18nLoadedAt:i},S(t,s,this[s]),S(t,"i18n",this.i18n),t);return this.options.withRef&&(a.ref="wrappedInstance"),!o&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!C&&(C=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),f.createElement(r,I({},this.props,a)))}}]),n}(e.Component);return p.WrappedComponent=r,p.contextTypes={i18n:n.object},p.childContextTypes=(a={},S(a,s,n.func.isRequired),S(a,"i18n",n.object),a),p.displayName="Translate("+i(r)+")",p.namespaces=t,v(p,r)}}function r(t){return t&&(t.children||t.props&&t.props.children)}function s(t){return t&&t.children?t.children:t.props&&t.props.children}function a(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(r(e))t=t+"<"+i+">"+a("",s(e),n+1)+"</"+i+">";else if(f.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":m(e))){var o=I({},e),p=o.format;delete o.format;var u=Object.keys(o);p&&1===u.length?t=t+"<"+i+">{{"+u[0]+", "+p+"}}</"+i+">":1===u.length&&(t=t+"<"+i+">{{"+u[0]+"}}</"+i+">")}}),t}function p(t,e,n){function i(t,e){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);var o=e.split(_).reduce(function(t,e,n){return e&&t.push(e),t},[]);return o.reduce(function(e,a,p){var u=!isNaN(a),c=p>0&&!isNaN(o[p-1]);if(c){var l=t[parseInt(o[p-1],10)]||{};f.isValidElement(l)&&!r(l)&&(c=!1)}if(c)return e;if(u){var d=t[parseInt(a,10)]||{},h=f.isValidElement(d);if("string"==typeof d)e.push(d);else if(r(d)){var y=i(s(d),o[p+1]);e.push(f.cloneElement(d,I({},d.props,{key:p}),y))}else if("object"!==(void 0===d?"undefined":m(d))||h)e.push(d);else{var v=n.services.interpolator.interpolate(o[p+1],d,n.language);e.push(v)}}return u||c||e.push(a),e},[])}return i(t,e)}function u(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===m(t[n])){var o=!0,r=!1,s=void 0;try{for(var a,p=Object.entries(t[n])[Symbol.iterator]();!(o=(a=p.next()).done);o=!0){var u=O(a.value,2),c=u[0],l=u[1];e(l,n,c)}}catch(t){r=!0,s=t}finally{try{!o&&p.return&&p.return()}finally{if(r)throw s}}}else e(t[n],n)}function c(t){var e=[];return u(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}function l(t){var e=t.components,n=t.i18n,i=c(e);return new Promise(function(t){n.loadNamespaces(i,t)})}var f="default"in e?e.default:e;n="default"in n?n.default:n;var d={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},h={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},y="function"==typeof Object.getOwnPropertySymbols,v=function(t,e,n){if("string"!=typeof e){var i=Object.getOwnPropertyNames(e);y&&(i=i.concat(Object.getOwnPropertySymbols(e)));for(var o=0;o<i.length;++o)if(!(d[i[o]]||h[i[o]]||n&&n[i[o]]))try{t[i[o]]=e[i[o]]}catch(t){}}return t},m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},b=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),S=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},I=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},x=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},w=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},O=function(){function t(t,e){var n=[],i=!0,o=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);i=!0);}catch(t){o=!0,r=t}finally{try{!i&&a.return&&a.return()}finally{if(o)throw r}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),j={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},C=!1;o.setDefaults=function(t){j=I({},j,t)};var T=function(t){function e(t,n){g(this,e);var i=w(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return x(e,t),b(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,o=i.className,r=i.style,s=this.props.useDangerouslySetInnerHTML||!1,a=this.props.dangerouslySetInnerHTMLPartElement||"span",p=I({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return f.createElement("noscript",null);var c=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+u),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),o=i.shift().trim(),r=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[o]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+o+" for interpolating "+u),t.i18n.options.interpolation.format(n[o],r,t.i18n.language)};u.split(n).reduce(function(e,n,i){var o=void 0;if(i%2==0){if(0===n.length)return e;o=s?f.createElement(a,{dangerouslySetInnerHTML:{__html:n}}):n}else o=l(n,t.props);return e.push(o),e},c);var d={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(d["data-i18next-options"]=JSON.stringify({ns:h}))}return o&&(d.className=o),r&&(d.style=r),f.createElement.apply(this,[e,d].concat(c))}}]),e}(e.Component);T.propTypes={className:n.string},T.defaultProps={className:""},T.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var _=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),N=function(t){function e(t,n){g(this,e);var i=w(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return x(e,t),b(e,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,o=a("",e,0),r=this.props.i18nKey||o,s=this.t(r,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:o,count:n}),u={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){c=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(u["data-i18next-options"]=JSON.stringify({ns:c}))}return f.createElement(i,u,p(e,s,this.i18n))}}]),e}(f.Component);N.propTypes={count:n.number,parent:n.string,i18nKey:n.string},N.defaultProps={parent:"div"},N.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var P=function(t){function n(t,e){g(this,n);var i=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return x(n,t),b(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);P.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},P.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=o,t.Interpolate=T,t.I18nextProvider=P,t.Trans=N,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "react-i18next",
"version": "4.8.0",
"version": "5.0.0",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",

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

@@ -210,2 +210,11 @@ (function (global, factory) {

var defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
};
function getDisplayName(component) {

@@ -219,12 +228,4 @@ return component.displayName || component.name || 'Component';

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$withRef = options.withRef,
withRef = _options$withRef === undefined ? false : _options$withRef,
_options$bindI18n = options.bindI18n,
bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n,
_options$bindStore = options.bindStore,
bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore,
_options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;
var _options$wait = options.wait,
wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName,
translateFuncName = _options$translateFun === undefined ? defaultOptions.translateFuncName : _options$translateFun;

@@ -247,10 +248,9 @@

if (!wait && _this.i18n.options && (_this.i18n.options.wait || _this.i18n.options.react && _this.i18n.options.react.wait)) wait = true;
var i18nOptions = _this.i18n && _this.i18n.options.react || {};
_this.options = _extends({}, defaultOptions, i18nOptions, options);
_this.nsMode = options.nsMode || _this.i18n.options && _this.i18n.options.react && _this.i18n.options.react.nsMode || 'default';
// nextjs SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
wait = false; // we got all passed down already
_this.options.wait = false; // we got all passed down already
}

@@ -263,3 +263,3 @@ if (props.initialLanguage) {

if (_this.i18n.options.isInitialSSR) {
wait = false;
_this.options.wait = false;
}

@@ -287,3 +287,3 @@

value: function componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, this.nsMode === 'fallback' ? namespaces : namespaces[0]);
this[translateFuncName] = this.i18n.getFixedT(null, this.options.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

@@ -296,4 +296,4 @@ }, {

var bind = function bind() {
if (bindI18n && _this2.i18n) _this2.i18n.on(bindI18n, _this2.onI18nChanged);
if (bindStore && _this2.i18n.store) _this2.i18n.store.on(bindStore, _this2.onI18nChanged);
if (_this2.options.bindI18n && _this2.i18n) _this2.i18n.on(_this2.options.bindI18n, _this2.onI18nChanged);
if (_this2.options.bindStore && _this2.i18n.store) _this2.i18n.store.on(_this2.options.bindStore, _this2.onI18nChanged);
};

@@ -305,3 +305,3 @@

if (_this2.mounted && !_this2.state.ready) _this2.setState({ ready: true });
if (wait && _this2.mounted) bind();
if (_this2.options.wait && _this2.mounted) bind();
};

@@ -324,3 +324,3 @@

if (!wait) bind();
if (!this.options.wait) bind();
}

@@ -334,4 +334,4 @@ }, {

if (this.onI18nChanged) {
if (bindI18n) {
var p = bindI18n.split(' ');
if (this.options.bindI18n) {
var p = this.options.bindI18n.split(' ');
p.forEach(function (f) {

@@ -341,4 +341,4 @@ return _this3.i18n.off(f, _this3.onI18nChanged);

}
if (bindStore) {
var _p = bindStore.split(' ');
if (this.options.bindStore) {
var _p = this.options.bindStore.split(' ');
_p.forEach(function (f) {

@@ -360,3 +360,3 @@ return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged);

value: function getWrappedInstance() {
if (!withRef) {
if (!this.options.withRef) {
// eslint-disable-next-line no-console

@@ -383,7 +383,7 @@ console.error('To access the wrapped instance, you need to specify ' + '{ withRef: true } as the second argument of the translate() call.');

if (withRef) {
if (this.options.withRef) {
extraProps.ref = 'wrappedInstance';
}
if (!ready && wait) return null;
if (!ready && this.options.wait) return null;

@@ -420,2 +420,6 @@ // remove ssr flag set by provider - first render was done from now on wait if set to wait

translate.setDefaults = function set$$1(options) {
defaultOptions = _extends({}, defaultOptions, options);
};
var Interpolate = function (_Component) {

@@ -422,0 +426,0 @@ inherits(Interpolate, _Component);

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react","prop-types"],e):e(t.reactI18next=t.reactI18next||{},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){return t.displayName||t.name||"Component"}function r(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.withRef,a=void 0!==o&&o,s=r.bindI18n,p=void 0===s?"languageChanged loaded":s,u=r.bindStore,c=void 0===u?"added removed":u,l=r.translateFuncName,d=void 0===l?"t":l,h=r.wait,y=void 0!==h&&h;return function(o){var s,u=function(e){function n(e,i){m(this,n);var o=j(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,i));return o.i18n=i.i18n||e.i18n||r.i18n,t=t||o.i18n.options.defaultNS,"string"==typeof t&&(t=[t]),!y&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(y=!0),o.nsMode=r.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",e.initialI18nStore&&(o.i18n.services.resourceStore.data=e.initialI18nStore,y=!1),e.initialLanguage&&o.i18n.changeLanguage(e.initialLanguage),o.i18n.options.isInitialSSR&&(y=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return O(n,e),b(n,[{key:"getChildContext",value:function(){var t;return t={},S(t,d,this[d]),S(t,"i18n",this.i18n),t}},{key:"componentWillMount",value:function(){this[d]=this.i18n.getFixedT(null,"fallback"===this.nsMode?t:t[0])}},{key:"componentDidMount",value:function(){var e=this,n=function(){p&&e.i18n&&e.i18n.on(p,e.onI18nChanged),c&&e.i18n.store&&e.i18n.store.on(c,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(t,function(){var t=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),y&&e.mounted&&n()};if(e.i18n.isInitialized)t();else{var i=function n(){setTimeout(function(){e.i18n.off("initialized",n)},1e3),t()};e.i18n.on("initialized",i)}}),y||n()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(p){p.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)})}if(c){c.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return a||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 t,e=this,n=this.state,i=n.i18nLoadedAt,r=n.ready,s=(t={i18nLoadedAt:i},S(t,d,this[d]),S(t,"i18n",this.i18n),t);return a&&(s.ref="wrappedInstance"),!r&&y?null:(this.i18n.options.isInitialSSR&&!w&&(w=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),f.createElement(o,x({},this.props,s)))}}]),n}(e.Component);return u.WrappedComponent=o,u.contextTypes={i18n:n.object},u.childContextTypes=(s={},S(s,d,n.func.isRequired),S(s,"i18n",n.object),s),u.displayName="Translate("+i(o)+")",u.namespaces=t,v(u,o)}}function o(t){return t&&(t.children||t.props&&t.props.children)}function a(t){return t&&t.children?t.children:t.props&&t.props.children}function s(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(o(e))t=t+"<"+i+">"+s("",a(e),n+1)+"</"+i+">";else if(f.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":g(e))){var r=x({},e),p=r.format;delete r.format;var u=Object.keys(r);p&&1===u.length?t=t+"<"+i+">{{"+u[0]+", "+p+"}}</"+i+">":1===u.length&&(t=t+"<"+i+">{{"+u[0]+"}}</"+i+">")}}),t}function p(t,e,n){function i(t,e){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);var r=e.split(T).reduce(function(t,e,n){return e&&t.push(e),t},[]);return r.reduce(function(e,s,p){var u=!isNaN(s),c=p>0&&!isNaN(r[p-1]);if(c){var l=t[parseInt(r[p-1],10)]||{};f.isValidElement(l)&&!o(l)&&(c=!1)}if(c)return e;if(u){var d=t[parseInt(s,10)]||{},h=f.isValidElement(d);if("string"==typeof d)e.push(d);else if(o(d)){var y=i(a(d),r[p+1]);e.push(f.cloneElement(d,x({},d.props,{key:p}),y))}else if("object"!==(void 0===d?"undefined":g(d))||h)e.push(d);else{var v=n.services.interpolator.interpolate(r[p+1],d,n.language);e.push(v)}}return u||c||e.push(s),e},[])}return i(t,e)}function u(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===g(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var u=I(s.value,2),c=u[0],l=u[1];e(l,n,c)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function c(t){var e=[];return u(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}function l(t){var e=t.components,n=t.i18n,i=c(e);return new Promise(function(t){n.loadNamespaces(i,t)})}var f="default"in e?e.default:e;n="default"in n?n.default:n;var d={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},h={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},y="function"==typeof Object.getOwnPropertySymbols,v=function(t,e,n){if("string"!=typeof e){var i=Object.getOwnPropertyNames(e);y&&(i=i.concat(Object.getOwnPropertySymbols(e)));for(var r=0;r<i.length;++r)if(!(d[i[r]]||h[i[r]]||n&&n[i[r]]))try{t[i[r]]=e[i[r]]}catch(t){}}return t},g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},b=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),S=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},x=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},O=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},j=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},I=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),w=!1,C=function(t){function e(t,n){m(this,e);var i=j(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return O(e,t),b(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=x({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return f.createElement("noscript",null);var c=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+u),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};u.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?f.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},c);var d={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(d["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(d.className=r),o&&(d.style=o),f.createElement.apply(this,[e,d].concat(c))}}]),e}(e.Component);C.propTypes={className:n.string},C.defaultProps={className:""},C.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var T=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),_=function(t){function e(t,n){m(this,e);var i=j(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return O(e,t),b(e,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=s("",e,0),o=this.props.i18nKey||r,a=this.t(o,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:r,count:n}),u={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){c=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(u["data-i18next-options"]=JSON.stringify({ns:c}))}return f.createElement(i,u,p(e,a,this.i18n))}}]),e}(f.Component);_.propTypes={count:n.number,parent:n.string,i18nKey:n.string},_.defaultProps={parent:"div"},_.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var P=function(t){function n(t,e){m(this,n);var i=j(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return O(n,t),b(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);P.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},P.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=r,t.Interpolate=C,t.I18nextProvider=P,t.Trans=_,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react","prop-types"],e):e(t.reactI18next=t.reactI18next||{},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){return t.displayName||t.name||"Component"}function o(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=o.translateFuncName,s=void 0===r?j.translateFuncName:r;return function(r){var a,p=function(e){function n(e,i){g(this,n);var r=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,i));r.i18n=i.i18n||e.i18n||o.i18n,"string"==typeof(t=t||r.i18n.options.defaultNS)&&(t=[t]);var s=r.i18n&&r.i18n.options.react||{};return r.options=I({},j,s,o),e.initialI18nStore&&(r.i18n.services.resourceStore.data=e.initialI18nStore,r.options.wait=!1),e.initialLanguage&&r.i18n.changeLanguage(e.initialLanguage),r.i18n.options.isInitialSSR&&(r.options.wait=!1),r.state={i18nLoadedAt:null,ready:!1},r.onI18nChanged=r.onI18nChanged.bind(r),r.getWrappedInstance=r.getWrappedInstance.bind(r),r}return x(n,e),b(n,[{key:"getChildContext",value:function(){var t;return t={},S(t,s,this[s]),S(t,"i18n",this.i18n),t}},{key:"componentWillMount",value:function(){this[s]=this.i18n.getFixedT(null,"fallback"===this.options.nsMode?t:t[0])}},{key:"componentDidMount",value:function(){var e=this,n=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(t,function(){var t=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&n()};if(e.i18n.isInitialized)t();else{var i=function n(){setTimeout(function(){e.i18n.off("initialized",n)},1e3),t()};e.i18n.on("initialized",i)}}),this.options.wait||n()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n){this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)})}if(this.options.bindStore){this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return this.options.withRef||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 t,e=this,n=this.state,i=n.i18nLoadedAt,o=n.ready,a=(t={i18nLoadedAt:i},S(t,s,this[s]),S(t,"i18n",this.i18n),t);return this.options.withRef&&(a.ref="wrappedInstance"),!o&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!C&&(C=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),f.createElement(r,I({},this.props,a)))}}]),n}(e.Component);return p.WrappedComponent=r,p.contextTypes={i18n:n.object},p.childContextTypes=(a={},S(a,s,n.func.isRequired),S(a,"i18n",n.object),a),p.displayName="Translate("+i(r)+")",p.namespaces=t,v(p,r)}}function r(t){return t&&(t.children||t.props&&t.props.children)}function s(t){return t&&t.children?t.children:t.props&&t.props.children}function a(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(r(e))t=t+"<"+i+">"+a("",s(e),n+1)+"</"+i+">";else if(f.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":m(e))){var o=I({},e),p=o.format;delete o.format;var u=Object.keys(o);p&&1===u.length?t=t+"<"+i+">{{"+u[0]+", "+p+"}}</"+i+">":1===u.length&&(t=t+"<"+i+">{{"+u[0]+"}}</"+i+">")}}),t}function p(t,e,n){function i(t,e){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]);var o=e.split(_).reduce(function(t,e,n){return e&&t.push(e),t},[]);return o.reduce(function(e,a,p){var u=!isNaN(a),c=p>0&&!isNaN(o[p-1]);if(c){var l=t[parseInt(o[p-1],10)]||{};f.isValidElement(l)&&!r(l)&&(c=!1)}if(c)return e;if(u){var d=t[parseInt(a,10)]||{},h=f.isValidElement(d);if("string"==typeof d)e.push(d);else if(r(d)){var y=i(s(d),o[p+1]);e.push(f.cloneElement(d,I({},d.props,{key:p}),y))}else if("object"!==(void 0===d?"undefined":m(d))||h)e.push(d);else{var v=n.services.interpolator.interpolate(o[p+1],d,n.language);e.push(v)}}return u||c||e.push(a),e},[])}return i(t,e)}function u(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===m(t[n])){var o=!0,r=!1,s=void 0;try{for(var a,p=Object.entries(t[n])[Symbol.iterator]();!(o=(a=p.next()).done);o=!0){var u=O(a.value,2),c=u[0],l=u[1];e(l,n,c)}}catch(t){r=!0,s=t}finally{try{!o&&p.return&&p.return()}finally{if(r)throw s}}}else e(t[n],n)}function c(t){var e=[];return u(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}function l(t){var e=t.components,n=t.i18n,i=c(e);return new Promise(function(t){n.loadNamespaces(i,t)})}var f="default"in e?e.default:e;n="default"in n?n.default:n;var d={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},h={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},y="function"==typeof Object.getOwnPropertySymbols,v=function(t,e,n){if("string"!=typeof e){var i=Object.getOwnPropertyNames(e);y&&(i=i.concat(Object.getOwnPropertySymbols(e)));for(var o=0;o<i.length;++o)if(!(d[i[o]]||h[i[o]]||n&&n[i[o]]))try{t[i[o]]=e[i[o]]}catch(t){}}return t},m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},b=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),S=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},I=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},x=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},w=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},O=function(){function t(t,e){var n=[],i=!0,o=!1,r=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);i=!0);}catch(t){o=!0,r=t}finally{try{!i&&a.return&&a.return()}finally{if(o)throw r}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),j={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},C=!1;o.setDefaults=function(t){j=I({},j,t)};var T=function(t){function e(t,n){g(this,e);var i=w(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return x(e,t),b(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,o=i.className,r=i.style,s=this.props.useDangerouslySetInnerHTML||!1,a=this.props.dangerouslySetInnerHTMLPartElement||"span",p=I({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return f.createElement("noscript",null);var c=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+u),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),o=i.shift().trim(),r=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[o]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+o+" for interpolating "+u),t.i18n.options.interpolation.format(n[o],r,t.i18n.language)};u.split(n).reduce(function(e,n,i){var o=void 0;if(i%2==0){if(0===n.length)return e;o=s?f.createElement(a,{dangerouslySetInnerHTML:{__html:n}}):n}else o=l(n,t.props);return e.push(o),e},c);var d={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(d["data-i18next-options"]=JSON.stringify({ns:h}))}return o&&(d.className=o),r&&(d.style=r),f.createElement.apply(this,[e,d].concat(c))}}]),e}(e.Component);T.propTypes={className:n.string},T.defaultProps={className:""},T.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var _=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),N=function(t){function e(t,n){g(this,e);var i=w(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return x(e,t),b(e,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,o=a("",e,0),r=this.props.i18nKey||o,s=this.t(r,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:o,count:n}),u={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1){c=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]}this.t.ns&&(u["data-i18next-options"]=JSON.stringify({ns:c}))}return f.createElement(i,u,p(e,s,this.i18n))}}]),e}(f.Component);N.propTypes={count:n.number,parent:n.string,i18nKey:n.string},N.defaultProps={parent:"div"},N.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var P=function(t){function n(t,e){g(this,n);var i=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return x(n,t),b(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);P.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},P.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=o,t.Interpolate=T,t.I18nextProvider=P,t.Trans=N,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -5,2 +5,11 @@ import React, { Component } from 'react';

let defaultOptions = {
wait: false,
withRef: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
};
function getDisplayName(component) {

@@ -13,4 +22,3 @@ return component.displayName || component.name || 'Component';

export default function translate(namespaces, options = {}) {
const { withRef = false, bindI18n = 'languageChanged loaded', bindStore = 'added removed', translateFuncName = 't' } = options;
let { wait = false } = options;
const { translateFuncName = defaultOptions.translateFuncName } = options;

@@ -27,10 +35,9 @@ return function Wrapper(WrappedComponent) {

if (!wait && this.i18n.options && (this.i18n.options.wait || (this.i18n.options.react && this.i18n.options.react.wait))) wait = true;
const i18nOptions = (this.i18n && this.i18n.options.react) || {};
this.options = { ...defaultOptions, ...i18nOptions, ...options };
this.nsMode = options.nsMode || (this.i18n.options && this.i18n.options.react && this.i18n.options.react.nsMode) || 'default';
// nextjs SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore) {
this.i18n.services.resourceStore.data = props.initialI18nStore;
wait = false; // we got all passed down already
this.options.wait = false; // we got all passed down already
}

@@ -43,3 +50,3 @@ if (props.initialLanguage) {

if (this.i18n.options.isInitialSSR) {
wait = false;
this.options.wait = false;
}

@@ -64,3 +71,3 @@

componentWillMount() {
this[translateFuncName] = this.i18n.getFixedT(null, this.nsMode === 'fallback' ? namespaces : namespaces[0]);
this[translateFuncName] = this.i18n.getFixedT(null, this.options.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

@@ -70,4 +77,4 @@

const bind = () => {
if (bindI18n && this.i18n) this.i18n.on(bindI18n, this.onI18nChanged);
if (bindStore && this.i18n.store) this.i18n.store.on(bindStore, this.onI18nChanged);
if (this.options.bindI18n && this.i18n) this.i18n.on(this.options.bindI18n, this.onI18nChanged);
if (this.options.bindStore && this.i18n.store) this.i18n.store.on(this.options.bindStore, this.onI18nChanged);
};

@@ -79,3 +86,3 @@

if (this.mounted && !this.state.ready) this.setState({ ready: true });
if (wait && this.mounted) bind();
if (this.options.wait && this.mounted) bind();
};

@@ -98,3 +105,3 @@

if (!wait) bind();
if (!this.options.wait) bind();
}

@@ -105,8 +112,8 @@

if (this.onI18nChanged) {
if (bindI18n) {
const p = bindI18n.split(' ');
if (this.options.bindI18n) {
const p = this.options.bindI18n.split(' ');
p.forEach(f => this.i18n.off(f, this.onI18nChanged));
}
if (bindStore) {
const p = bindStore.split(' ');
if (this.options.bindStore) {
const p = this.options.bindStore.split(' ');
p.forEach(f => this.i18n.store && this.i18n.store.off(f, this.onI18nChanged));

@@ -124,3 +131,3 @@ }

getWrappedInstance() {
if (!withRef) {
if (!this.options.withRef) {
// eslint-disable-next-line no-console

@@ -145,7 +152,7 @@ console.error(

if (withRef) {
if (this.options.withRef) {
extraProps.ref = 'wrappedInstance';
}
if (!ready && wait) return null;
if (!ready && this.options.wait) return null;

@@ -185,1 +192,5 @@ // remove ssr flag set by provider - first render was done from now on wait if set to wait

}
translate.setDefaults = function set(options) {
defaultOptions = { ...defaultOptions, ...options };
};
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