Socket
Socket
Sign inDemoInstall

react-i18next

Package Overview
Dependencies
Maintainers
2
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18next - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

4

CHANGELOG.md

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

### 4.5.0
- pass i18n instance to context inside translate hoc to simplify usage in nextjs
- options.react.exposeNamespace will expose namespace on data-i18next-options for consuming in editors
### 4.4.0

@@ -2,0 +6,0 @@ - introduces Trans component which enables you to translate nested components incl. interpolation by resulting in one translatable string. [learn more](https://react.i18next.com/components/trans-component.html)

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

return function Wrapper(WrappedComponent) {
var _Translate$childConte;
var Translate = function (_Component) {

@@ -262,3 +264,5 @@ inherits(Translate, _Component);

value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
var _ref;
return _ref = {}, defineProperty(_ref, translateFuncName, this[translateFuncName]), defineProperty(_ref, 'i18n', this.i18n), _ref;
}

@@ -352,3 +356,5 @@ }, {

var extraProps = (_extraProps = { i18nLoadedAt: i18nLoadedAt }, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);
var extraProps = (_extraProps = {
i18nLoadedAt: i18nLoadedAt
}, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);

@@ -373,3 +379,3 @@ if (withRef) {

Translate.childContextTypes = defineProperty({}, translateFuncName, PropTypes.func.isRequired);
Translate.childContextTypes = (_Translate$childConte = {}, defineProperty(_Translate$childConte, translateFuncName, PropTypes.func.isRequired), defineProperty(_Translate$childConte, 'i18n', PropTypes.object), _Translate$childConte);

@@ -454,2 +460,11 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
if (className) additionalProps.className = className;

@@ -579,3 +594,13 @@ if (style) additionalProps.style = style;

return React__default.createElement('div', {}, renderNodes(children, translation, this.i18n));
var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
return React__default.createElement('div', additionalProps, renderNodes(children, translation, this.i18n));
}

@@ -582,0 +607,0 @@ }]);

2

dist/amd/react-i18next.min.js

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

