react-i18next
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -1,2 +0,2 @@ | ||
### 2.2.2 | ||
### 2.2.3 | ||
- try not access store if undefined for hmr | ||
@@ -3,0 +3,0 @@ |
@@ -284,3 +284,3 @@ define('reactI18next', ['exports', 'react'], function (exports, React) { 'use strict'; | ||
_p.forEach(function (f) { | ||
return _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
}); | ||
@@ -287,0 +287,0 @@ } |
@@ -1,1 +0,1 @@ | ||
define("reactI18next",["exports","react"],function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.bindI18n,c=void 0===u?"languageChanged loaded":u,f=n.bindStore,g=void 0===f?"added removed":f,w=n.translateFuncName,x=void 0===w?"t":w;return function(n){var r=function(t){function r(t,n){d(this,r);var o=b(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n||t.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),y(r,[{key:"getChildContext",value:function(){return h({},x,this[x])}},{key:"componentWillMount",value:function(){this[x]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this,n=function(){c&&t.i18n.on(c,t.onI18nChanged),g&&t.i18n.store&&t.i18n.store.on(g,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),s&&t.mounted&&n()};if(t.i18n.isInitialized)return e();var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}),s||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(c){var t=c.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(g){var n=g.split(" ");n.forEach(function(t){return e.i18n.store.off(t,e.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,t=this.state,r=t.i18nLoadedAt,o=t.ready,a=(e={i18nLoadedAt:r},h(e,x,this[x]),h(e,"i18n",this.i18n),e);return i&&(a.ref="wrappedInstance"),!o&&s?null:p.createElement(n,v({},this.props,a))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object},r.childContextTypes=h({},x,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=g(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},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},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),w=function(e){function t(e,n){d(this,t);var r=b(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),y(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[t]&&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)};return 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),p.createElement.apply(this,[t,{className:o,style:i}].concat(l))}}]),t}(t.Component);w.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},w.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var x=function(e){function n(e,t){d(this,n);var r=b(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);x.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},x.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=w,e.I18nextProvider=x,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
define("reactI18next",["exports","react"],function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.bindI18n,c=void 0===u?"languageChanged loaded":u,f=n.bindStore,g=void 0===f?"added removed":f,w=n.translateFuncName,x=void 0===w?"t":w;return function(n){var r=function(t){function r(t,n){d(this,r);var o=b(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n||t.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),y(r,[{key:"getChildContext",value:function(){return h({},x,this[x])}},{key:"componentWillMount",value:function(){this[x]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this,n=function(){c&&t.i18n.on(c,t.onI18nChanged),g&&t.i18n.store&&t.i18n.store.on(g,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),s&&t.mounted&&n()};if(t.i18n.isInitialized)return e();var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}),s||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(c){var t=c.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(g){var n=g.split(" ");n.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 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,t=this.state,r=t.i18nLoadedAt,o=t.ready,a=(e={i18nLoadedAt:r},h(e,x,this[x]),h(e,"i18n",this.i18n),e);return i&&(a.ref="wrappedInstance"),!o&&s?null:p.createElement(n,v({},this.props,a))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object},r.childContextTypes=h({},x,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=g(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},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},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),w=function(e){function t(e,n){d(this,t);var r=b(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),y(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[t]&&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)};return 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),p.createElement.apply(this,[t,{className:o,style:i}].concat(l))}}]),t}(t.Component);w.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},w.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var x=function(e){function n(e,t){d(this,n);var r=b(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);x.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},x.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=w,e.I18nextProvider=x,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -126,3 +126,3 @@ 'use strict'; | ||
_p.forEach(function (f) { | ||
return _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
}); | ||
@@ -129,0 +129,0 @@ } |
@@ -111,3 +111,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
_p.forEach(function (f) { | ||
return _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
}); | ||
@@ -114,0 +114,0 @@ } |
@@ -288,3 +288,3 @@ (function (global, factory) { | ||
_p.forEach(function (f) { | ||
return _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
}); | ||
@@ -291,0 +291,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.bindI18n,c=void 0===u?"languageChanged loaded":u,f=n.bindStore,g=void 0===f?"added removed":f,x=n.translateFuncName,w=void 0===x?"t":x;return function(n){var r=function(t){function r(t,n){d(this,r);var o=b(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n||t.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),y(r,[{key:"getChildContext",value:function(){return h({},w,this[w])}},{key:"componentWillMount",value:function(){this[w]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this,n=function(){c&&t.i18n.on(c,t.onI18nChanged),g&&t.i18n.store&&t.i18n.store.on(g,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),s&&t.mounted&&n()};if(t.i18n.isInitialized)return e();var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}),s||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(c){var t=c.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(g){var n=g.split(" ");n.forEach(function(t){return e.i18n.store.off(t,e.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,t=this.state,r=t.i18nLoadedAt,o=t.ready,a=(e={i18nLoadedAt:r},h(e,w,this[w]),h(e,"i18n",this.i18n),e);return i&&(a.ref="wrappedInstance"),!o&&s?null:p.createElement(n,v({},this.props,a))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object},r.childContextTypes=h({},w,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=g(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},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},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x=function(e){function t(e,n){d(this,t);var r=b(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),y(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[t]&&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)};return 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),p.createElement.apply(this,[t,{className:o,style:i}].concat(l))}}]),t}(t.Component);x.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},x.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var w=function(e){function n(e,t){d(this,n);var r=b(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);w.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},w.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=x,e.I18nextProvider=w,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.bindI18n,c=void 0===u?"languageChanged loaded":u,f=n.bindStore,g=void 0===f?"added removed":f,x=n.translateFuncName,w=void 0===x?"t":x;return function(n){var r=function(t){function r(t,n){d(this,r);var o=b(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n||t.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),y(r,[{key:"getChildContext",value:function(){return h({},w,this[w])}},{key:"componentWillMount",value:function(){this[w]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this,n=function(){c&&t.i18n.on(c,t.onI18nChanged),g&&t.i18n.store&&t.i18n.store.on(g,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),s&&t.mounted&&n()};if(t.i18n.isInitialized)return e();var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}),s||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(c){var t=c.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(g){var n=g.split(" ");n.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 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,t=this.state,r=t.i18nLoadedAt,o=t.ready,a=(e={i18nLoadedAt:r},h(e,w,this[w]),h(e,"i18n",this.i18n),e);return i&&(a.ref="wrappedInstance"),!o&&s?null:p.createElement(n,v({},this.props,a))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object},r.childContextTypes=h({},w,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=g(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},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},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x=function(e){function t(e,n){d(this,t);var r=b(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),y(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[t]&&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)};return 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),p.createElement.apply(this,[t,{className:o,style:i}].concat(l))}}]),t}(t.Component);x.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},x.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var w=function(e){function n(e,t){d(this,n);var r=b(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);w.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},w.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=x,e.I18nextProvider=w,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "react-i18next", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js", |
@@ -288,3 +288,3 @@ (function (global, factory) { | ||
_p.forEach(function (f) { | ||
return _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
return _this3.i18n.store && _this3.i18n.store.off(f, _this3.onI18nChanged); | ||
}); | ||
@@ -291,0 +291,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.bindI18n,c=void 0===u?"languageChanged loaded":u,f=n.bindStore,g=void 0===f?"added removed":f,x=n.translateFuncName,w=void 0===x?"t":x;return function(n){var r=function(t){function r(t,n){d(this,r);var o=b(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n||t.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),y(r,[{key:"getChildContext",value:function(){return h({},w,this[w])}},{key:"componentWillMount",value:function(){this[w]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this,n=function(){c&&t.i18n.on(c,t.onI18nChanged),g&&t.i18n.store&&t.i18n.store.on(g,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),s&&t.mounted&&n()};if(t.i18n.isInitialized)return e();var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}),s||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(c){var t=c.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(g){var n=g.split(" ");n.forEach(function(t){return e.i18n.store.off(t,e.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,t=this.state,r=t.i18nLoadedAt,o=t.ready,a=(e={i18nLoadedAt:r},h(e,w,this[w]),h(e,"i18n",this.i18n),e);return i&&(a.ref="wrappedInstance"),!o&&s?null:p.createElement(n,v({},this.props,a))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object},r.childContextTypes=h({},w,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=g(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},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},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x=function(e){function t(e,n){d(this,t);var r=b(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),y(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[t]&&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)};return 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),p.createElement.apply(this,[t,{className:o,style:i}].concat(l))}}]),t}(t.Component);x.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},x.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var w=function(e){function n(e,t){d(this,n);var r=b(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);w.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},w.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=x,e.I18nextProvider=w,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e,t){return t={exports:{}},e(t,t.exports),t.exports}function o(e){return e.displayName||e.name||"Component"}function i(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=n.withRef,i=void 0!==r&&r,a=n.wait,s=void 0!==a&&a,u=n.bindI18n,c=void 0===u?"languageChanged loaded":u,f=n.bindStore,g=void 0===f?"added removed":f,x=n.translateFuncName,w=void 0===x?"t":x;return function(n){var r=function(t){function r(t,n){d(this,r);var o=b(this,Object.getPrototypeOf(r).call(this,t,n));return o.i18n=n.i18n||t.i18n,e=e||o.i18n.options.defaultNS,o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o}return m(r,t),y(r,[{key:"getChildContext",value:function(){return h({},w,this[w])}},{key:"componentWillMount",value:function(){this[w]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this,n=function(){c&&t.i18n.on(c,t.onI18nChanged),g&&t.i18n.store&&t.i18n.store.on(g,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),s&&t.mounted&&n()};if(t.i18n.isInitialized)return e();var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}),s||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(c){var t=c.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(g){var n=g.split(" ");n.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 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,t=this.state,r=t.i18nLoadedAt,o=t.ready,a=(e={i18nLoadedAt:r},h(e,w,this[w]),h(e,"i18n",this.i18n),e);return i&&(a.ref="wrappedInstance"),!o&&s?null:p.createElement(n,v({},this.props,a))}}]),r}(t.Component);return r.WrappedComponent=n,r.contextTypes={i18n:t.PropTypes.object},r.childContextTypes=h({},w,t.PropTypes.func.isRequired),r.displayName="Translate("+o(n)+")",r.namespaces=e,l(r,n)}}function a(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===f(e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var p=g(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function s(e){var t=[];return a(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function u(e){var t=e.components,n=e.i18n,r=s(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var p="default"in t?t.default:t,c=r(function(e){var t={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},r="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,o,i){if("string"!=typeof o){var a=Object.getOwnPropertyNames(o);r&&(a=a.concat(Object.getOwnPropertySymbols(o)));for(var s=0;s<a.length;++s)if(!(t[a[s]]||n[a[s]]||i&&i[a[s]]))try{e[a[s]]=o[a[s]]}catch(e){}}return e}}),l=n(c),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},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},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},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},g=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),x=function(e){function t(e,n){d(this,t);var r=b(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),y(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[t]&&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)};return 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),p.createElement.apply(this,[t,{className:o,style:i}].concat(l))}}]),t}(t.Component);x.propTypes={children:t.PropTypes.node,className:t.PropTypes.string},x.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var w=function(e){function n(e,t){d(this,n);var r=b(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);w.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},w.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=u,e.translate=i,e.Interpolate=x,e.I18nextProvider=w,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -71,3 +71,3 @@ import React, { Component, PropTypes } from 'react'; | ||
const p = bindStore.split(' '); | ||
p.forEach(f => this.i18n.store.off(f, this.onI18nChanged)); | ||
p.forEach(f => this.i18n.store && this.i18n.store.off(f, this.onI18nChanged)); | ||
} | ||
@@ -74,0 +74,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140909