Socket
Socket
Sign inDemoInstall

react-i18next

Package Overview
Dependencies
1
Maintainers
2
Versions
309
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.9.0 to 1.10.0

3

CHANGELOG.md

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

### 1.10.0
- allow passing i18next instance via props to translate hoc [PR203](https://github.com/i18next/react-i18next/pull/203)
### 1.9.0

@@ -2,0 +5,0 @@ - adds options bindI18n, bindStore can be set to false or string of events to bind for triggering updates

2

dist/commonjs/translate.js

@@ -58,3 +58,3 @@ 'use strict';

_this.i18n = context.i18n;
_this.i18n = context.i18n || props.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -61,0 +61,0 @@

@@ -43,3 +43,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; };

_this.i18n = context.i18n;
_this.i18n = context.i18n || props.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -46,0 +46,0 @@

@@ -220,3 +220,3 @@ (function (global, factory) {

_this.i18n = context.i18n;
_this.i18n = context.i18n || props.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -223,0 +223,0 @@

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

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

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

@@ -220,3 +220,3 @@ (function (global, factory) {

_this.i18n = context.i18n;
_this.i18n = context.i18n || props.i18n;
namespaces = namespaces || _this.i18n.options.defaultNS;

@@ -223,0 +223,0 @@

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

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

@@ -74,3 +74,3 @@ # react-i18next

- props.t will default to first namespace in array of given namespaces (providing a string as namespace will convert automatically to array, providing no namespaces will default to `defaultNS`)
- used nested inside I18nextProvider (context.i18n)
- used nested inside I18nextProvider (context.i18n) or by passing i18n as a prop
- passing `{ withRef: true }` to options store a ref to the wrapped component instance making it available via `getWrappedInstance()` method

@@ -77,0 +77,0 @@ - passing `{ translateFuncName: 'someFunctionName' }` will change the name of the property passed to the child component for the translation function (by default, the value is `t`). This is useful if you are already using a concrete function name for extracting the translation chains from your source files

@@ -16,3 +16,3 @@ import React, { Component, PropTypes } from 'react';

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

@@ -19,0 +19,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc