forked from i18next/react-i18next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-i18next.min.js
1 lines (1 loc) · 4.07 KB
/
react-i18next.min.js
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){return function(r){var s=void 0,a=void 0,u=function(t){function n(e,t){i.classCallCheck(this,n);var r=i.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,e,t));return a=t.i18n,r.state={i18nLoadedAt:null},r}return i.inherits(n,t),i.createClass(n,[{key:"getChildContext",value:function(){return{t:s}}},{key:"componentWillMount",value:function(){this.mounted=!0,a.loadNamespaces(e),s=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:"render",value:function(){var e=this.state.i18nLoadedAt;return o.createElement(r,i["extends"]({},this.props,{t:s,i18nLoadedAt:e}))}}]),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}}var o="default"in t?t["default"]:t,i={};i.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i.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}}(),i["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},i.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)},i.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};var s=function(e){function t(e,n){i.classCallCheck(this,t);var r=i.possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e,n));return r.i18n=n.i18n,r.t=n.t,r}return i.inherits(t,e),i.createClass(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=i["extends"]({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),s=this.t(this.props.i18nKey,r);if(!s||"string"!=typeof s)return o.createElement("noscript",null);var a=[];return s.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},a),o.createElement.apply(this,[t,this.props].concat(a))}}]),t}(t.Component);s.contextTypes={i18n:t.PropTypes.object.isRequired,t:t.PropTypes.func.isRequired};var a=function(e){function n(e,t){i.classCallCheck(this,n);var r=i.possibleConstructorReturn(this,Object.getPrototypeOf(n).call(this,e,t));return r.i18n=e.i18n,r}return i.inherits(n,e),i.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);a.propTypes={i18n:t.PropTypes.object.isRequired,children:t.PropTypes.element.isRequired},a.childContextTypes={i18n:t.PropTypes.object.isRequired},e.translate=r,e.Interpolate=s,e.I18nextProvider=a});