define("reactI18next",["exports","react","prop-types"],function(e,t,n){"use strict";function r(e){return e.displayName||e.name||"Component"}function i(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.withRef,a=void 0!==o&&o,s=i.bindI18n,u=void 0===s?"languageChanged loaded":s,p=i.bindStore,l=void 0===p?"added removed":p,f=i.translateFuncName,d=void 0===f?"t":f,y=i.wait,O=void 0!==y&&y;return function(o){var s=function(t){function n(t,r){v(this,n);var o=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r));return o.i18n=r.i18n||t.i18n||i.i18n,e=e||o.i18n.options.defaultNS,"string"==typeof e&&(e=[e]),!O&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(O=!0),o.nsMode=i.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",t.initialI18nStore&&t.initialLanguage&&(o.i18n.services.resourceStore.data=t.initialI18nStore,o.i18n.changeLanguage(t.initialLanguage),O=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return j(n,t),m(n,[{key:"getChildContext",value:function(){return g({},d,this[d])}},{key:"componentWillMount",value:function(){this[d]=this.i18n.getFixedT(null,"fallback"===this.nsMode?e:e[0])}},{key:"componentDidMount",value:function(){var t=this,n=function(){u&&t.i18n&&t.i18n.on(u,t.onI18nChanged),l&&t.i18n.store&&t.i18n.store.on(l,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),O&&t.mounted&&n()};if(t.i18n.isInitialized)e();else{var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}}),O||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(u){var t=u.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(l){var n=l.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 a||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e,t=this.state,n=t.i18nLoadedAt,r=t.ready,i=(e={i18nLoadedAt:n},g(e,d,this[d]),g(e,"i18n",this.i18n),e);return a&&(i.ref="wrappedInstance"),!r&&O?null:c.createElement(o,b({},this.props,i))}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object},s.childContextTypes=g({},d,n.func.isRequired),s.displayName="Translate("+r(o)+")",s.namespaces=e,h(s,o)}}function o(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var r=""+n;if("string"==typeof t)e=""+e+t;else if(t.props&&t.props.children)e=e+"<"+r+">"+o("",t.props.children,n+1)+"</"+r+">";else if("object"===("undefined"==typeof t?"undefined":y(t))){var i=b({},t),a=i.format;delete i.format;var s=Object.keys(i);a&&1===s.length?e=e+"<"+r+">{{"+s[0]+", "+a+"}}</"+r+">":1===s.length&&(e=e+"<"+r+">{{"+s[0]+"}}</"+r+">")}}),e}function a(e,t,n){function r(e,t){"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]);var i=t.split(I).reduce(function(e,t,n){return t&&e.push(t),e},[]);return i.reduce(function(t,o,a){var s=!isNaN(o),u=a>0&&!isNaN(i[a-1]);if(u)return t;if(s){var p=e[parseInt(o,10)]||{},l=c.isValidElement(p);if("string"==typeof p)t.push(p);else if(p.props&&p.props.children){var f=r(p.props&&p.props.children,i[a+1]);t.push(c.cloneElement(p,b({},p.props,{key:a}),f))}else if("object"===("undefined"==typeof p?"undefined":y(p))&&!l){var d=n.services.interpolator.interpolate(i[a+1],p,n.language);t.push(d)}}return s||u||t.push(o),t},[])}return r(e,t)}function s(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===y(e[n])){var i=!0,o=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var p=O(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){o=!0,a=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw a}}}else t(e[n],n)}function u(e){var t=[];return s(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function p(e){var t=e.components,n=e.i18n,r=u(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var c="default"in t?t.default:t;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(e,t,n){if("string"!=typeof t){var r=Object.getOwnPropertyNames(t);d&&(r=r.concat(Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;++i)if(!(l[r[i]]||f[r[i]]||n&&n[r[i]]))try{e[r[i]]=t[r[i]]}catch(e){}}return e},y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},m=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}}(),g=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},b=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},j=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)},w=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},O=function(){function e(e,t){var n=[],r=!0,i=!1,o=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){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}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){v(this,t);var r=w(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return j(t,e),m(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,i=r.className,o=r.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",u=b({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,u);if(!p||"string"!=typeof p)return c.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 "+p),n[t];var r=t.split(e.i18n.options.interpolation.formatSeparator),i=r.shift().trim(),o=r.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[i]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+i+" for interpolating "+p),e.i18n.options.interpolation.format(n[i],o,e.i18n.language)};p.split(n).reduce(function(t,n,r){var i=void 0;if(r%2===0){if(0===n.length)return t;i=a?c.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else i=f(n,e.props);return t.push(i),t},l);var d={};return i&&(d.className=i),o&&(d.style=o),c.createElement.apply(this,[t,d].concat(l))}}]),t}(t.Component);x.propTypes={className:n.string},x.defaultProps={className:""},x.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var I=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),S=function(e){function t(e,n){v(this,t);var r=w(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return j(t,e),m(t,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var e=this.props,t=e.children,n=e.count,r=o("",t,0),i=this.props.i18nKey||r,s=this.t(i,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:r,count:n});return c.createElement("div",{},a(t,s,this.i18n))}}]),t}(c.Component);S.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var C=function(e){function n(e,t){v(this,n);var r=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return r.i18n=e.i18n,r}return j(n,e),m(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);C.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},C.childContextTypes={i18n:n.object.isRequired},e.loadNamespaces=p,e.translate=i,e.Interpolate=x,e.I18nextProvider=C,e.Trans=S,Object.defineProperty(e,"__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,x=void 0!==y&&y;return function(o){var s,u=function(e){function n(e,i){v(this,n);var o=j(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]),!x&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(x=!0),o.nsMode=r.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",e.initialI18nStore&&e.initialLanguage&&(o.i18n.services.resourceStore.data=e.initialI18nStore,o.i18n.changeLanguage(e.initialLanguage),x=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return O(n,e),m(n,[{key:"getChildContext",value:function(){var t;return t={},g(t,d,this[d]),g(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.setState({ready:!0}),x&&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)}}),x||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.state,n=e.i18nLoadedAt,i=e.ready,r=(t={i18nLoadedAt:n},g(t,d,this[d]),g(t,"i18n",this.i18n),t);return a&&(r.ref="wrappedInstance"),!i&&x?null:c.createElement(o,b({},this.props,r))}}]),n}(e.Component);return u.WrappedComponent=o,u.contextTypes={i18n:n.object},u.childContextTypes=(s={},g(s,d,n.func.isRequired),g(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=x(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")},m=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}}(),g=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},O=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)},j=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},x=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")}}(),S=function(t){function e(t,n){v(this,e);var i=j(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return O(e,t),m(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);S.propTypes={className:n.string},S.defaultProps={className:""},S.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var w=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),I=function(t){function e(t,n){v(this,e);var i=j(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=n.i18n,i.t=n.t,i}return O(e,t),m(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);I.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var C=function(t){function n(t,e){v(this,n);var i=j(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,i}return O(n,t),m(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);C.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},C.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=u,t.translate=r,t.Interpolate=S,t.I18nextProvider=C,t.Trans=I,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -97,2 +97,11 @@ 'use strict';

var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
if (className) additionalProps.className = className;

@@ -99,0 +108,0 @@ if (style) additionalProps.style = style;

@@ -131,3 +131,13 @@ 'use strict';

return _react2.default.createElement('div', {}, renderNodes(children, translation, this.i18n));
var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
return _react2.default.createElement('div', additionalProps, renderNodes(children, translation, this.i18n));
}

@@ -134,0 +144,0 @@ }]);

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

return function Wrapper(WrappedComponent) {
var _Translate$childConte;
var Translate = function (_Component) {

@@ -91,3 +93,5 @@ _inherits(Translate, _Component);

value: function getChildContext() {
return _defineProperty({}, translateFuncName, this[translateFuncName]);
var _ref;
return _ref = {}, _defineProperty(_ref, translateFuncName, this[translateFuncName]), _defineProperty(_ref, 'i18n', this.i18n), _ref;
}

@@ -181,3 +185,5 @@ }, {

var extraProps = (_extraProps = { i18nLoadedAt: i18nLoadedAt }, _defineProperty(_extraProps, translateFuncName, this[translateFuncName]), _defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);
var extraProps = (_extraProps = {
i18nLoadedAt: i18nLoadedAt
}, _defineProperty(_extraProps, translateFuncName, this[translateFuncName]), _defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);

@@ -203,3 +209,3 @@ if (withRef) {

Translate.childContextTypes = _defineProperty({}, translateFuncName, _propTypes2.default.func.isRequired);
Translate.childContextTypes = (_Translate$childConte = {}, _defineProperty(_Translate$childConte, translateFuncName, _propTypes2.default.func.isRequired), _defineProperty(_Translate$childConte, 'i18n', _propTypes2.default.object), _Translate$childConte);

@@ -206,0 +212,0 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

@@ -84,2 +84,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
if (className) additionalProps.className = className;

@@ -86,0 +95,0 @@ if (style) additionalProps.style = style;

@@ -118,3 +118,13 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

return React.createElement('div', {}, renderNodes(children, translation, this.i18n));
var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
return React.createElement('div', additionalProps, renderNodes(children, translation, this.i18n));
}

@@ -121,0 +131,0 @@ }]);

