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