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 4.2.0 to 4.3.0

3

CHANGELOG.md

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

### 4.3.0
- allow passing down initialI18nStore and initialLanguage to translate hoc to support ssr scenario better see example/nextjs
### 4.2.0

@@ -2,0 +5,0 @@ - allow passing i18next instance in translate hoc options makes integration in nextjs easier

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

// SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore && props.initialLanguage) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
_this.i18n.changeLanguage(props.initialLanguage);
wait = false; // we got all passed down already
}
_this.state = {

@@ -243,0 +250,0 @@ i18nLoadedAt: null,

2

dist/amd/react-i18next.min.js

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

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

@@ -70,2 +70,9 @@ 'use strict';

// SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore && props.initialLanguage) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
_this.i18n.changeLanguage(props.initialLanguage);
wait = false; // we got all passed down already
}
_this.state = {

@@ -72,0 +79,0 @@ i18nLoadedAt: null,

@@ -52,2 +52,9 @@ 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; };

// SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore && props.initialLanguage) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
_this.i18n.changeLanguage(props.initialLanguage);
wait = false; // we got all passed down already
}
_this.state = {

@@ -54,0 +61,0 @@ i18nLoadedAt: null,

@@ -245,2 +245,9 @@ (function (global, factory) {

// SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore && props.initialLanguage) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
_this.i18n.changeLanguage(props.initialLanguage);
wait = false; // we got all passed down already
}
_this.state = {

@@ -247,0 +254,0 @@ i18nLoadedAt: null,

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

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

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

@@ -245,2 +245,9 @@ (function (global, factory) {

// SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore && props.initialLanguage) {
_this.i18n.services.resourceStore.data = props.initialI18nStore;
_this.i18n.changeLanguage(props.initialLanguage);
wait = false; // we got all passed down already
}
_this.state = {

@@ -247,0 +254,0 @@ i18nLoadedAt: null,

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

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

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

super(props, context);
this.i18n = context.i18n || props.i18n || options.i18n;

@@ -27,2 +28,9 @@ namespaces = namespaces || this.i18n.options.defaultNS;

// SSR: getting data from next.js or other ssr stack
if (props.initialI18nStore && props.initialLanguage) {
this.i18n.services.resourceStore.data = props.initialI18nStore;
this.i18n.changeLanguage(props.initialLanguage);
wait = false; // we got all passed down already
}
this.state = {

@@ -29,0 +37,0 @@ i18nLoadedAt: null,

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