@@ -36,2 +36,4 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

return function Wrapper(WrappedComponent) {
var _Translate$childConte;
var Translate = function (_Component) {

@@ -73,3 +75,5 @@ _inherits(Translate, _Component);

value: function getChildContext() {
return _defineProperty({}, translateFuncName, this[translateFuncName]);
var _ref;
return _ref = {}, _defineProperty(_ref, translateFuncName, this[translateFuncName]), _defineProperty(_ref, 'i18n', this.i18n), _ref;
}

@@ -163,3 +167,5 @@ }, {

var extraProps = (_extraProps = { i18nLoadedAt: i18nLoadedAt }, _defineProperty(_extraProps, translateFuncName, this[translateFuncName]), _defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);
var extraProps = (_extraProps = {
i18nLoadedAt: i18nLoadedAt
}, _defineProperty(_extraProps, translateFuncName, this[translateFuncName]), _defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);

@@ -185,3 +191,3 @@ if (withRef) {

Translate.childContextTypes = _defineProperty({}, translateFuncName, PropTypes.func.isRequired);
Translate.childContextTypes = (_Translate$childConte = {}, _defineProperty(_Translate$childConte, translateFuncName, PropTypes.func.isRequired), _defineProperty(_Translate$childConte, 'i18n', PropTypes.object), _Translate$childConte);

@@ -188,0 +194,0 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

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

return function Wrapper(WrappedComponent) {
var _Translate$childConte;
var Translate = function (_Component) {

@@ -266,3 +268,5 @@ inherits(Translate, _Component);

value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
var _ref;
return _ref = {}, defineProperty(_ref, translateFuncName, this[translateFuncName]), defineProperty(_ref, 'i18n', this.i18n), _ref;
}

@@ -356,3 +360,5 @@ }, {

var extraProps = (_extraProps = { i18nLoadedAt: i18nLoadedAt }, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);
var extraProps = (_extraProps = {
i18nLoadedAt: i18nLoadedAt
}, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);

@@ -377,3 +383,3 @@ if (withRef) {

Translate.childContextTypes = defineProperty({}, translateFuncName, PropTypes.func.isRequired);
Translate.childContextTypes = (_Translate$childConte = {}, defineProperty(_Translate$childConte, translateFuncName, PropTypes.func.isRequired), defineProperty(_Translate$childConte, 'i18n', PropTypes.object), _Translate$childConte);

@@ -458,2 +464,11 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
if (className) additionalProps.className = className;

@@ -583,3 +598,13 @@ if (style) additionalProps.style = style;

return React__default.createElement('div', {}, renderNodes(children, translation, this.i18n));
var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
return React__default.createElement('div', additionalProps, renderNodes(children, translation, this.i18n));
}

@@ -586,0 +611,0 @@ }]);

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react","prop-types"],t):t(e.reactI18next=e.reactI18next||{},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function r(e){return e.displayName||e.name||"Component"}function i(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.withRef,a=void 0!==o&&o,s=i.bindI18n,u=void 0===s?"languageChanged loaded":s,p=i.bindStore,l=void 0===p?"added removed":p,f=i.translateFuncName,d=void 0===f?"t":f,y=i.wait,x=void 0!==y&&y;return function(o){var s=function(t){function n(t,r){v(this,n);var o=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r));return o.i18n=r.i18n||t.i18n||i.i18n,e=e||o.i18n.options.defaultNS,"string"==typeof e&&(e=[e]),!x&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(x=!0),o.nsMode=i.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",t.initialI18nStore&&t.initialLanguage&&(o.i18n.services.resourceStore.data=t.initialI18nStore,o.i18n.changeLanguage(t.initialLanguage),x=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return j(n,t),m(n,[{key:"getChildContext",value:function(){return g({},d,this[d])}},{key:"componentWillMount",value:function(){this[d]=this.i18n.getFixedT(null,"fallback"===this.nsMode?e:e[0])}},{key:"componentDidMount",value:function(){var t=this,n=function(){u&&t.i18n&&t.i18n.on(u,t.onI18nChanged),l&&t.i18n.store&&t.i18n.store.on(l,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),x&&t.mounted&&n()};if(t.i18n.isInitialized)e();else{var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}}),x||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(u){var t=u.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(l){var n=l.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 a||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e,t=this.state,n=t.i18nLoadedAt,r=t.ready,i=(e={i18nLoadedAt:n},g(e,d,this[d]),g(e,"i18n",this.i18n),e);return a&&(i.ref="wrappedInstance"),!r&&x?null:c.createElement(o,b({},this.props,i))}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object},s.childContextTypes=g({},d,n.func.isRequired),s.displayName="Translate("+r(o)+")",s.namespaces=e,h(s,o)}}function o(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var r=""+n;if("string"==typeof t)e=""+e+t;else if(t.props&&t.props.children)e=e+"<"+r+">"+o("",t.props.children,n+1)+"</"+r+">";else if("object"===("undefined"==typeof t?"undefined":y(t))){var i=b({},t),a=i.format;delete i.format;var s=Object.keys(i);a&&1===s.length?e=e+"<"+r+">{{"+s[0]+", "+a+"}}</"+r+">":1===s.length&&(e=e+"<"+r+">{{"+s[0]+"}}</"+r+">")}}),e}function a(e,t,n){function r(e,t){"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]);var i=t.split(I).reduce(function(e,t,n){return t&&e.push(t),e},[]);return i.reduce(function(t,o,a){var s=!isNaN(o),u=a>0&&!isNaN(i[a-1]);if(u)return t;if(s){var p=e[parseInt(o,10)]||{},l=c.isValidElement(p);if("string"==typeof p)t.push(p);else if(p.props&&p.props.children){var f=r(p.props&&p.props.children,i[a+1]);t.push(c.cloneElement(p,b({},p.props,{key:a}),f))}else if("object"===("undefined"==typeof p?"undefined":y(p))&&!l){var d=n.services.interpolator.interpolate(i[a+1],p,n.language);t.push(d)}}return s||u||t.push(o),t},[])}return r(e,t)}function s(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===y(e[n])){var i=!0,o=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var p=x(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){o=!0,a=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw a}}}else t(e[n],n)}function u(e){var t=[];return s(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function p(e){var t=e.components,n=e.i18n,r=u(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var c="default"in t?t.default:t;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(e,t,n){if("string"!=typeof t){var r=Object.getOwnPropertyNames(t);d&&(r=r.concat(Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;++i)if(!(l[r[i]]||f[r[i]]||n&&n[r[i]]))try{e[r[i]]=t[r[i]]}catch(e){}}return e},y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},m=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}}(),g=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},b=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},j=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)},w=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},x=function(){function e(e,t){var n=[],r=!0,i=!1,o=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){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O=function(e){function t(e,n){v(this,t);var r=w(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return j(t,e),m(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,i=r.className,o=r.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",u=b({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,u);if(!p||"string"!=typeof p)return c.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 "+p),n[t];var r=t.split(e.i18n.options.interpolation.formatSeparator),i=r.shift().trim(),o=r.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[i]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+i+" for interpolating "+p),e.i18n.options.interpolation.format(n[i],o,e.i18n.language)};p.split(n).reduce(function(t,n,r){var i=void 0;if(r%2===0){if(0===n.length)return t;i=a?c.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else i=f(n,e.props);return t.push(i),t},l);var d={};return i&&(d.className=i),o&&(d.style=o),c.createElement.apply(this,[t,d].concat(l))}}]),t}(t.Component);O.propTypes={className:n.string},O.defaultProps={className:""},O.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var I=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),S=function(e){function t(e,n){v(this,t);var r=w(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return j(t,e),m(t,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var e=this.props,t=e.children,n=e.count,r=o("",t,0),i=this.props.i18nKey||r,s=this.t(i,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:r,count:n});return c.createElement("div",{},a(t,s,this.i18n))}}]),t}(c.Component);S.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var C=function(e){function n(e,t){v(this,n);var r=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return r.i18n=e.i18n,r}return j(n,e),m(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);C.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},C.childContextTypes={i18n:n.object.isRequired},e.loadNamespaces=p,e.translate=i,e.Interpolate=O,e.I18nextProvider=C,e.Trans=S,Object.defineProperty(e,"__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,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&&e.initialLanguage&&(o.i18n.services.resourceStore.data=e.initialI18nStore,o.i18n.changeLanguage(e.initialLanguage),j=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return x(n,e),m(n,[{key:"getChildContext",value:function(){var t;return t={},g(t,d,this[d]),g(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.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.state,n=e.i18nLoadedAt,i=e.ready,r=(t={i18nLoadedAt:n},g(t,d,this[d]),g(t,"i18n",this.i18n),t);return a&&(r.ref="wrappedInstance"),!i&&j?null:c.createElement(o,b({},this.props,r))}}]),n}(e.Component);return u.WrappedComponent=o,u.contextTypes={i18n:n.object},u.childContextTypes=(s={},g(s,d,n.func.isRequired),g(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=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")},m=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}}(),g=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},x=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},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")}}(),S=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 x(e,t),m(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);S.propTypes={className:n.string},S.defaultProps={className:""},S.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var w=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),I=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 x(e,t),m(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);I.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var C=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,i}return x(n,t),m(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);C.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},C.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=u,t.translate=r,t.Interpolate=S,t.I18nextProvider=C,t.Trans=I,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "react-i18next",
"version": "4.4.0",
"version": "4.5.0",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",

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

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

