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

react-i18next

Package Overview
Dependencies
Maintainers
2
Versions
316
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18next - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

10

CHANGELOG.md

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

### 5.1.0
- you now can set i18n instance on translate hoc once using setI18n:
```
import translate from 'react-i18next';
import i18n from './i18n';
translate.setI18n(i18n);
```
### 5.0.0

@@ -2,0 +12,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 } }`

10

dist/amd/react-i18next.js

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

var i18n = void 0;
function getDisplayName(component) {

@@ -239,3 +241,3 @@ return component.displayName || component.name || 'Component';

_this.i18n = context.i18n || props.i18n || options.i18n;
_this.i18n = context.i18n || props.i18n || options.i18n || i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -406,6 +408,10 @@ if (typeof namespaces === 'string') namespaces = [namespaces];

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

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

2

dist/amd/react-i18next.min.js

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

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})});
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||C,"string"==typeof(t=t||r.i18n.options.defaultNS)&&(t=[t]);var s=r.i18n&&r.i18n.options.react||{};return r.options=I({},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 w(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&&!_&&(_=!0,setTimeout(function(){delete n.i18n.options.isInitialSSR},100)),f.createElement(r,I({},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=I({},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(T).reduce(function(t,n,e){return n&&t.push(n),t},[]);return o.reduce(function(n,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 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,I({},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||c||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),c=u[0],l=u[1];n(l,e,c)}}catch(t){r=!0,s=t}finally{try{!o&&p.return&&p.return()}finally{if(r)throw s}}}else n(t[e],e)}function c(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 l(t){var n=t.components,e=t.i18n,i=c(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},I=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},w=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=void 0,_=!1;o.setDefaults=function(t){x=I({},x,t)},o.setI18n=function(t){C=t};var N=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 w(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=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(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=l(e,t.props);return n.push(o),n},c);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(c))}}]),n}(n.Component);N.propTypes={className:e.string},N.defaultProps={className:""},N.contextTypes={i18n:e.object.isRequired,t:e.func.isRequired};var T=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),P=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 w(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 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(n,s,this.i18n))}}]),n}(f.Component);P.propTypes={count:e.number,parent:e.string,i18nKey:e.string},P.defaultProps={parent:"div"},P.contextTypes={i18n:e.object.isRequired,t:e.func.isRequired};var E=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 w(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);E.propTypes={i18n:e.object.isRequired,children:e.element.isRequired},E.childContextTypes={i18n:e.object.isRequired},t.loadNamespaces=l,t.translate=o,t.Interpolate=N,t.I18nextProvider=E,t.Trans=P,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -44,2 +44,4 @@ 'use strict';

var i18n = void 0;
function getDisplayName(component) {

@@ -68,3 +70,3 @@ return component.displayName || component.name || 'Component';

_this.i18n = context.i18n || props.i18n || options.i18n;
_this.i18n = context.i18n || props.i18n || options.i18n || i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -236,4 +238,8 @@ if (typeof namespaces === 'string') namespaces = [namespaces];

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

@@ -26,2 +26,4 @@ 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 i18n = void 0;
function getDisplayName(component) {

@@ -50,3 +52,3 @@ return component.displayName || component.name || 'Component';

_this.i18n = context.i18n || props.i18n || options.i18n;
_this.i18n = context.i18n || props.i18n || options.i18n || i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -218,4 +220,8 @@ if (typeof namespaces === 'string') namespaces = [namespaces];

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

@@ -219,2 +219,4 @@ (function (global, factory) {

var i18n = void 0;
function getDisplayName(component) {

@@ -243,3 +245,3 @@ return component.displayName || component.name || 'Component';

_this.i18n = context.i18n || props.i18n || options.i18n;
_this.i18n = context.i18n || props.i18n || options.i18n || i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -410,6 +412,10 @@ if (typeof namespaces === 'string') namespaces = [namespaces];

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

@@ -416,0 +422,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 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})});
!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||C,"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&&!T&&(T=!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(N).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=void 0,T=!1;o.setDefaults=function(t){j=I({},j,t)},o.setI18n=function(t){C=t};var _=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);_.propTypes={className:n.string},_.defaultProps={className:""},_.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var N=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),P=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);P.propTypes={count:n.number,parent:n.string,i18nKey:n.string},P.defaultProps={parent:"div"},P.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var E=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);E.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},E.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=o,t.Interpolate=_,t.I18nextProvider=E,t.Trans=P,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "react-i18next",
"version": "5.0.0",
"version": "5.1.0",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",

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

@@ -219,2 +219,4 @@ (function (global, factory) {

var i18n = void 0;
function getDisplayName(component) {

@@ -243,3 +245,3 @@ return component.displayName || component.name || 'Component';

_this.i18n = context.i18n || props.i18n || options.i18n;
_this.i18n = context.i18n || props.i18n || options.i18n || i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -410,6 +412,10 @@ if (typeof namespaces === 'string') namespaces = [namespaces];

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

@@ -416,0 +422,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 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})});
!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||C,"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&&!T&&(T=!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(N).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=void 0,T=!1;o.setDefaults=function(t){j=I({},j,t)},o.setI18n=function(t){C=t};var _=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);_.propTypes={className:n.string},_.defaultProps={className:""},_.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var N=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),P=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);P.propTypes={count:n.number,parent:n.string,i18nKey:n.string},P.defaultProps={parent:"div"},P.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var E=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);E.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},E.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=l,t.translate=o,t.Interpolate=_,t.I18nextProvider=E,t.Trans=P,Object.defineProperty(t,"__esModule",{value:!0})});

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

let i18n;
function getDisplayName(component) {

@@ -30,3 +32,3 @@ return component.displayName || component.name || 'Component';

this.i18n = context.i18n || props.i18n || options.i18n;
this.i18n = context.i18n || props.i18n || options.i18n || i18n;
namespaces = namespaces || this.i18n.options.defaultNS;

@@ -184,4 +186,8 @@ if (typeof namespaces === 'string') namespaces = [namespaces];

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