react-i18next
Advanced tools
Comparing version 6.0.3 to 6.0.4
@@ -532,4 +532,4 @@ define(['exports', 'react', 'prop-types'], function (exports, React, PropTypes) { 'use strict'; | ||
return function Wrapper(WrappedComponent) { | ||
var Translate = function (_PureComponent) { | ||
inherits(Translate, _PureComponent); | ||
var Translate = function (_Component) { | ||
inherits(Translate, _Component); | ||
@@ -582,3 +582,3 @@ function Translate(props, context) { | ||
return Translate; | ||
}(PureComponent); | ||
}(React.Component); | ||
@@ -585,0 +585,0 @@ Translate.WrappedComponent = WrappedComponent; |
@@ -1,1 +0,1 @@ | ||
define(["exports","react","prop-types"],function(t,e,n){"use strict";function i(t){W=E({},W,t)}function r(){return W}function o(t){M=t}function a(){return M}function s(t){return t.displayName||t.name||"Component"}function c(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){var o=function(n){function o(n,i){T(this,o);var s=L(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,n,i));s.i18n=i.i18n||n.i18n||e.i18n||a(),"string"==typeof(t=t||s.i18n.options.defaultNS)&&(t=[t]);var c=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),c,e),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return N(o,n),C(o,[{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var e=this,n={};return this.options.withRef&&(n.ref=function(t){e.wrappedInstance=t}),g.createElement(K,E({ns:t},this.options,this.props,{i18n:this.i18n}),function(t,r){return g.createElement(i,E({},e.props,n,r))})}}]),o}(PureComponent);return o.WrappedComponent=i,o.contextTypes={i18n:n.object},o.displayName="Translate("+s(i)+")",o.namespaces=t,_(o,i)}}function p(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":k(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),e.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":k(a))||s)e.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(p)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],U.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===k(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=A(s.value,2),u=p[0];e(p[1],n,u)}}catch(t){o=!0,a=t}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else e(t[n],n)}function m(t){var e=[];return v(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var g="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var b={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},O=Object.defineProperty,w=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,I=Object.getOwnPropertyDescriptor,j=Object.getPrototypeOf,P=j&&j(Object),_=function t(e,n,i){if("string"!=typeof n){if(P){var r=j(n);r&&r!==P&&t(e,r,i)}var o=w(n);x&&(o=o.concat(x(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=I(n,s);try{O(e,s,c)}catch(t){}}}return e}return e},k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},N=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},R=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},L=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},A=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),W={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},M=void 0,q={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){T(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=n.i18n||t.i18n||a(),i.namespaces=i.props.ns||i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var o=i.i18n&&i.i18n.options.react||{};return i.options=E({},r(),o,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1),i.state={i18nLoadedAt:null,ready:!1},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return N(e,t),C(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t}))}}]),e}(e.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},c.setDefaults=i,c.setI18n=o;var $=function(t){function e(t,n){T(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return N(e,t),C(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",c=E({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,c);if(!p||"string"!=typeof p)return g.createElement("noscript",null);var u=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+p),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};p.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),g.createElement.apply(this,[e,f].concat(u))}}]),e}(e.PureComponent);$.propTypes={className:n.string},$.defaultProps={className:""},$.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var z={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},H=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,V=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},U={parse:function(t,e){e||(e={}),e.components||(e.components=J);var n,i=[],r=-1,o=[],a=!1;return t.replace(F,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,l="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=c+s.length,d=t.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||p(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!l||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&p(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&p(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+l("",e)},"")}},B=function(t){function e(t,n){T(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return N(e,t),C(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=R(t,["children","count","parent","i18nKey"]),a=d("",e,0),s=r||a,c=this.t(s,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:a,count:n});if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var p="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];r&&this.i18n.options.nsSeparator&&r.indexOf(this.i18n.options.nsSeparator)>-1&&(p=r.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(o["data-i18next-options"]=JSON.stringify({ns:p}))}return g.createElement(i,o,y(e,c,this.i18n))}}]),e}(g.PureComponent);B.propTypes={count:n.number,parent:n.string,i18nKey:n.string},B.defaultProps={parent:"div"},B.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){T(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return N(n,t),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},t.translate=c,t.I18n=K,t.Interpolate=$,t.Trans=B,t.I18nextProvider=G,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=m(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=q,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
define(["exports","react","prop-types"],function(t,e,n){"use strict";function i(t){W=E({},W,t)}function r(){return W}function o(t){M=t}function a(){return M}function s(t){return t.displayName||t.name||"Component"}function c(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(e){function n(e,o){T(this,n);var s=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,o));s.i18n=o.i18n||e.i18n||i.i18n||a(),"string"==typeof(t=t||s.i18n.options.defaultNS)&&(t=[t]);var c=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),c,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return N(n,e),C(n,[{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var e=this,n={};return this.options.withRef&&(n.ref=function(t){e.wrappedInstance=t}),g.createElement(K,E({ns:t},this.options,this.props,{i18n:this.i18n}),function(t,i){return g.createElement(o,E({},e.props,n,i))})}}]),n}(e.Component);return c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=t,P(c,o)}}function p(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":k(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),e.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":k(a))||s)e.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(p)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],U.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===k(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=A(s.value,2),u=p[0];e(p[1],n,u)}}catch(t){o=!0,a=t}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else e(t[n],n)}function m(t){var e=[];return v(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var g="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var b={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},O=Object.defineProperty,w=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,I=Object.getOwnPropertyDescriptor,j=Object.getPrototypeOf,_=j&&j(Object),P=function t(e,n,i){if("string"!=typeof n){if(_){var r=j(n);r&&r!==_&&t(e,r,i)}var o=w(n);x&&(o=o.concat(x(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=I(n,s);try{O(e,s,c)}catch(t){}}}return e}return e},k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},N=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},R=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},L=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},A=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),W={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},M=void 0,q={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){T(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=n.i18n||t.i18n||a(),i.namespaces=i.props.ns||i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var o=i.i18n&&i.i18n.options.react||{};return i.options=E({},r(),o,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1),i.state={i18nLoadedAt:null,ready:!1},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return N(e,t),C(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t}))}}]),e}(e.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},c.setDefaults=i,c.setI18n=o;var $=function(t){function e(t,n){T(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return N(e,t),C(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",c=E({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,c);if(!p||"string"!=typeof p)return g.createElement("noscript",null);var u=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+p),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};p.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),g.createElement.apply(this,[e,f].concat(u))}}]),e}(e.PureComponent);$.propTypes={className:n.string},$.defaultProps={className:""},$.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var z={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},H=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,V=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},U={parse:function(t,e){e||(e={}),e.components||(e.components=J);var n,i=[],r=-1,o=[],a=!1;return t.replace(F,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,l="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=c+s.length,d=t.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||p(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!l||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&p(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&p(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+l("",e)},"")}},B=function(t){function e(t,n){T(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return N(e,t),C(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=R(t,["children","count","parent","i18nKey"]),a=d("",e,0),s=r||a,c=this.t(s,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:a,count:n});if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var p="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];r&&this.i18n.options.nsSeparator&&r.indexOf(this.i18n.options.nsSeparator)>-1&&(p=r.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(o["data-i18next-options"]=JSON.stringify({ns:p}))}return g.createElement(i,o,y(e,c,this.i18n))}}]),e}(g.PureComponent);B.propTypes={count:n.number,parent:n.string,i18nKey:n.string},B.defaultProps={parent:"div"},B.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){T(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return N(n,t),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},t.translate=c,t.I18n=K,t.Interpolate=$,t.Trans=B,t.I18nextProvider=G,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=m(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=q,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -48,4 +48,4 @@ 'use strict'; | ||
return function Wrapper(WrappedComponent) { | ||
var Translate = function (_PureComponent) { | ||
_inherits(Translate, _PureComponent); | ||
var Translate = function (_Component) { | ||
_inherits(Translate, _Component); | ||
@@ -99,3 +99,3 @@ function Translate(props, context) { | ||
return Translate; | ||
}(PureComponent); | ||
}(_react.Component); | ||
@@ -102,0 +102,0 @@ Translate.WrappedComponent = WrappedComponent; |
@@ -26,4 +26,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; }; | ||
return function Wrapper(WrappedComponent) { | ||
var Translate = function (_PureComponent) { | ||
_inherits(Translate, _PureComponent); | ||
var Translate = function (_Component) { | ||
_inherits(Translate, _Component); | ||
@@ -77,3 +77,3 @@ function Translate(props, context) { | ||
return Translate; | ||
}(PureComponent); | ||
}(Component); | ||
@@ -80,0 +80,0 @@ Translate.WrappedComponent = WrappedComponent; |
@@ -536,4 +536,4 @@ (function (global, factory) { | ||
return function Wrapper(WrappedComponent) { | ||
var Translate = function (_PureComponent) { | ||
inherits(Translate, _PureComponent); | ||
var Translate = function (_Component) { | ||
inherits(Translate, _Component); | ||
@@ -586,3 +586,3 @@ function Translate(props, context) { | ||
return Translate; | ||
}(PureComponent); | ||
}(React.Component); | ||
@@ -589,0 +589,0 @@ Translate.WrappedComponent = WrappedComponent; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){A=E({},A,t)}function r(){return A}function o(t){W=t}function a(){return W}function s(t){return t.displayName||t.name||"Component"}function p(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){var o=function(n){function o(n,i){k(this,o);var s=L(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,n,i));s.i18n=i.i18n||n.i18n||e.i18n||a(),"string"==typeof(t=t||s.i18n.options.defaultNS)&&(t=[t]);var p=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),p,e),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(o,n),C(o,[{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var e=this,n={};return this.options.withRef&&(n.ref=function(t){e.wrappedInstance=t}),g.createElement(K,E({ns:t},this.options,this.props,{i18n:this.i18n}),function(t,r){return g.createElement(i,E({},e.props,n,r))})}}]),o}(PureComponent);return o.WrappedComponent=i,o.contextTypes={i18n:n.object},o.displayName="Translate("+s(i)+")",o.namespaces=t,_(o,i)}}function c(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":T(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var p=i(h(a),r.children);a.dummy&&(a.children=p),e.push(g.cloneElement(a,E({},a.props,{key:o}),p))}else if("object"!==(void 0===a?"undefined":T(a))||s)e.push(a);else{var c=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(c)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],U.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===T(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var c=q(s.value,2),u=c[0];e(c[1],n,u)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function m(t){var e=[];return v(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var g="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var b={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},x=Object.defineProperty,O=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,j=Object.getOwnPropertyDescriptor,w=Object.getPrototypeOf,P=w&&w(Object),_=function t(e,n,i){if("string"!=typeof n){if(P){var r=w(n);r&&r!==P&&t(e,r,i)}var o=O(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var p=j(n,s);try{x(e,s,p)}catch(t){}}}return e}return e},T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},N=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},L=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},q=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),A={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=n.i18n||t.i18n||a(),i.namespaces=i.props.ns||i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var o=i.i18n&&i.i18n.options.react||{};return i.options=E({},r(),o,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1),i.state={i18nLoadedAt:null,ready:!1},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(e,t),C(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t}))}}]),e}(e.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},p.setDefaults=i,p.setI18n=o;var $=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=E({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,p);if(!c||"string"!=typeof c)return g.createElement("noscript",null);var u=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+c),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};c.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),g.createElement.apply(this,[e,f].concat(u))}}]),e}(e.PureComponent);$.propTypes={className:n.string},$.defaultProps={className:""},$.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var z={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},H=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,V=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},U={parse:function(t,e){e||(e={}),e.components||(e.components=J);var n,i=[],r=-1,o=[],a=!1;return t.replace(F,function(s,p){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,l="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=p+s.length,d=t.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||c(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!l||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&c(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&c(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+l("",e)},"")}},B=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=N(t,["children","count","parent","i18nKey"]),a=d("",e,0),s=r||a,p=this.t(s,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:a,count:n});if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];r&&this.i18n.options.nsSeparator&&r.indexOf(this.i18n.options.nsSeparator)>-1&&(c=r.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(o["data-i18next-options"]=JSON.stringify({ns:c}))}return g.createElement(i,o,y(e,p,this.i18n))}}]),e}(g.PureComponent);B.propTypes={count:n.number,parent:n.string,i18nKey:n.string},B.defaultProps={parent:"div"},B.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){k(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return R(n,t),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},t.translate=p,t.I18n=K,t.Interpolate=$,t.Trans=B,t.I18nextProvider=G,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=m(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){A=E({},A,t)}function r(){return A}function o(t){W=t}function a(){return W}function s(t){return t.displayName||t.name||"Component"}function p(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var p=function(e){function n(e,o){k(this,n);var s=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,o));s.i18n=o.i18n||e.i18n||i.i18n||a(),"string"==typeof(t=t||s.i18n.options.defaultNS)&&(t=[t]);var p=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),p,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(n,e),C(n,[{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var e=this,n={};return this.options.withRef&&(n.ref=function(t){e.wrappedInstance=t}),g.createElement(K,E({ns:t},this.options,this.props,{i18n:this.i18n}),function(t,i){return g.createElement(o,E({},e.props,n,i))})}}]),n}(e.Component);return p.WrappedComponent=o,p.contextTypes={i18n:n.object},p.displayName="Translate("+s(o)+")",p.namespaces=t,_(p,o)}}function c(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":T(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var p=i(h(a),r.children);a.dummy&&(a.children=p),e.push(g.cloneElement(a,E({},a.props,{key:o}),p))}else if("object"!==(void 0===a?"undefined":T(a))||s)e.push(a);else{var c=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(c)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],U.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===T(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var c=q(s.value,2),u=c[0];e(c[1],n,u)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function m(t){var e=[];return v(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var g="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var b={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},x=Object.defineProperty,O=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,j=Object.getOwnPropertyDescriptor,w=Object.getPrototypeOf,P=w&&w(Object),_=function t(e,n,i){if("string"!=typeof n){if(P){var r=w(n);r&&r!==P&&t(e,r,i)}var o=O(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var p=j(n,s);try{x(e,s,p)}catch(t){}}}return e}return e},T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},N=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},L=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},q=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),A={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=n.i18n||t.i18n||a(),i.namespaces=i.props.ns||i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var o=i.i18n&&i.i18n.options.react||{};return i.options=E({},r(),o,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1),i.state={i18nLoadedAt:null,ready:!1},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(e,t),C(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t}))}}]),e}(e.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},p.setDefaults=i,p.setI18n=o;var $=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=E({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,p);if(!c||"string"!=typeof c)return g.createElement("noscript",null);var u=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+c),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};c.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),g.createElement.apply(this,[e,f].concat(u))}}]),e}(e.PureComponent);$.propTypes={className:n.string},$.defaultProps={className:""},$.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var z={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},H=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,V=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},U={parse:function(t,e){e||(e={}),e.components||(e.components=J);var n,i=[],r=-1,o=[],a=!1;return t.replace(F,function(s,p){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,l="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=p+s.length,d=t.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||c(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!l||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&c(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&c(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+l("",e)},"")}},B=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=N(t,["children","count","parent","i18nKey"]),a=d("",e,0),s=r||a,p=this.t(s,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:a,count:n});if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];r&&this.i18n.options.nsSeparator&&r.indexOf(this.i18n.options.nsSeparator)>-1&&(c=r.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(o["data-i18next-options"]=JSON.stringify({ns:c}))}return g.createElement(i,o,y(e,p,this.i18n))}}]),e}(g.PureComponent);B.propTypes={count:n.number,parent:n.string,i18nKey:n.string},B.defaultProps={parent:"div"},B.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){k(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return R(n,t),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},t.translate=p,t.I18n=K,t.Interpolate=$,t.Trans=B,t.I18nextProvider=G,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=m(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "react-i18next", | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js", |
@@ -536,4 +536,4 @@ (function (global, factory) { | ||
return function Wrapper(WrappedComponent) { | ||
var Translate = function (_PureComponent) { | ||
inherits(Translate, _PureComponent); | ||
var Translate = function (_Component) { | ||
inherits(Translate, _Component); | ||
@@ -586,3 +586,3 @@ function Translate(props, context) { | ||
return Translate; | ||
}(PureComponent); | ||
}(React.Component); | ||
@@ -589,0 +589,0 @@ Translate.WrappedComponent = WrappedComponent; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){A=E({},A,t)}function r(){return A}function o(t){W=t}function a(){return W}function s(t){return t.displayName||t.name||"Component"}function p(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){var o=function(n){function o(n,i){k(this,o);var s=L(this,(o.__proto__||Object.getPrototypeOf(o)).call(this,n,i));s.i18n=i.i18n||n.i18n||e.i18n||a(),"string"==typeof(t=t||s.i18n.options.defaultNS)&&(t=[t]);var p=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),p,e),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(o,n),C(o,[{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var e=this,n={};return this.options.withRef&&(n.ref=function(t){e.wrappedInstance=t}),g.createElement(K,E({ns:t},this.options,this.props,{i18n:this.i18n}),function(t,r){return g.createElement(i,E({},e.props,n,r))})}}]),o}(PureComponent);return o.WrappedComponent=i,o.contextTypes={i18n:n.object},o.displayName="Translate("+s(i)+")",o.namespaces=t,_(o,i)}}function c(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":T(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var p=i(h(a),r.children);a.dummy&&(a.children=p),e.push(g.cloneElement(a,E({},a.props,{key:o}),p))}else if("object"!==(void 0===a?"undefined":T(a))||s)e.push(a);else{var c=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(c)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],U.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===T(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var c=q(s.value,2),u=c[0];e(c[1],n,u)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function m(t){var e=[];return v(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var g="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var b={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},x=Object.defineProperty,O=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,j=Object.getOwnPropertyDescriptor,w=Object.getPrototypeOf,P=w&&w(Object),_=function t(e,n,i){if("string"!=typeof n){if(P){var r=w(n);r&&r!==P&&t(e,r,i)}var o=O(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var p=j(n,s);try{x(e,s,p)}catch(t){}}}return e}return e},T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},N=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},L=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},q=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),A={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=n.i18n||t.i18n||a(),i.namespaces=i.props.ns||i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var o=i.i18n&&i.i18n.options.react||{};return i.options=E({},r(),o,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1),i.state={i18nLoadedAt:null,ready:!1},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(e,t),C(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t}))}}]),e}(e.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},p.setDefaults=i,p.setI18n=o;var $=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=E({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,p);if(!c||"string"!=typeof c)return g.createElement("noscript",null);var u=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+c),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};c.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),g.createElement.apply(this,[e,f].concat(u))}}]),e}(e.PureComponent);$.propTypes={className:n.string},$.defaultProps={className:""},$.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var z={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},H=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,V=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},U={parse:function(t,e){e||(e={}),e.components||(e.components=J);var n,i=[],r=-1,o=[],a=!1;return t.replace(F,function(s,p){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,l="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=p+s.length,d=t.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||c(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!l||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&c(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&c(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+l("",e)},"")}},B=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=N(t,["children","count","parent","i18nKey"]),a=d("",e,0),s=r||a,p=this.t(s,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:a,count:n});if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];r&&this.i18n.options.nsSeparator&&r.indexOf(this.i18n.options.nsSeparator)>-1&&(c=r.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(o["data-i18next-options"]=JSON.stringify({ns:c}))}return g.createElement(i,o,y(e,p,this.i18n))}}]),e}(g.PureComponent);B.propTypes={count:n.number,parent:n.string,i18nKey:n.string},B.defaultProps={parent:"div"},B.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){k(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return R(n,t),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},t.translate=p,t.I18n=K,t.Interpolate=$,t.Trans=B,t.I18nextProvider=G,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=m(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){A=E({},A,t)}function r(){return A}function o(t){W=t}function a(){return W}function s(t){return t.displayName||t.name||"Component"}function p(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var p=function(e){function n(e,o){k(this,n);var s=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,o));s.i18n=o.i18n||e.i18n||i.i18n||a(),"string"==typeof(t=t||s.i18n.options.defaultNS)&&(t=[t]);var p=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),p,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(n,e),C(n,[{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var e=this,n={};return this.options.withRef&&(n.ref=function(t){e.wrappedInstance=t}),g.createElement(K,E({ns:t},this.options,this.props,{i18n:this.i18n}),function(t,i){return g.createElement(o,E({},e.props,n,i))})}}]),n}(e.Component);return p.WrappedComponent=o,p.contextTypes={i18n:n.object},p.displayName="Translate("+s(o)+")",p.namespaces=t,_(p,o)}}function c(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":T(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var p=i(h(a),r.children);a.dummy&&(a.children=p),e.push(g.cloneElement(a,E({},a.props,{key:o}),p))}else if("object"!==(void 0===a?"undefined":T(a))||s)e.push(a);else{var c=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(c)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],U.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===T(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=Object.entries(t[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var c=q(s.value,2),u=c[0];e(c[1],n,u)}}catch(t){o=!0,a=t}finally{try{!r&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}function m(t){var e=[];return v(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var g="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var b={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},S={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},x=Object.defineProperty,O=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,j=Object.getOwnPropertyDescriptor,w=Object.getPrototypeOf,P=w&&w(Object),_=function t(e,n,i){if("string"!=typeof n){if(P){var r=w(n);r&&r!==P&&t(e,r,i)}var o=O(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var p=j(n,s);try{x(e,s,p)}catch(t){}}}return e}return e},T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},N=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},L=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},q=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),A={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=n.i18n||t.i18n||a(),i.namespaces=i.props.ns||i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var o=i.i18n&&i.i18n.options.react||{};return i.options=E({},r(),o,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1),i.state={i18nLoadedAt:null,ready:!1},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(e,t),C(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t}))}}]),e}(e.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},p.setDefaults=i,p.setI18n=o;var $=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=E({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,p);if(!c||"string"!=typeof c)return g.createElement("noscript",null);var u=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+c),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};c.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),g.createElement.apply(this,[e,f].concat(u))}}]),e}(e.PureComponent);$.propTypes={className:n.string},$.defaultProps={className:""},$.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var z={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},H=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,V=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},U={parse:function(t,e){e||(e={}),e.components||(e.components=J);var n,i=[],r=-1,o=[],a=!1;return t.replace(F,function(s,p){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,l="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=p+s.length,d=t.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||c(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!l||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&c(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&c(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+l("",e)},"")}},B=function(t){function e(t,n){k(this,e);var i=L(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return R(e,t),C(e,[{key:"render",value:function(){var t=this.props,e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=N(t,["children","count","parent","i18nKey"]),a=d("",e,0),s=r||a,p=this.t(s,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:a,count:n});if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var c="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];r&&this.i18n.options.nsSeparator&&r.indexOf(this.i18n.options.nsSeparator)>-1&&(c=r.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(o["data-i18next-options"]=JSON.stringify({ns:c}))}return g.createElement(i,o,y(e,p,this.i18n))}}]),e}(g.PureComponent);B.propTypes={count:n.number,parent:n.string,i18nKey:n.string},B.defaultProps={parent:"div"},B.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){k(this,n);var i=L(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return R(n,t),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},t.translate=p,t.I18n=K,t.Interpolate=$,t.Trans=B,t.I18nextProvider=G,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=m(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -15,3 +15,3 @@ import React, { Component } from 'react'; | ||
class Translate extends PureComponent { | ||
class Translate extends Component { | ||
constructor(props, context) { | ||
@@ -18,0 +18,0 @@ super(props, context); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
247175