text: 'use strict';Object.defineProperty(exports,'__esModule',{value:true});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}}();var _react=require('react');var _react2=_interopRequireDefault(_react);var _propTypes=require('prop-types');var _reactDeepForceUpdate=require('react-deep-force-update');var _reactDeepForceUpdate2=_interopRequireDefault(_reactDeepForceUpdate);var _actions=require('../actions');var _getTranslateFunction=require('../getTranslateFunction');var _getTranslateFunction2=_interopRequireDefault(_getTranslateFunction);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')}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called')}return call&&(typeof call==='object'||typeof call==='function')?call:self}function _inherits(subClass,superClass){if(typeof superClass!=='function'&&superClass!==null){throw new TypeError('Super expression must either be null or a function, not '+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var I18n=function(_React$Component){_inherits(I18n,_React$Component);function I18n(){_classCallCheck(this,I18n);return _possibleConstructorReturn(this,(I18n.__proto__||Object.getPrototypeOf(I18n)).apply(this,arguments))}_createClass(I18n,[{key:'getChildContext',value:function getChildContext(){var _props=this.props,lang=_props.lang,fallbackLang=_props.fallbackLang,useReducer=_props.useReducer,translations_reducer=_props.translations_reducer,translations=_props.translations,newFallbackLang=_props.newFallbackLang;return{t:(0,_getTranslateFunction2.default)(useReducer?translations_reducer:translations,lang,newFallbackLang?newFallbackLang:fallbackLang)}}},{key:'shouldComponentUpdate',value:function shouldComponentUpdate(nextProps,nextState){if(this.props.forceRefresh&&!nextProps.forceRefresh){return false}return true}},{key:'componentDidUpdate',value:function componentDidUpdate(prevProps,prevState){if(prevProps.lang!==this.props.lang||!prevProps.forceRefresh&&this.props.forceRefresh){(0,_reactDeepForceUpdate2.default)(this);if(this.props.forceRefresh){this.props.dispatch((0,_actions.setForceRefresh)(false))}}}},{key:'componentWillMount',value:function componentWillMount(){if(!this.props.initialized){this.props.dispatch((0,_actions.setLanguage)(this.props.initialLang))}}},{key:'render',value:function render(){return this.props.children}}]);return I18n}(_react2.default.Component);I18n.childContextTypes={t:_propTypes.PropTypes.func.isRequired};I18n.propTypes={translations:_propTypes.PropTypes.object.isRequired,useReducer:_propTypes.PropTypes.bool,initialLang:_propTypes.PropTypes.string,fallbackLang:_propTypes.PropTypes.string,initialized:_propTypes.PropTypes.bool};I18n.defaultProps={useReducer:false,initialLang:'en',fallbackLang:null};exports.default=I18n;