return function Wrapper(WrappedComponent) {
var _Translate$childConte;
var Translate = function (_Component) {

@@ -266,3 +268,5 @@ inherits(Translate, _Component);

value: function getChildContext() {
return defineProperty({}, translateFuncName, this[translateFuncName]);
var _ref;
return _ref = {}, defineProperty(_ref, translateFuncName, this[translateFuncName]), defineProperty(_ref, 'i18n', this.i18n), _ref;
}

@@ -356,3 +360,5 @@ }, {

var extraProps = (_extraProps = { i18nLoadedAt: i18nLoadedAt }, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);
var extraProps = (_extraProps = {
i18nLoadedAt: i18nLoadedAt
}, defineProperty(_extraProps, translateFuncName, this[translateFuncName]), defineProperty(_extraProps, 'i18n', this.i18n), _extraProps);

@@ -377,3 +383,3 @@ if (withRef) {

Translate.childContextTypes = defineProperty({}, translateFuncName, PropTypes.func.isRequired);
Translate.childContextTypes = (_Translate$childConte = {}, defineProperty(_Translate$childConte, translateFuncName, PropTypes.func.isRequired), defineProperty(_Translate$childConte, 'i18n', PropTypes.object), _Translate$childConte);

@@ -458,2 +464,11 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
if (className) additionalProps.className = className;

@@ -583,3 +598,13 @@ if (style) additionalProps.style = style;

return React__default.createElement('div', {}, renderNodes(children, translation, this.i18n));
var additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
var ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
var parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns: ns });
}
return React__default.createElement('div', additionalProps, renderNodes(children, translation, this.i18n));
}

