react-i18next
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -0,1 +1,4 @@ | ||
### 7.0.1 | ||
- working Trans component without the need of setting options.react | ||
### 7.0.0 | ||
@@ -2,0 +5,0 @@ - **[BREAKING]** As with react 16 you can return multiple elements from render - based on that we do not need to return a wrapper any longer from Trans component. |
@@ -1017,10 +1017,11 @@ define(['exports', 'react', 'prop-types'], function (exports, React, PropTypes) { 'use strict'; | ||
var useAsParent = parent !== undefined ? parent : i18n.options.react.defaultTransParent; | ||
var reactI18nextOptions = i18n.options && i18n.options.react || {}; | ||
var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; | ||
var defaultValue = nodesToString('', children, 0); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
if (i18n.options.react && i18n.options.react.exposeNamespace) { | ||
if (reactI18nextOptions.exposeNamespace) { | ||
var ns = typeof t.ns === 'string' ? t.ns : t.ns[0]; | ||
@@ -1027,0 +1028,0 @@ if (i18nKey && i18n.options.nsSeparator && i18nKey.indexOf(i18n.options.nsSeparator) > -1) { |
@@ -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 i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(e){function n(e,o){P(this,n);var s=A(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 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 c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=t,_(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":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+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)}),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":T(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}],B.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,c=Object.entries(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=L(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},j=Object.defineProperty,w=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,x=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,k=I&&I(Object),_=function t(e,n,i){if("string"!=typeof n){if(k){var r=I(n);r&&r!==k&&t(e,r,i)}var o=w(n);O&&(o=o.concat(O(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=x(n,s);try{j(e,s,c)}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},P=(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},A=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},L=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){P(this,e);var i=A(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||{};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);var s=i.i18n.languages&&i.i18n.languages[0],c=!!s&&i.namespaces.every(function(t){return i.i18n.hasResourceBundle(s,t)});return i.state={i18nLoadedAt:null,ready:c},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},c.setDefaults=i,c.setI18n=o;var $=function(t){function e(t,n){P(this,e);var i=A(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",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):{},B={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)},"")}},U=function(t){function e(){return P(this,e),A(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return R(e,t),C(e,[{key:"render",value:function(){var t=E({i18n:this.context.i18n,t:this.context.t},this.props),e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=t.i18n,a=t.t,s=N(t,["children","count","parent","i18nKey","i18n","t"]),c=void 0!==i?i:o.options.react.defaultTransParent,p=d("",e,0),u=o.options.react&&o.options.react.hashTransKey,l=r||(u?u(p):p),f=l?a(l,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:p,count:n}):p;if(o.options.react&&o.options.react.exposeNamespace){var h="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(h=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:h}))}return c?g.createElement(c,s,y(e,f,o)):e}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.node,i18nKey:n.string,i18n:n.object,t:n.func},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){P(this,n);var i=A(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},Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=[e[n],t[e[n]]];return i}),t.translate=c,t.I18n=K,t.Interpolate=$,t.Trans=U,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){P(this,n);var s=A(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 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 c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=t,_(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":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+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)}),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":T(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}],B.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,c=Object.entries(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=L(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},j=Object.defineProperty,w=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,x=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,k=I&&I(Object),_=function t(e,n,i){if("string"!=typeof n){if(k){var r=I(n);r&&r!==k&&t(e,r,i)}var o=w(n);O&&(o=o.concat(O(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=x(n,s);try{j(e,s,c)}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},P=(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},A=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},L=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){P(this,e);var i=A(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||{};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);var s=i.i18n.languages&&i.i18n.languages[0],c=!!s&&i.namespaces.every(function(t){return i.i18n.hasResourceBundle(s,t)});return i.state={i18nLoadedAt:null,ready:c},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},c.setDefaults=i,c.setI18n=o;var $=function(t){function e(t,n){P(this,e);var i=A(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",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):{},B={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)},"")}},U=function(t){function e(){return P(this,e),A(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return R(e,t),C(e,[{key:"render",value:function(){var t=E({i18n:this.context.i18n,t:this.context.t},this.props),e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=t.i18n,a=t.t,s=N(t,["children","count","parent","i18nKey","i18n","t"]),c=o.options&&o.options.react||{},p=void 0!==i?i:c.defaultTransParent,u=d("",e,0),l=c.hashTransKey,f=r||(l?l(u):u),h=f?a(f,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:u,count:n}):u;if(c.exposeNamespace){var v="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(v=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:v}))}return p?g.createElement(p,s,y(e,h,o)):e}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.node,i18nKey:n.string,i18n:n.object,t:n.func},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){P(this,n);var i=A(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},Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=[e[n],t[e[n]]];return i}),t.translate=c,t.I18n=K,t.Interpolate=$,t.Trans=U,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})}); |
@@ -142,10 +142,11 @@ 'use strict'; | ||
var useAsParent = parent !== undefined ? parent : i18n.options.react.defaultTransParent; | ||
var reactI18nextOptions = i18n.options && i18n.options.react || {}; | ||
var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; | ||
var defaultValue = nodesToString('', children, 0); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
if (i18n.options.react && i18n.options.react.exposeNamespace) { | ||
if (reactI18nextOptions.exposeNamespace) { | ||
var ns = typeof t.ns === 'string' ? t.ns : t.ns[0]; | ||
@@ -152,0 +153,0 @@ if (i18nKey && i18n.options.nsSeparator && i18nKey.indexOf(i18n.options.nsSeparator) > -1) { |
@@ -126,10 +126,11 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var useAsParent = parent !== undefined ? parent : i18n.options.react.defaultTransParent; | ||
var reactI18nextOptions = i18n.options && i18n.options.react || {}; | ||
var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; | ||
var defaultValue = nodesToString('', children, 0); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
if (i18n.options.react && i18n.options.react.exposeNamespace) { | ||
if (reactI18nextOptions.exposeNamespace) { | ||
var ns = typeof t.ns === 'string' ? t.ns : t.ns[0]; | ||
@@ -136,0 +137,0 @@ if (i18nKey && i18n.options.nsSeparator && i18nKey.indexOf(i18n.options.nsSeparator) > -1) { |
@@ -1021,10 +1021,11 @@ (function (global, factory) { | ||
var useAsParent = parent !== undefined ? parent : i18n.options.react.defaultTransParent; | ||
var reactI18nextOptions = i18n.options && i18n.options.react || {}; | ||
var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; | ||
var defaultValue = nodesToString('', children, 0); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
if (i18n.options.react && i18n.options.react.exposeNamespace) { | ||
if (reactI18nextOptions.exposeNamespace) { | ||
var ns = typeof t.ns === 'string' ? t.ns : t.ns[0]; | ||
@@ -1031,0 +1032,0 @@ if (i18nKey && i18n.options.nsSeparator && i18nKey.indexOf(i18n.options.nsSeparator) > -1) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e){q=E({},q,e)}function r(){return q}function o(e){W=e}function a(){return W}function s(e){return e.displayName||e.name||"Component"}function c(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(t){function n(t,o){P(this,n);var s=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,o));s.i18n=o.i18n||t.i18n||i.i18n||a(),"string"==typeof(e=e||s.i18n.options.defaultNS)&&(e=[e]);var c=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),c,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(n,t),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 t=this,n={};return this.options.withRef&&(n.ref=function(e){t.wrappedInstance=e}),g.createElement(K,E({ns:e},this.options,this.props,{i18n:this.i18n}),function(e,i){return g.createElement(o,E({},t.props,n,i))})}}]),n}(t.Component);return c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=e,T(c,o)}}function p(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function u(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function l(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?u(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(l,"")+"</"+t.name+">"}}function f(e){return e&&(e.children||e.props&&e.props.children)}function h(e){return e&&e.children?e.children:e.props&&e.props.children}function d(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(f(t))e=e+"<"+i+">"+d("",h(t),n+1)+"</"+i+">";else if(g.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":_(t))){var r=E({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e}function y(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)t.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),t.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":_(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return h(i([{dummy:!0,children:e}],B.parse("<0>"+t+"</0>"))[0])}function v(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===_(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=L(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function m(e){var t=[];return v(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var g="default"in t?t.default:t;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},j=Object.defineProperty,x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,O=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,k=I&&I(Object),T=function e(t,n,i){if("string"!=typeof n){if(k){var r=I(n);r&&r!==k&&e(t,r,i)}var o=x(n);w&&(o=o.concat(w(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=O(n,s);try{j(t,s,c)}catch(e){}}}return t}return t},_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),C=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},R=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},N=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},A=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},L=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(e){i(e.options.react),o(e)}},D=!1,K=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=n.i18n||e.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||{};i.options=E({},r(),o,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1);var s=i.i18n.languages&&i.i18n.languages[0],c=!!s&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(s,e)});return i.state={i18nLoadedAt:null,ready:c},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(t,e),C(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.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 e=this,t=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t}))}}]),t}(t.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},c.setDefaults=i,c.setI18n=o;var $=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return R(t,e),C(t,[{key:"render",value:function(){var e=this,t=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(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},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,[t,f].concat(u))}}]),t}(t.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(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},B={parse:function(e,t){t||(t={}),t.components||(t.components=J);var n,i=[],r=-1,o=[],a=!1;return e.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=e.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||p(n.children,e,r,h,t.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,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&p(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+l("",t)},"")}},U=function(e){function t(){return P(this,t),A(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return R(t,e),C(t,[{key:"render",value:function(){var e=E({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.i18n,a=e.t,s=N(e,["children","count","parent","i18nKey","i18n","t"]),c=void 0!==i?i:o.options.react.defaultTransParent,p=d("",t,0),u=o.options.react&&o.options.react.hashTransKey,l=r||(u?u(p):p),f=l?a(l,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:p,count:n}):p;if(o.options.react&&o.options.react.exposeNamespace){var h="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(h=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:h}))}return c?g.createElement(c,s,y(t,f,o)):t}}]),t}(g.Component);U.propTypes={count:n.number,parent:n.node,i18nKey:n.string,i18n:n.object,t:n.func},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(e){function n(e,t){P(this,n);var i=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return R(n,e),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=c,e.I18n=K,e.Interpolate=$,e.Trans=U,e.I18nextProvider=G,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=m(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=M,e.setDefaults=i,e.getDefaults=r,e.setI18n=o,e.getI18n=a,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e){q=E({},q,e)}function r(){return q}function o(e){W=e}function a(){return W}function s(e){return e.displayName||e.name||"Component"}function c(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(t){function n(t,o){P(this,n);var s=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,o));s.i18n=o.i18n||t.i18n||i.i18n||a(),"string"==typeof(e=e||s.i18n.options.defaultNS)&&(e=[e]);var c=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),c,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(n,t),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 t=this,n={};return this.options.withRef&&(n.ref=function(e){t.wrappedInstance=e}),g.createElement(K,E({ns:e},this.options,this.props,{i18n:this.i18n}),function(e,i){return g.createElement(o,E({},t.props,n,i))})}}]),n}(t.Component);return c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=e,T(c,o)}}function p(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function u(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function l(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?u(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(l,"")+"</"+t.name+">"}}function f(e){return e&&(e.children||e.props&&e.props.children)}function h(e){return e&&e.children?e.children:e.props&&e.props.children}function d(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(f(t))e=e+"<"+i+">"+d("",h(t),n+1)+"</"+i+">";else if(g.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":_(t))){var r=E({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e}function y(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)t.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),t.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":_(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return h(i([{dummy:!0,children:e}],B.parse("<0>"+t+"</0>"))[0])}function v(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===_(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=L(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function m(e){var t=[];return v(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var g="default"in t?t.default:t;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},j=Object.defineProperty,x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,O=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,k=I&&I(Object),T=function e(t,n,i){if("string"!=typeof n){if(k){var r=I(n);r&&r!==k&&e(t,r,i)}var o=x(n);w&&(o=o.concat(w(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=O(n,s);try{j(t,s,c)}catch(e){}}}return t}return t},_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),C=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},R=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},N=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},A=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},L=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(e){i(e.options.react),o(e)}},D=!1,K=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=n.i18n||e.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||{};i.options=E({},r(),o,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1);var s=i.i18n.languages&&i.i18n.languages[0],c=!!s&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(s,e)});return i.state={i18nLoadedAt:null,ready:c},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(t,e),C(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.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 e=this,t=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t}))}}]),t}(t.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},c.setDefaults=i,c.setI18n=o;var $=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return R(t,e),C(t,[{key:"render",value:function(){var e=this,t=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(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},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,[t,f].concat(u))}}]),t}(t.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(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},B={parse:function(e,t){t||(t={}),t.components||(t.components=J);var n,i=[],r=-1,o=[],a=!1;return e.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=e.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||p(n.children,e,r,h,t.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,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&p(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+l("",t)},"")}},U=function(e){function t(){return P(this,t),A(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return R(t,e),C(t,[{key:"render",value:function(){var e=E({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.i18n,a=e.t,s=N(e,["children","count","parent","i18nKey","i18n","t"]),c=o.options&&o.options.react||{},p=void 0!==i?i:c.defaultTransParent,u=d("",t,0),l=c.hashTransKey,f=r||(l?l(u):u),h=f?a(f,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:u,count:n}):u;if(c.exposeNamespace){var v="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(v=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:v}))}return p?g.createElement(p,s,y(t,h,o)):t}}]),t}(g.Component);U.propTypes={count:n.number,parent:n.node,i18nKey:n.string,i18n:n.object,t:n.func},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(e){function n(e,t){P(this,n);var i=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return R(n,e),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=c,e.I18n=K,e.Interpolate=$,e.Trans=U,e.I18nextProvider=G,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=m(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=M,e.setDefaults=i,e.getDefaults=r,e.setI18n=o,e.getI18n=a,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "react-i18next", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js", |
@@ -1021,10 +1021,11 @@ (function (global, factory) { | ||
var useAsParent = parent !== undefined ? parent : i18n.options.react.defaultTransParent; | ||
var reactI18nextOptions = i18n.options && i18n.options.react || {}; | ||
var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; | ||
var defaultValue = nodesToString('', children, 0); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
if (i18n.options.react && i18n.options.react.exposeNamespace) { | ||
if (reactI18nextOptions.exposeNamespace) { | ||
var ns = typeof t.ns === 'string' ? t.ns : t.ns[0]; | ||
@@ -1031,0 +1032,0 @@ if (i18nKey && i18n.options.nsSeparator && i18nKey.indexOf(i18n.options.nsSeparator) > -1) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e){q=E({},q,e)}function r(){return q}function o(e){W=e}function a(){return W}function s(e){return e.displayName||e.name||"Component"}function c(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(t){function n(t,o){P(this,n);var s=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,o));s.i18n=o.i18n||t.i18n||i.i18n||a(),"string"==typeof(e=e||s.i18n.options.defaultNS)&&(e=[e]);var c=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),c,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(n,t),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 t=this,n={};return this.options.withRef&&(n.ref=function(e){t.wrappedInstance=e}),g.createElement(K,E({ns:e},this.options,this.props,{i18n:this.i18n}),function(e,i){return g.createElement(o,E({},t.props,n,i))})}}]),n}(t.Component);return c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=e,T(c,o)}}function p(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function u(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function l(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?u(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(l,"")+"</"+t.name+">"}}function f(e){return e&&(e.children||e.props&&e.props.children)}function h(e){return e&&e.children?e.children:e.props&&e.props.children}function d(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(f(t))e=e+"<"+i+">"+d("",h(t),n+1)+"</"+i+">";else if(g.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":_(t))){var r=E({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e}function y(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)t.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),t.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":_(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return h(i([{dummy:!0,children:e}],B.parse("<0>"+t+"</0>"))[0])}function v(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===_(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=L(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function m(e){var t=[];return v(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var g="default"in t?t.default:t;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},j=Object.defineProperty,x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,O=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,k=I&&I(Object),T=function e(t,n,i){if("string"!=typeof n){if(k){var r=I(n);r&&r!==k&&e(t,r,i)}var o=x(n);w&&(o=o.concat(w(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=O(n,s);try{j(t,s,c)}catch(e){}}}return t}return t},_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),C=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},R=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},N=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},A=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},L=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(e){i(e.options.react),o(e)}},D=!1,K=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=n.i18n||e.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||{};i.options=E({},r(),o,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1);var s=i.i18n.languages&&i.i18n.languages[0],c=!!s&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(s,e)});return i.state={i18nLoadedAt:null,ready:c},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(t,e),C(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.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 e=this,t=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t}))}}]),t}(t.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},c.setDefaults=i,c.setI18n=o;var $=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return R(t,e),C(t,[{key:"render",value:function(){var e=this,t=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(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},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,[t,f].concat(u))}}]),t}(t.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(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},B={parse:function(e,t){t||(t={}),t.components||(t.components=J);var n,i=[],r=-1,o=[],a=!1;return e.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=e.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||p(n.children,e,r,h,t.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,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&p(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+l("",t)},"")}},U=function(e){function t(){return P(this,t),A(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return R(t,e),C(t,[{key:"render",value:function(){var e=E({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.i18n,a=e.t,s=N(e,["children","count","parent","i18nKey","i18n","t"]),c=void 0!==i?i:o.options.react.defaultTransParent,p=d("",t,0),u=o.options.react&&o.options.react.hashTransKey,l=r||(u?u(p):p),f=l?a(l,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:p,count:n}):p;if(o.options.react&&o.options.react.exposeNamespace){var h="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(h=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:h}))}return c?g.createElement(c,s,y(t,f,o)):t}}]),t}(g.Component);U.propTypes={count:n.number,parent:n.node,i18nKey:n.string,i18n:n.object,t:n.func},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(e){function n(e,t){P(this,n);var i=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return R(n,e),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=c,e.I18n=K,e.Interpolate=$,e.Trans=U,e.I18nextProvider=G,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=m(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=M,e.setDefaults=i,e.getDefaults=r,e.setI18n=o,e.getI18n=a,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e){q=E({},q,e)}function r(){return q}function o(e){W=e}function a(){return W}function s(e){return e.displayName||e.name||"Component"}function c(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(t){function n(t,o){P(this,n);var s=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,o));s.i18n=o.i18n||t.i18n||i.i18n||a(),"string"==typeof(e=e||s.i18n.options.defaultNS)&&(e=[e]);var c=s.i18n&&s.i18n.options.react||{};return s.options=E({},r(),c,i),s.getWrappedInstance=s.getWrappedInstance.bind(s),s}return R(n,t),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 t=this,n={};return this.options.withRef&&(n.ref=function(e){t.wrappedInstance=e}),g.createElement(K,E({ns:e},this.options,this.props,{i18n:this.i18n}),function(e,i){return g.createElement(o,E({},t.props,n,i))})}}]),n}(t.Component);return c.WrappedComponent=o,c.contextTypes={i18n:n.object},c.displayName="Translate("+s(o)+")",c.namespaces=e,T(c,o)}}function p(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function u(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function l(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?u(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(l,"")+"</"+t.name+">"}}function f(e){return e&&(e.children||e.props&&e.props.children)}function h(e){return e&&e.children?e.children:e.props&&e.props.children}function d(e,t,n){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(f(t))e=e+"<"+i+">"+d("",h(t),n+1)+"</"+i+">";else if(g.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":_(t))){var r=E({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e}function y(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)t.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),t.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":_(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return h(i([{dummy:!0,children:e}],B.parse("<0>"+t+"</0>"))[0])}function v(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===_(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=L(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function m(e){var t=[];return v(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var g="default"in t?t.default:t;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},j=Object.defineProperty,x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,O=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,k=I&&I(Object),T=function e(t,n,i){if("string"!=typeof n){if(k){var r=I(n);r&&r!==k&&e(t,r,i)}var o=x(n);w&&(o=o.concat(w(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=O(n,s);try{j(t,s,c)}catch(e){}}}return t}return t},_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),C=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},R=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},N=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},A=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},L=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(e){i(e.options.react),o(e)}},D=!1,K=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=n.i18n||e.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||{};i.options=E({},r(),o,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options.isInitialSSR&&(i.options.wait=!1);var s=i.i18n.languages&&i.i18n.languages[0],c=!!s&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(s,e)});return i.state={i18nLoadedAt:null,ready:c},i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return R(t,e),C(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentWillMount",value:function(){this.t=this.getI18nTranslate()}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.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 e=this,t=this.props.children;return!this.state.ready&&this.options.wait?null:(this.i18n.options.isInitialSSR&&!D&&(D=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t}))}}]),t}(t.Component);K.contextTypes={i18n:n.object},K.childContextTypes={t:n.func.isRequired,i18n:n.object},c.setDefaults=i,c.setI18n=o;var $=function(e){function t(e,n){P(this,t);var i=A(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return R(t,e),C(t,[{key:"render",value:function(){var e=this,t=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(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?g.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},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,[t,f].concat(u))}}]),t}(t.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(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(H,function(o){if("="===o)return i=!0,void n++;i?0===n?((z[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},F=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,J=Object.create?Object.create(null):{},B={parse:function(e,t){t||(t={}),t.components||(t.components=J);var n,i=[],r=-1,o=[],a=!1;return e.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=e.charAt(h);l&&!f&&(r++,"tag"===(n=V(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||p(n.children,e,r,h,t.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,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&p(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+l("",t)},"")}},U=function(e){function t(){return P(this,t),A(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return R(t,e),C(t,[{key:"render",value:function(){var e=E({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.i18n,a=e.t,s=N(e,["children","count","parent","i18nKey","i18n","t"]),c=o.options&&o.options.react||{},p=void 0!==i?i:c.defaultTransParent,u=d("",t,0),l=c.hashTransKey,f=r||(l?l(u):u),h=f?a(f,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:u,count:n}):u;if(c.exposeNamespace){var v="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(v=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:v}))}return p?g.createElement(p,s,y(t,h,o)):t}}]),t}(g.Component);U.propTypes={count:n.number,parent:n.node,i18nKey:n.string,i18n:n.object,t:n.func},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(e){function n(e,t){P(this,n);var i=A(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return R(n,e),C(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);G.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},G.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=c,e.I18n=K,e.Interpolate=$,e.Trans=U,e.I18nextProvider=G,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=m(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=M,e.setDefaults=i,e.getDefaults=r,e.setI18n=o,e.getI18n=a,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -101,10 +101,11 @@ import React from 'react'; | ||
const useAsParent = parent !== undefined ? parent : i18n.options.react.defaultTransParent; | ||
const reactI18nextOptions = (i18n.options && i18n.options.react) || {}; | ||
const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; | ||
const defaultValue = nodesToString('', children, 0); | ||
const hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
const hashTransKey = reactI18nextOptions.hashTransKey; | ||
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
const translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue, count }) : defaultValue; | ||
if (i18n.options.react && i18n.options.react.exposeNamespace) { | ||
if (reactI18nextOptions.exposeNamespace) { | ||
let ns = typeof t.ns === 'string' ? t.ns : t.ns[0]; | ||
@@ -111,0 +112,0 @@ if (i18nKey && i18n.options.nsSeparator && i18nKey.indexOf(i18n.options.nsSeparator) > -1) { |
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
260514
4892
37