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.6.3 to 1.7.0

__tests__/i18nextProvider-test.js

4

CHANGELOG.md

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

### 1.7.0
- add option to change t function name to something else [PR196](https://github.com/i18next/react-i18next/pull/196)
- Added an option of using the <Interpolate /> with a raw HTML [PR195](https://github.com/i18next/react-i18next/pull/195)
### 1.6.3

@@ -2,0 +6,0 @@ - only trigger loaded namespaces if mounted

6

dist/commonjs/I18nextProvider.js

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

var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -43,3 +39,3 @@

if (this.props.i18n !== nextProps.i18n) {
console.error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}

@@ -46,0 +42,0 @@ }

@@ -44,2 +44,7 @@ 'use strict';

// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });

@@ -57,3 +62,7 @@ var format = this.t(this.props.i18nKey, tOpts);

if (match.length === 0) return memo;
child = match;
if (useDangerouslySetInnerHTML) {
child = _react2.default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {

@@ -60,0 +69,0 @@ child = _this2.props[match];

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -40,2 +42,4 @@

var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;

@@ -67,3 +71,3 @@

value: function getChildContext() {
return { t: this.t };
return _defineProperty({}, translateFuncName, this[translateFuncName]);
}

@@ -73,3 +77,3 @@ }, {

value: function componentWillMount() {
this.t = this.i18n.getFixedT(null, namespaces);
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}

@@ -86,3 +90,3 @@ }, {

this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}

@@ -124,3 +128,3 @@ }, {

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

@@ -146,5 +150,3 @@ if (withRef) {

Translate.childContextTypes = {
t: _react.PropTypes.func.isRequired
};
Translate.childContextTypes = _defineProperty({}, translateFuncName, _react.PropTypes.func.isRequired);

@@ -151,0 +153,0 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

@@ -9,3 +9,3 @@ 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; }; }();

import React, { Component, PropTypes, Children } from 'react';
import { Component, PropTypes, Children } from 'react';

@@ -33,3 +33,3 @@ var I18nextProvider = function (_Component) {

if (this.props.i18n !== nextProps.i18n) {
console.error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}

@@ -36,0 +36,0 @@ }

@@ -34,2 +34,7 @@ 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; };

// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });

@@ -47,3 +52,7 @@ var format = this.t(this.props.i18nKey, tOpts);

if (match.length === 0) return memo;
child = match;
if (useDangerouslySetInnerHTML) {
child = React.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {

@@ -50,0 +59,0 @@ child = _this2.props[match];

@@ -5,2 +5,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; };

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -25,2 +27,4 @@

var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;

@@ -52,3 +56,3 @@

value: function getChildContext() {
return { t: this.t };
return _defineProperty({}, translateFuncName, this[translateFuncName]);
}

@@ -58,3 +62,3 @@ }, {

value: function componentWillMount() {
this.t = this.i18n.getFixedT(null, namespaces);
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}

@@ -71,3 +75,3 @@ }, {

this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}

