Socket
Socket
Sign inDemoInstall

react-i18next

Package Overview
Dependencies
0
Maintainers
1
Versions
309
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

3

CHANGELOG.md

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

### 1.4.1
- change global name
### 1.4.0

@@ -2,0 +5,0 @@ - adds getWrappedInstance() to translate wrapper

2

dist/commonjs/interpolate.js

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

if (!format || typeof format !== 'string') return _react2.default.createElement('noscript', null);;
if (!format || typeof format !== 'string') return _react2.default.createElement('noscript', null);

@@ -50,0 +50,0 @@ var children = [];

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

if (!format || typeof format !== 'string') return React.createElement('noscript', null);;
if (!format || typeof format !== 'string') return React.createElement('noscript', null);

@@ -40,0 +40,0 @@ var children = [];

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
typeof define === 'function' && define.amd ? define('react-i18next', ['exports', 'react'], factory) :
(factory((global.react-i18next = global.react-i18next || {}),global.React));
typeof define === 'function' && define.amd ? define('reactI18next', ['exports', 'react'], factory) :
(factory((global.reactI18next = global.reactI18next || {}),global.React));
}(this, function (exports,React) { 'use strict';

@@ -259,3 +259,3 @@

if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);;
if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);

@@ -262,0 +262,0 @@ var children = [];

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("react-i18next",["exports","react"],t):t(e.react-i18next=e.react-i18next||{},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=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});
{
"name": "react-i18next",
"version": "1.4.0",
"version": "1.4.1",
"description": "React integration for i18next",

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

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
typeof define === 'function' && define.amd ? define('react-i18next', ['exports', 'react'], factory) :
(factory((global.react-i18next = global.react-i18next || {}),global.React));
typeof define === 'function' && define.amd ? define('reactI18next', ['exports', 'react'], factory) :
(factory((global.reactI18next = global.reactI18next || {}),global.React));
}(this, function (exports,React) { 'use strict';

@@ -259,3 +259,3 @@

if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);;
if (!format || typeof format !== 'string') return React__default.createElement('noscript', null);

@@ -262,0 +262,0 @@ var children = [];

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define("react-i18next",["exports","react"],t):t(e.react-i18next=e.react-i18next||{},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=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});

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

- used nested inside I18nextProvider (context.i18n)
- passing `{ withRef: true }` in options will make the wrapped component instance available via `getWrappedInstance()` method
- passing `{ withRef: true }` to options store a ref to the wrapped component instance making it available via `getWrappedInstance()` method

@@ -77,2 +77,50 @@

__getWrappedInstance()__: allows you to access to the component instance, wrapped into `translate()`.
Only available if you pass `{ withRef: true }` to the `translate()` options.
```javascript
import React, { Component } from 'react';
import { translate } from 'react-i18next';
class TranslatableView extends Component {
foo() {
// do something important
}
render() {
const { t } = this.props;
return (
<div>
<h1>{t('keyFromDefault')}</h1>
</div>
)
}
}
export default translate(['defaultNamespace', 'anotherNamespace'], { withRef: true })(TranslatableView);
```
```javascript
import React, { Component } from 'react';
import ./TranslatableView;
class App extends Component {
handleClick() {
this.refs.translatedView.foo();
}
render() {
return (
<div>
<TranslatableView ref="translatedView" />
<button onClick={() => this.handleClick()}>Click</button>
</div>
)
}
}
```
### Interpolate Component

@@ -79,0 +127,0 @@

@@ -29,5 +29,5 @@ import babel from 'rollup-plugin-babel';

].concat(compress ? uglify() : []),
moduleName: 'react-i18next',
moduleId: 'react-i18next',
moduleName: 'reactI18next',
moduleId: 'reactI18next',
dest
};

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

if (!format || typeof format !== 'string') return React.createElement('noscript', null);;
if (!format || typeof format !== 'string') return React.createElement('noscript', null);

@@ -21,0 +21,0 @@ let children = [];

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