diff --git a/.gitignore b/.gitignore index a1b5a529a..6f4b703ca 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ npm-debug.log.* # Ignore various temporary files *~ *.swp +.idea/ # Ignore various Node.js related directories and files diff --git a/react-i18next.js b/react-i18next.js index 1b1d13253..357643761 100644 --- a/react-i18next.js +++ b/react-i18next.js @@ -168,6 +168,7 @@ _this2.setState({ ready: true }); }); this.i18n.on('languageChanged loaded', this.onI18nChanged); + this.i18n.store.on('added removed', this.onI18nChanged); } }, { key: 'componentWillUnmount', @@ -176,6 +177,8 @@ if (this.onI18nChanged) { this.i18n.off('languageChanged', this.onI18nChanged); this.i18n.off('loaded', this.onI18nChanged); + this.i18n.store.off('added', this.onI18nChanged); + this.i18n.store.off('removed', this.onI18nChanged); } } }, { diff --git a/react-i18next.min.js b/react-i18next.min.js index 939840082..26e2dd6d6 100644 --- a/react-i18next.min.js +++ b/react-i18next.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e.displayName||e.name||"Component"}function r(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=r.withRef,i=void 0===o?!1:o,a=r.wait,u=void 0===a?!1:a;return function(r){var o=function(t){function n(t,r){c.classCallCheck(this,n);var o=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,t,r));return o.i18n=r.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return c.inherits(n,t),c.createClass(n,[{key:"getChildContext",value:function(){return{t:this.t}}},{key:"componentWillMount",value:function(){this.t=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(this.i18n.off("languageChanged",this.onI18nChanged),this.i18n.off("loaded",this.onI18nChanged))}},{key:"onI18nChanged",value:function(){this.mounted&&this.setState({i18nLoadedAt:new Date})}},{key:"getWrappedInstance",value:function(){return i||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e=this.state,t=e.i18nLoadedAt,n=e.ready,o={i18nLoadedAt:t,t:this.t};return i&&(o.ref="wrappedInstance"),!n&&u?null:s.createElement(r,c["extends"]({},this.props,o))}}]),n}(t.Component);return o.WrappedComponent=r,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes={t:t.PropTypes.func.isRequired},o.displayName="Translate["+n(r)+"]",o.namespaces=e,o}}function o(e,t){for(var n=0,r=e.length;r>n;n++)if("object"===c["typeof"](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 l=c.slicedToArray(s.value,2),p=l[0],f=l[1];t(f,n,p)}}catch(h){i=!0,a=h}finally{try{!o&&u["return"]&&u["return"]()}finally{if(i)throw a}}}else t(e[n],n)}function i(e){var t=[];return o(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}function a(e){var t=e.components,n=e.i18n,r=i(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var s="default"in t?t["default"]:t,c={};c["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},c.createClass=function(){function e(e,t){for(var n=0;n