@@ -109,3 +113,3 @@ }, {

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

@@ -131,5 +135,3 @@ if (withRef) {

Translate.childContextTypes = {
t: PropTypes.func.isRequired
};
Translate.childContextTypes = _defineProperty({}, translateFuncName, PropTypes.func.isRequired);

@@ -136,0 +138,0 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

@@ -98,2 +98,17 @@ (function (global, factory) {

var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
var _extends = Object.assign || function (target) {

@@ -185,2 +200,4 @@ for (var i = 1; i < arguments.length; i++) {

var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;

@@ -212,3 +229,3 @@

value: function getChildContext() {
return { t: this.t };
return defineProperty({}, translateFuncName, this[translateFuncName]);
}

@@ -218,3 +235,3 @@ }, {

value: function componentWillMount() {
this.t = this.i18n.getFixedT(null, namespaces);
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}

@@ -231,3 +248,3 @@ }, {

this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}

@@ -269,3 +286,3 @@ }, {

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

@@ -290,5 +307,3 @@ if (withRef) {

Translate.childContextTypes = {
t: React.PropTypes.func.isRequired
};
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);

@@ -324,2 +339,7 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });

@@ -337,3 +357,7 @@ var format = this.t(this.props.i18nKey, tOpts);

if (match.length === 0) return memo;
child = match;
if (useDangerouslySetInnerHTML) {
child = React__default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {

@@ -380,3 +404,3 @@ child = _this2.props[match];

if (this.props.i18n !== nextProps.i18n) {
console.error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}

@@ -383,0 +407,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,t){return t={exports:{}},e(t,t.exports),t.exports}function r(e){return e.displayName||e.name||"Component"}function o(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=n.withRef,i=void 0!==o&&o,a=n.wait,s=void 0!==a&&a;return function(n){var o=function(t){function r(t,n){f(this,r);var o=v(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 y(r,t),d(r,[{key:"getChildContext",value:function(){return{t:this.t}}},{key:"componentWillMount",value:function(){this.t=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store.on("added removed",this.onI18nChanged)}},{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={i18nLoadedAt:t,t:this.t};return i&&(o.ref="wrappedInstance"),!r&&s?null:u.createElement(n,h({},this.props,o))}}]),r}(t.Component);return o.WrappedComponent=n,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes={t:t.PropTypes.func.isRequired},o.displayName="Translate("+r(n)+")",o.namespaces=e,p(o,n)}}function i(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===l(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 c=m(s.value,2),p=c[0],f=c[1];t(f,n,p)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function a(e){var t=[];return i(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function s(e){var t=e.components,n=e.i18n,r=a(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var u="default"in t?t.default:t,c=n(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}}),p=c&&"object"==typeof c&&"default"in c?c.default:c,l="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},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},d=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=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},y=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)},v=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},m=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")}}(),g=function(e){function t(e,n){f(this,t);var r=v(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return y(t,e),d(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=h({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),o=this.t(this.props.i18nKey,r);if(!o||"string"!=typeof o)return u.createElement("noscript",null);var i=[];return o.split(n).reduce(function(t,n,r){var i;if(r%2===0){if(0===n.length)return t;i=n}else i=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+o);return t.push(i),t},i),u.createElement.apply(this,[t,null].concat(i))}}]),t}(t.Component);g.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var b=function(e){function n(e,t){f(this,n);var r=v(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return y(n,e),d(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);b.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},b.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=s,e.translate=o,e.Interpolate=g,e.I18nextProvider=b,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,t){return t={exports:{}},e(t,t.exports),t.exports}function r(e){return e.displayName||e.name||"Component"}function o(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=n.withRef,i=void 0!==o&&o,a=n.wait,s=void 0!==a&&a,c=n.translateFuncName,l=void 0===c?"t":c;return function(n){var o=function(t){function r(t,n){f(this,r);var o=v(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 m(r,t),d(r,[{key:"getChildContext",value:function(){return h({},l,this[l])}},{key:"componentWillMount",value:function(){this[l]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store&&this.i18n.store.on("added removed",this.onI18nChanged)}},{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},l,this[l]);return i&&(o.ref="wrappedInstance"),!r&&s?null:u.createElement(n,y({},this.props,o))}}]),r}(t.Component);return o.WrappedComponent=n,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes=h({},l,t.PropTypes.func.isRequired),o.displayName="Translate("+r(n)+")",o.namespaces=e,p(o,n)}}function i(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===l(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 c=g(s.value,2),p=c[0],f=c[1];t(f,n,p)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function a(e){var t=[];return i(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function s(e){var t=e.components,n=e.i18n,r=a(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var u="default"in t?t.default:t,c=n(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}}),p=c&&"object"==typeof c&&"default"in c?c.default:c,l="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},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},d=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},y=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},m=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)},v=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")}}(),b=function(e){function t(e,n){f(this,t);var r=v(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),d(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.useDangerouslySetInnerHTML||!1,o=this.props.dangerouslySetInnerHTMLPartElement||"span",i=y({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),a=this.t(this.props.i18nKey,i);if(!a||"string"!=typeof a)return u.createElement("noscript",null);var s=[];return a.split(n).reduce(function(t,n,i){var s;if(i%2===0){if(0===n.length)return t;s=r?u.createElement(o,{dangerouslySetInnerHTML:{__html:n}}):n}else s=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+a);return t.push(s),t},s),u.createElement.apply(this,[t,null].concat(s))}}]),t}(t.Component);b.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var x=function(e){function n(e,t){f(this,n);var r=v(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),d(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);x.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},x.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=s,e.translate=o,e.Interpolate=b,e.I18nextProvider=x,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "react-i18next",
"version": "1.6.3",
"version": "1.7.0",
"description": "React integration for i18next",

@@ -31,2 +31,3 @@ "main": "dist/commonjs/index.js",

"babel-eslint": "6.1.2",
"babel-jest": "^14.0.0",
"babel-preset-es2015": "6.9.0",

@@ -37,3 +38,4 @@ "babel-preset-es2015-native-modules": "6.6.0",

"babel-register": "6.9.0",
"eslint": "3.0.1",
"enzyme": "2.4.1",
"eslint": "2.10.2",
"eslint-config-airbnb": "9.0.1",

@@ -44,3 +46,6 @@ "eslint-plugin-import": "1.10.2",

"i18next": "3.3.1",
"jest": "14.0.0",
"jest-cli": "13.2.3",
"mkdirp": "0.5.1",
"react": "15.2.1",
"rimraf": "2.5.3",

@@ -64,6 +69,15 @@ "rollup": "0.33.2",

"preversion": "npm run build && git push",
"postversion": "git push && git push --tags"
"postversion": "git push && git push --tags",
"test": "BABEL_ENV=development jest --no-cache",
"test:watch": "BABEL_ENV=development jest --no-cache --watch",
"test:coverage": "BABEL_ENV=development jest --no-cache --coverage",
"test:lint": "./node_modules/.bin/eslint ./src"
},
"author": "Jan Mühlemann <jan.muehlemann@gmail.com> (https://github.com/jamuhl)",
"license": "MIT"
"license": "MIT",
"jest": {
"unmockedModulePathPatterns": [
"react"
]
}
}

@@ -98,2 +98,17 @@ (function (global, factory) {

var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
var _extends = Object.assign || function (target) {

@@ -185,2 +200,4 @@ for (var i = 1; i < arguments.length; i++) {

var wait = _options$wait === undefined ? false : _options$wait;
var _options$translateFun = options.translateFuncName;
var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun;

@@ -212,3 +229,3 @@

value: function getChildContext() {
return { t: this.t };
return defineProperty({}, translateFuncName, this[translateFuncName]);
}

@@ -218,3 +235,3 @@ }, {

value: function componentWillMount() {
this.t = this.i18n.getFixedT(null, namespaces);
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}

@@ -231,3 +248,3 @@ }, {

this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}

@@ -269,3 +286,3 @@ }, {

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

@@ -290,5 +307,3 @@ if (withRef) {

Translate.childContextTypes = {
t: React.PropTypes.func.isRequired
};
Translate.childContextTypes = defineProperty({}, translateFuncName, React.PropTypes.func.isRequired);

@@ -324,2 +339,7 @@ Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';

// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
var useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
var dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
var tOpts = _extends({}, this.props.options, { interpolation: { prefix: '#$?', suffix: '?$#' } });

@@ -337,3 +357,7 @@ var format = this.t(this.props.i18nKey, tOpts);

if (match.length === 0) return memo;
child = match;
if (useDangerouslySetInnerHTML) {
child = React__default.createElement(dangerouslySetInnerHTMLPartElement, { dangerouslySetInnerHTML: { __html: match } });
} else {
child = match;
}
} else {

@@ -380,3 +404,3 @@ child = _this2.props[match];

if (this.props.i18n !== nextProps.i18n) {
console.error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}

@@ -383,0 +407,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,t){return t={exports:{}},e(t,t.exports),t.exports}function r(e){return e.displayName||e.name||"Component"}function o(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=n.withRef,i=void 0!==o&&o,a=n.wait,s=void 0!==a&&a;return function(n){var o=function(t){function r(t,n){f(this,r);var o=v(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 y(r,t),d(r,[{key:"getChildContext",value:function(){return{t:this.t}}},{key:"componentWillMount",value:function(){this.t=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store.on("added removed",this.onI18nChanged)}},{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={i18nLoadedAt:t,t:this.t};return i&&(o.ref="wrappedInstance"),!r&&s?null:u.createElement(n,h({},this.props,o))}}]),r}(t.Component);return o.WrappedComponent=n,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes={t:t.PropTypes.func.isRequired},o.displayName="Translate("+r(n)+")",o.namespaces=e,p(o,n)}}function i(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===l(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 c=m(s.value,2),p=c[0],f=c[1];t(f,n,p)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function a(e){var t=[];return i(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function s(e){var t=e.components,n=e.i18n,r=a(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var u="default"in t?t.default:t,c=n(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}}),p=c&&"object"==typeof c&&"default"in c?c.default:c,l="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},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},d=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=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},y=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)},v=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},m=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")}}(),g=function(e){function t(e,n){f(this,t);var r=v(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return y(t,e),d(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=h({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),o=this.t(this.props.i18nKey,r);if(!o||"string"!=typeof o)return u.createElement("noscript",null);var i=[];return o.split(n).reduce(function(t,n,r){var i;if(r%2===0){if(0===n.length)return t;i=n}else i=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+o);return t.push(i),t},i),u.createElement.apply(this,[t,null].concat(i))}}]),t}(t.Component);g.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var b=function(e){function n(e,t){f(this,n);var r=v(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return y(n,e),d(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);b.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},b.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=s,e.translate=o,e.Interpolate=g,e.I18nextProvider=b,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,t){return t={exports:{}},e(t,t.exports),t.exports}function r(e){return e.displayName||e.name||"Component"}function o(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=n.withRef,i=void 0!==o&&o,a=n.wait,s=void 0!==a&&a,c=n.translateFuncName,l=void 0===c?"t":c;return function(n){var o=function(t){function r(t,n){f(this,r);var o=v(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 m(r,t),d(r,[{key:"getChildContext",value:function(){return h({},l,this[l])}},{key:"componentWillMount",value:function(){this[l]=this.i18n.getFixedT(null,e)}},{key:"componentDidMount",value:function(){var t=this;this.mounted=!0,this.i18n.loadNamespaces(e,function(){t.mounted&&t.setState({ready:!0})}),this.i18n.on("languageChanged loaded",this.onI18nChanged),this.i18n.store&&this.i18n.store.on("added removed",this.onI18nChanged)}},{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},l,this[l]);return i&&(o.ref="wrappedInstance"),!r&&s?null:u.createElement(n,y({},this.props,o))}}]),r}(t.Component);return o.WrappedComponent=n,o.contextTypes={i18n:t.PropTypes.object.isRequired},o.childContextTypes=h({},l,t.PropTypes.func.isRequired),o.displayName="Translate("+r(n)+")",o.namespaces=e,p(o,n)}}function i(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===l(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 c=g(s.value,2),p=c[0],f=c[1];t(f,n,p)}}catch(e){i=!0,a=e}finally{try{!o&&u.return&&u.return()}finally{if(i)throw a}}}else t(e[n],n)}function a(e){var t=[];return i(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){t.indexOf(e)===-1&&t.push(e)})}),t}function s(e){var t=e.components,n=e.i18n,r=a(t);return new Promise(function(e){n.loadNamespaces(r,e)})}var u="default"in t?t.default:t,c=n(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}}),p=c&&"object"==typeof c&&"default"in c?c.default:c,l="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},f=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},d=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},y=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},m=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)},v=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")}}(),b=function(e){function t(e,n){f(this,t);var r=v(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return m(t,e),d(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.useDangerouslySetInnerHTML||!1,o=this.props.dangerouslySetInnerHTMLPartElement||"span",i=y({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),a=this.t(this.props.i18nKey,i);if(!a||"string"!=typeof a)return u.createElement("noscript",null);var s=[];return a.split(n).reduce(function(t,n,i){var s;if(i%2===0){if(0===n.length)return t;s=r?u.createElement(o,{dangerouslySetInnerHTML:{__html:n}}):n}else s=e.props[n],e.props[n]||e.i18n.services.logger.warn("interpolator: missed to pass in variable "+n+" for interpolating "+a);return t.push(s),t},s),u.createElement.apply(this,[t,null].concat(s))}}]),t}(t.Component);b.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var x=function(e){function n(e,t){f(this,n);var r=v(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return m(n,e),d(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);x.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},x.childContextTypes={i18n:t.PropTypes.object.isRequired},e.loadNamespaces=s,e.translate=o,e.Interpolate=b,e.I18nextProvider=x,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -55,2 +55,3 @@ # react-i18next

- passing `{ withRef: true }` to options store a ref to the wrapped component instance making it available via `getWrappedInstance()` method
- 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

@@ -159,2 +160,4 @@

- parent: optional component to wrap translation into (default 'span')
- useDangerouslySetInnerHTML: allows use of raw html tags in translation values
- dangerouslySetInnerHTMLPartElement: optional component to wrap parts of translation values into (default 'span'), used with `useDangerouslySetInnerHTML={true}` only
- ...props: values to interpolate into found translation (eg. `my value with {{replaceMe}} interpolation`)

@@ -166,3 +169,3 @@

{
"interpolateSample": "you can interpolate {{value}} or {{component}} via interpolate component!"
"interpolateSample": "you <strong>can</strong> interpolate {{value}} or {{component}} via interpolate component!"
}

@@ -186,5 +189,14 @@ ```

<span>
you can interpolate "some string" or <strong>a interpolated component</strong> via interpolate component!
you &lt;strong&gt;can&lt;/strong&gt; interpolate "some string" or <strong>a interpolated component</strong> via interpolate component!
</span>
*/}
<Interpolate i18nKey='ns:interpolateSample' useDangerouslySetInnerHTML={true} value='"some string"' component={interpolateComponent} />
{/*
=>
<span>
you <strong>can</strong> interpolate "some string" or <strong>a interpolated component</strong> via interpolate component!
</span>
*/}
</div>

@@ -191,0 +203,0 @@ )

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

import React, { Component, PropTypes, Children } from 'react';
import { Component, PropTypes, Children } from 'react';

@@ -15,3 +15,3 @@ class I18nextProvider extends Component {

if (this.props.i18n !== nextProps.i18n) {
console.error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
throw new Error('[react-i18next][I18nextProvider]does not support changing the i18n object.');
}

@@ -18,0 +18,0 @@ }

@@ -15,2 +15,7 @@ import React, { Component, PropTypes } from 'react';

// Set to true if you want to use raw HTML in translation values
// See https://github.com/i18next/react-i18next/issues/189
const useDangerouslySetInnerHTML = this.props.useDangerouslySetInnerHTML || false;
const dangerouslySetInnerHTMLPartElement = this.props.dangerouslySetInnerHTMLPartElement || 'span';
let tOpts = {...{}, ...this.props.options, ...{interpolation: { prefix: '#$?', suffix: '?$#'}}}

@@ -28,3 +33,7 @@ let format = this.t(this.props.i18nKey, tOpts);

if (match.length === 0) return memo;
child = match;
if (useDangerouslySetInnerHTML) {
child = React.createElement(dangerouslySetInnerHTMLPartElement, {dangerouslySetInnerHTML: {__html: match}});
} else {
child = match;
}
} else {

@@ -31,0 +40,0 @@ child = this.props[match];

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

export default function translate(namespaces, options = {}) {
const { withRef = false, wait = false } = options;
const { withRef = false, wait = false, translateFuncName = 't' } = options;

@@ -29,7 +29,7 @@ return function Wrapper(WrappedComponent) {

getChildContext() {
return { t: this.t };
return { [translateFuncName]: this[translateFuncName] };
}
componentWillMount() {
this.t = this.i18n.getFixedT(null, namespaces);
this[translateFuncName] = this.i18n.getFixedT(null, namespaces);
}

@@ -43,3 +43,3 @@

this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
this.i18n.store && this.i18n.store.on('added removed', this.onI18nChanged);
}

@@ -77,3 +77,3 @@

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

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

Translate.childContextTypes = {
t: PropTypes.func.isRequired
[translateFuncName]: PropTypes.func.isRequired
};

@@ -103,0 +103,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