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 1.4.1 to 1.4.2

3

CHANGELOG.md

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

### 1.4.2
- possible fix for HRM issues
### 1.4.1

@@ -2,0 +5,0 @@ - change global name

9

dist/commonjs/translate.js

@@ -36,4 +36,3 @@ 'use strict';

return function Wrapper(WrappedComponent) {
var t = void 0,
i18n = void 0;
var i18n = void 0;

@@ -60,3 +59,3 @@ var Translate = function (_Component) {

value: function getChildContext() {
return { t: t };
return { t: this.t };
}

@@ -68,3 +67,3 @@ }, {

i18n.loadNamespaces(namespaces);
t = i18n.getFixedT(null, namespaces);
this.t = i18n.getFixedT(null, namespaces);
}

@@ -115,3 +114,3 @@ }, {

var extraProps = { i18nLoadedAt: i18nLoadedAt, t: t };
var extraProps = { i18nLoadedAt: i18nLoadedAt, t: this.t };

@@ -118,0 +117,0 @@ if (withRef) {

@@ -24,4 +24,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; };

return function Wrapper(WrappedComponent) {
var t = void 0,
i18n = void 0;
var i18n = void 0;

@@ -48,3 +47,3 @@ var Translate = function (_Component) {

value: function getChildContext() {
return { t: t };
return { t: this.t };
}

@@ -56,3 +55,3 @@ }, {

i18n.loadNamespaces(namespaces);
t = i18n.getFixedT(null, namespaces);
this.t = i18n.getFixedT(null, namespaces);
}

@@ -103,3 +102,3 @@ }, {

var extraProps = { i18nLoadedAt: i18nLoadedAt, t: t };
var extraProps = { i18nLoadedAt: i18nLoadedAt, t: this.t };

@@ -106,0 +105,0 @@ if (withRef) {

@@ -129,4 +129,3 @@ (function (global, factory) {

return function Wrapper(WrappedComponent) {
var t = void 0,
i18n = void 0;
var i18n = void 0;

@@ -153,3 +152,3 @@ var Translate = function (_Component) {

value: function getChildContext() {
return { t: t };
return { t: this.t };
}

@@ -161,3 +160,3 @@ }, {

i18n.loadNamespaces(namespaces);
t = i18n.getFixedT(null, namespaces);
this.t = i18n.getFixedT(null, namespaces);
}

@@ -208,3 +207,3 @@ }, {

var extraProps = { i18nLoadedAt: i18nLoadedAt, t: t };
var extraProps = { i18nLoadedAt: i18nLoadedAt, t: this.t };

@@ -211,0 +210,0 @@ if (withRef) {

@@ -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.displayName||e.name||"Component"}function r(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=r.withRef,i=void 0===o?!1:o;return function(r){var o=void 0,a=void 0,u=function(t){function n(t,r){c.classCallCheck(this,n);var o=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,t,r));return a=r.i18n,e=e||a.options.defaultNS,o.state={i18nLoadedAt:null},o}return c.inherits(n,t),c.createClass(n,[{key:"getChildContext",value:function(){return{t:o}}},{key:"componentWillMount",value:function(){this.mounted=!0,a.loadNamespaces(e),o=a.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var e=this;this.onI18nChanged=function(){e.mounted&&e.setState({i18nLoadedAt:new Date})},a.on("languageChanged loaded",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(a.off("languageChanged",this.onI18nChanged),a.off("loaded",this.onI18nChanged))}},{key:"onI18nChange",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.i18nLoadedAt,t={i18nLoadedAt:e,t:o};return i&&(t.ref="wrappedInstance"),s.createElement(r,c["extends"]({},this.props,t))}}]),n}(t.Component);return u.WrappedComponent=r,u.contextTypes={i18n:t.PropTypes.object.isRequired},u.childContextTypes={t:t.PropTypes.func.isRequired},u.displayName="Translate["+n(r)+"]",u.namespaces=e,u}}function o(e,t){for(var n=0,r=e.length;r>n;n++)if("object"===c["typeof"](e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var l=c.slicedToArray(s.value,2),p=l[0],f=l[1];t(f,n,p)}}catch(d){i=!0,a=d}finally{try{!o&&u["return"]&&u["return"]()}finally{if(i)throw a}}}else t(e[n],n)}function i(e){var t=[];return o(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}function a(e){var t=e.components,n=e.i18n,r=i(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var s="default"in t?t["default"]:t,c={};c["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},c.createClass=function(){function e(e,t){for(var n=0;n<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}}(),c["extends"]=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},c.inherits=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)},c.possibleConstructorReturn=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},c.slicedToArray=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(c){o=!0,i=c}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")}}();var u=function(e){function t(e,n){c.classCallCheck(this,t);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return c.inherits(t,e),c.createClass(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=c["extends"]({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),o=this.t(this.props.i18nKey,r);if(!o||"string"!=typeof o)return s.createElement("noscript",null);var i=[];return o.split(n).reduce(function(t,n,r){var o;if(r%2===0){if(0===n.length)return t;o=n}else o=e.props[n];return t.push(o),t},i),s.createElement.apply(this,[t,this.props].concat(i))}}]),t}(t.Component);u.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var l=function(e){function n(e,t){c.classCallCheck(this,n);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return c.inherits(n,e),c.createClass(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){this.props.i18n!==e.i18n&&console.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);l.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},l.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=a,e.translate=r,e.Interpolate=u,e.I18nextProvider=l});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e.displayName||e.name||"Component"}function r(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=r.withRef,i=void 0===o?!1:o;return function(r){var o=void 0,a=function(t){function n(t,r){c.classCallCheck(this,n);var i=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,t,r));return o=r.i18n,e=e||o.options.defaultNS,i.state={i18nLoadedAt:null},i}return c.inherits(n,t),c.createClass(n,[{key:"getChildContext",value:function(){return{t:this.t}}},{key:"componentWillMount",value:function(){this.mounted=!0,o.loadNamespaces(e),this.t=o.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var e=this;this.onI18nChanged=function(){e.mounted&&e.setState({i18nLoadedAt:new Date})},o.on("languageChanged loaded",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(o.off("languageChanged",this.onI18nChanged),o.off("loaded",this.onI18nChanged))}},{key:"onI18nChange",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.i18nLoadedAt,t={i18nLoadedAt:e,t:this.t};return i&&(t.ref="wrappedInstance"),s.createElement(r,c["extends"]({},this.props,t))}}]),n}(t.Component);return a.WrappedComponent=r,a.contextTypes={i18n:t.PropTypes.object.isRequired},a.childContextTypes={t:t.PropTypes.func.isRequired},a.displayName="Translate["+n(r)+"]",a.namespaces=e,a}}function o(e,t){for(var n=0,r=e.length;r>n;n++)if("object"===c["typeof"](e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var l=c.slicedToArray(s.value,2),p=l[0],f=l[1];t(f,n,p)}}catch(h){i=!0,a=h}finally{try{!o&&u["return"]&&u["return"]()}finally{if(i)throw a}}}else t(e[n],n)}function i(e){var t=[];return o(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}function a(e){var t=e.components,n=e.i18n,r=i(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var s="default"in t?t["default"]:t,c={};c["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},c.createClass=function(){function e(e,t){for(var n=0;n<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}}(),c["extends"]=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},c.inherits=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)},c.possibleConstructorReturn=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},c.slicedToArray=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(c){o=!0,i=c}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")}}();var u=function(e){function t(e,n){c.classCallCheck(this,t);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return c.inherits(t,e),c.createClass(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=c["extends"]({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),o=this.t(this.props.i18nKey,r);if(!o||"string"!=typeof o)return s.createElement("noscript",null);var i=[];return o.split(n).reduce(function(t,n,r){var o;if(r%2===0){if(0===n.length)return t;o=n}else o=e.props[n];return t.push(o),t},i),s.createElement.apply(this,[t,this.props].concat(i))}}]),t}(t.Component);u.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var l=function(e){function n(e,t){c.classCallCheck(this,n);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return c.inherits(n,e),c.createClass(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){this.props.i18n!==e.i18n&&console.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);l.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},l.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=a,e.translate=r,e.Interpolate=u,e.I18nextProvider=l});
{
"name": "react-i18next",
"version": "1.4.1",
"version": "1.4.2",
"description": "React integration for i18next",

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

@@ -129,4 +129,3 @@ (function (global, factory) {

return function Wrapper(WrappedComponent) {
var t = void 0,
i18n = void 0;
var i18n = void 0;

@@ -153,3 +152,3 @@ var Translate = function (_Component) {

value: function getChildContext() {
return { t: t };
return { t: this.t };
}

@@ -161,3 +160,3 @@ }, {

i18n.loadNamespaces(namespaces);
t = i18n.getFixedT(null, namespaces);
this.t = i18n.getFixedT(null, namespaces);
}

@@ -208,3 +207,3 @@ }, {

var extraProps = { i18nLoadedAt: i18nLoadedAt, t: t };
var extraProps = { i18nLoadedAt: i18nLoadedAt, t: this.t };

@@ -211,0 +210,0 @@ if (withRef) {

@@ -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.displayName||e.name||"Component"}function r(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=r.withRef,i=void 0===o?!1:o;return function(r){var o=void 0,a=void 0,u=function(t){function n(t,r){c.classCallCheck(this,n);var o=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,t,r));return a=r.i18n,e=e||a.options.defaultNS,o.state={i18nLoadedAt:null},o}return c.inherits(n,t),c.createClass(n,[{key:"getChildContext",value:function(){return{t:o}}},{key:"componentWillMount",value:function(){this.mounted=!0,a.loadNamespaces(e),o=a.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var e=this;this.onI18nChanged=function(){e.mounted&&e.setState({i18nLoadedAt:new Date})},a.on("languageChanged loaded",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(a.off("languageChanged",this.onI18nChanged),a.off("loaded",this.onI18nChanged))}},{key:"onI18nChange",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.i18nLoadedAt,t={i18nLoadedAt:e,t:o};return i&&(t.ref="wrappedInstance"),s.createElement(r,c["extends"]({},this.props,t))}}]),n}(t.Component);return u.WrappedComponent=r,u.contextTypes={i18n:t.PropTypes.object.isRequired},u.childContextTypes={t:t.PropTypes.func.isRequired},u.displayName="Translate["+n(r)+"]",u.namespaces=e,u}}function o(e,t){for(var n=0,r=e.length;r>n;n++)if("object"===c["typeof"](e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var l=c.slicedToArray(s.value,2),p=l[0],f=l[1];t(f,n,p)}}catch(d){i=!0,a=d}finally{try{!o&&u["return"]&&u["return"]()}finally{if(i)throw a}}}else t(e[n],n)}function i(e){var t=[];return o(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}function a(e){var t=e.components,n=e.i18n,r=i(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var s="default"in t?t["default"]:t,c={};c["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},c.createClass=function(){function e(e,t){for(var n=0;n<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}}(),c["extends"]=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},c.inherits=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)},c.possibleConstructorReturn=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},c.slicedToArray=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(c){o=!0,i=c}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")}}();var u=function(e){function t(e,n){c.classCallCheck(this,t);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return c.inherits(t,e),c.createClass(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=c["extends"]({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),o=this.t(this.props.i18nKey,r);if(!o||"string"!=typeof o)return s.createElement("noscript",null);var i=[];return o.split(n).reduce(function(t,n,r){var o;if(r%2===0){if(0===n.length)return t;o=n}else o=e.props[n];return t.push(o),t},i),s.createElement.apply(this,[t,this.props].concat(i))}}]),t}(t.Component);u.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var l=function(e){function n(e,t){c.classCallCheck(this,n);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return c.inherits(n,e),c.createClass(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){this.props.i18n!==e.i18n&&console.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);l.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},l.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=a,e.translate=r,e.Interpolate=u,e.I18nextProvider=l});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("reactI18next",["exports","react"],t):t(e.reactI18next=e.reactI18next||{},e.React)}(this,function(e,t){"use strict";function n(e){return e.displayName||e.name||"Component"}function r(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=r.withRef,i=void 0===o?!1:o;return function(r){var o=void 0,a=function(t){function n(t,r){c.classCallCheck(this,n);var i=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,t,r));return o=r.i18n,e=e||o.options.defaultNS,i.state={i18nLoadedAt:null},i}return c.inherits(n,t),c.createClass(n,[{key:"getChildContext",value:function(){return{t:this.t}}},{key:"componentWillMount",value:function(){this.mounted=!0,o.loadNamespaces(e),this.t=o.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var e=this;this.onI18nChanged=function(){e.mounted&&e.setState({i18nLoadedAt:new Date})},o.on("languageChanged loaded",this.onI18nChanged)}},{key:"componentWillUnmount",value:function(){this.mounted=!1,this.onI18nChanged&&(o.off("languageChanged",this.onI18nChanged),o.off("loaded",this.onI18nChanged))}},{key:"onI18nChange",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.i18nLoadedAt,t={i18nLoadedAt:e,t:this.t};return i&&(t.ref="wrappedInstance"),s.createElement(r,c["extends"]({},this.props,t))}}]),n}(t.Component);return a.WrappedComponent=r,a.contextTypes={i18n:t.PropTypes.object.isRequired},a.childContextTypes={t:t.PropTypes.func.isRequired},a.displayName="Translate["+n(r)+"]",a.namespaces=e,a}}function o(e,t){for(var n=0,r=e.length;r>n;n++)if("object"===c["typeof"](e[n])){var o=!0,i=!1,a=void 0;try{for(var s,u=Object.entries(e[n])[Symbol.iterator]();!(o=(s=u.next()).done);o=!0){var l=c.slicedToArray(s.value,2),p=l[0],f=l[1];t(f,n,p)}}catch(h){i=!0,a=h}finally{try{!o&&u["return"]&&u["return"]()}finally{if(i)throw a}}}else t(e[n],n)}function i(e){var t=[];return o(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}function a(e){var t=e.components,n=e.i18n,r=i(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var s="default"in t?t["default"]:t,c={};c["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},c.createClass=function(){function e(e,t){for(var n=0;n<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}}(),c["extends"]=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},c.inherits=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)},c.possibleConstructorReturn=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},c.slicedToArray=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(c){o=!0,i=c}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")}}();var u=function(e){function t(e,n){c.classCallCheck(this,t);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return c.inherits(t,e),c.createClass(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=c["extends"]({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),o=this.t(this.props.i18nKey,r);if(!o||"string"!=typeof o)return s.createElement("noscript",null);var i=[];return o.split(n).reduce(function(t,n,r){var o;if(r%2===0){if(0===n.length)return t;o=n}else o=e.props[n];return t.push(o),t},i),s.createElement.apply(this,[t,this.props].concat(i))}}]),t}(t.Component);u.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var l=function(e){function n(e,t){c.classCallCheck(this,n);var r=c.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return c.inherits(n,e),c.createClass(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){this.props.i18n!==e.i18n&&console.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);l.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},l.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=a,e.translate=r,e.Interpolate=u,e.I18nextProvider=l});

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

return function Wrapper(WrappedComponent) {
let t, i18n;
let i18n;

@@ -26,3 +26,3 @@ class Translate extends Component {

getChildContext() {
return { t: t };
return { t: this.t };
}

@@ -33,3 +33,3 @@

i18n.loadNamespaces(namespaces);
t = i18n.getFixedT(null, namespaces);
this.t = i18n.getFixedT(null, namespaces);
}

@@ -75,3 +75,3 @@

const { i18nLoadedAt } = this.state;
const extraProps = { i18nLoadedAt, t };
const extraProps = { i18nLoadedAt, t: this.t };

@@ -81,3 +81,3 @@ if (withRef) {

}
return React.createElement(

@@ -84,0 +84,0 @@ WrappedComponent,

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