@@ -586,0 +611,0 @@ }]);

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react","prop-types"],t):t(e.reactI18next=e.reactI18next||{},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function r(e){return e.displayName||e.name||"Component"}function i(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.withRef,a=void 0!==o&&o,s=i.bindI18n,u=void 0===s?"languageChanged loaded":s,p=i.bindStore,l=void 0===p?"added removed":p,f=i.translateFuncName,d=void 0===f?"t":f,y=i.wait,x=void 0!==y&&y;return function(o){var s=function(t){function n(t,r){v(this,n);var o=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r));return o.i18n=r.i18n||t.i18n||i.i18n,e=e||o.i18n.options.defaultNS,"string"==typeof e&&(e=[e]),!x&&o.i18n.options&&(o.i18n.options.wait||o.i18n.options.react&&o.i18n.options.react.wait)&&(x=!0),o.nsMode=i.nsMode||o.i18n.options&&o.i18n.options.react&&o.i18n.options.react.nsMode||"default",t.initialI18nStore&&t.initialLanguage&&(o.i18n.services.resourceStore.data=t.initialI18nStore,o.i18n.changeLanguage(t.initialLanguage),x=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return j(n,t),m(n,[{key:"getChildContext",value:function(){return g({},d,this[d])}},{key:"componentWillMount",value:function(){this[d]=this.i18n.getFixedT(null,"fallback"===this.nsMode?e:e[0])}},{key:"componentDidMount",value:function(){var t=this,n=function(){u&&t.i18n&&t.i18n.on(u,t.onI18nChanged),l&&t.i18n.store&&t.i18n.store.on(l,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(e,function(){var e=function(){t.mounted&&t.setState({ready:!0}),x&&t.mounted&&n()};if(t.i18n.isInitialized)e();else{var r=function n(){setTimeout(function(){t.i18n.off("initialized",n)},1e3),e()};t.i18n.on("initialized",r)}}),x||n()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(u){var t=u.split(" ");t.forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(l){var n=l.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 a||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.refs.wrappedInstance}},{key:"render",value:function(){var e,t=this.state,n=t.i18nLoadedAt,r=t.ready,i=(e={i18nLoadedAt:n},g(e,d,this[d]),g(e,"i18n",this.i18n),e);return a&&(i.ref="wrappedInstance"),!r&&x?null:c.createElement(o,b({},this.props,i))}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object},s.childContextTypes=g({},d,n.func.isRequired),s.displayName="Translate("+r(o)+")",s.namespaces=e,h(s,o)}}function o(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var r=""+n;if("string"==typeof t)e=""+e+t;else if(t.props&&t.props.children)e=e+"<"+r+">"+o("",t.props.children,n+1)+"</"+r+">";else if("object"===("undefined"==typeof t?"undefined":y(t))){var i=b({},t),a=i.format;delete i.format;var s=Object.keys(i);a&&1===s.length?e=e+"<"+r+">{{"+s[0]+", "+a+"}}</"+r+">":1===s.length&&(e=e+"<"+r+">{{"+s[0]+"}}</"+r+">")}}),e}function a(e,t,n){function r(e,t){"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]);var i=t.split(I).reduce(function(e,t,n){return t&&e.push(t),e},[]);return i.reduce(function(t,o,a){var s=!isNaN(o),u=a>0&&!isNaN(i[a-1]);if(u)return t;if(s){var p=e[parseInt(o,10)]||{},l=c.isValidElement(p);if("string"==typeof p)t.push(p);else if(p.props&&p.props.children){var f=r(p.props&&p.props.children,i[a+1]);t.push(c.cloneElement(p,b({},p.props,{key:a}),f))}else if("object"===("undefined"==typeof p?"undefined":y(p))&&!l){var d=n.services.interpolator.interpolate(i[a+1],p,n.language);t.push(d)}}return s||u||t.push(o),t},[])}return r(e,t)}function s(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===y(e[n])){var i=!0,o=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var p=x(s.value,2),c=p[0],l=p[1];t(l,n,c)}}catch(e){o=!0,a=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw a}}}else t(e[n],n)}function u(e){var t=[];return s(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function p(e){var t=e.components,n=e.i18n,r=u(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var c="default"in t?t.default:t;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(e,t,n){if("string"!=typeof t){var r=Object.getOwnPropertyNames(t);d&&(r=r.concat(Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;++i)if(!(l[r[i]]||f[r[i]]||n&&n[r[i]]))try{e[r[i]]=t[r[i]]}catch(e){}}return e},y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},m=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}}(),g=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},b=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},j=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)},w=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},x=function(){function e(e,t){var n=[],r=!0,i=!1,o=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){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),O=function(e){function t(e,n){v(this,t);var r=w(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return j(t,e),m(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,i=r.className,o=r.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",u=b({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,u);if(!p||"string"!=typeof p)return c.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 "+p),n[t];var r=t.split(e.i18n.options.interpolation.formatSeparator),i=r.shift().trim(),o=r.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[i]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+i+" for interpolating "+p),e.i18n.options.interpolation.format(n[i],o,e.i18n.language)};p.split(n).reduce(function(t,n,r){var i=void 0;if(r%2===0){if(0===n.length)return t;i=a?c.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else i=f(n,e.props);return t.push(i),t},l);var d={};return i&&(d.className=i),o&&(d.style=o),c.createElement.apply(this,[t,d].concat(l))}}]),t}(t.Component);O.propTypes={className:n.string},O.defaultProps={className:""},O.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var I=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),S=function(e){function t(e,n){v(this,t);var r=w(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return j(t,e),m(t,[{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var e=this.props,t=e.children,n=e.count,r=o("",t,0),i=this.props.i18nKey||r,s=this.t(i,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:r,count:n});return c.createElement("div",{},a(t,s,this.i18n))}}]),t}(c.Component);S.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var C=function(e){function n(e,t){v(this,n);var r=w(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return r.i18n=e.i18n,r}return j(n,e),m(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);C.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},C.childContextTypes={i18n:n.object.isRequired},e.loadNamespaces=p,e.translate=i,e.Interpolate=O,e.I18nextProvider=C,e.Trans=S,Object.defineProperty(e,"__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,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&&e.initialLanguage&&(o.i18n.services.resourceStore.data=e.initialI18nStore,o.i18n.changeLanguage(e.initialLanguage),j=!1),o.state={i18nLoadedAt:null,ready:!1},o.onI18nChanged=o.onI18nChanged.bind(o),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return x(n,e),m(n,[{key:"getChildContext",value:function(){var t;return t={},g(t,d,this[d]),g(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.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.state,n=e.i18nLoadedAt,i=e.ready,r=(t={i18nLoadedAt:n},g(t,d,this[d]),g(t,"i18n",this.i18n),t);return a&&(r.ref="wrappedInstance"),!i&&j?null:c.createElement(o,b({},this.props,r))}}]),n}(e.Component);return u.WrappedComponent=o,u.contextTypes={i18n:n.object},u.childContextTypes=(s={},g(s,d,n.func.isRequired),g(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=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")},m=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}}(),g=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},x=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},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")}}(),S=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 x(e,t),m(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);S.propTypes={className:n.string},S.defaultProps={className:""},S.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var w=new RegExp("(?:<([^>]*)>(.*?)<\\/\\1>)","gi"),I=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 x(e,t),m(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);I.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var C=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,i}return x(n,t),m(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);C.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},C.childContextTypes={i18n:n.object.isRequired},t.loadNamespaces=u,t.translate=r,t.Interpolate=S,t.I18nextProvider=C,t.Trans=I,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -25,2 +25,26 @@ # react-i18next

### How will my code look like?
**Before:** Your react code would have looked something like:
```html
...
<div>Just simple content</div>
<div>
Hello <strong title="this is your name">{name}</strong>, you have {count} unread message(s). <Link to="/msgs">Go to messages</Link>.
</div>
...
```
**After:** With the trans component just change it to:
```html
...
<div>{t('simpleContent')}</div>
<Trans i18nKey="userMessagesUnread" count={count}>
Hello <strong title={t('nameTitle')}>{{name}}</strong>, you have {{count}} unread message. <Link to="/msgs">Go to messages</Link>.
</Trans>
...
```
### Documentation

@@ -27,0 +51,0 @@

@@ -62,2 +62,11 @@ import React, { Component } from 'react';

const additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
let ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
const parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns });
}
if (className) additionalProps.className = className;

@@ -64,0 +73,0 @@ if (style) additionalProps.style = style;

@@ -102,5 +102,15 @@ import React from 'react';

const additionalProps = {};
if (this.i18n.options.react && this.i18n.options.react.exposeNamespace) {
let ns = typeof this.t.ns === 'string' ? this.t.ns : this.t.ns[0];
if (this.props.i18nKey && this.i18n.options.nsSeparator && this.props.i18nKey.indexOf(this.i18n.options.nsSeparator) > -1) {
const parts = this.props.i18nKey.split(this.i18n.options.nsSeparator);
ns = parts[0];
}
if (this.t.ns) additionalProps['data-i18next-options'] = JSON.stringify({ ns });
}
return React.createElement(
'div',
{},
additionalProps,
renderNodes(children, translation, this.i18n)

@@ -107,0 +117,0 @@ );

@@ -44,3 +44,6 @@ import React, { Component } from 'react';

getChildContext() {
return { [translateFuncName]: this[translateFuncName] };
return {
[translateFuncName]: this[translateFuncName],
i18n: this.i18n
};
}

@@ -118,3 +121,7 @@

const { i18nLoadedAt, ready } = this.state;
const extraProps = { i18nLoadedAt, [translateFuncName]: this[translateFuncName], i18n: this.i18n };
const extraProps = {
i18nLoadedAt,
[translateFuncName]: this[translateFuncName],
i18n: this.i18n
};

@@ -141,3 +148,4 @@ if (withRef) {

Translate.childContextTypes = {
[translateFuncName]: PropTypes.func.isRequired
[translateFuncName]: PropTypes.func.isRequired,
i18n: PropTypes.object
};

@@ -144,0 +152,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc