react-i18next
Advanced tools
Comparing version 6.1.0 to 6.2.0
@@ -0,1 +1,4 @@ | ||
### 6.2.0 | ||
- adds hashTransKey function for custom key generation in case of not passing a key to Trans component and not like having the source value as key | ||
### 6.1.0 | ||
@@ -2,0 +5,0 @@ - pre-check namespaces to avoid unnecessary initial `null` render [PR336](https://github.com/i18next/react-i18next/pull/336) |
@@ -1013,4 +1013,5 @@ define(['exports', 'react', 'prop-types'], function (exports, React, PropTypes) { 'use strict'; | ||
var defaultValue = nodesToString('', children, 0); | ||
var key = i18nKey || defaultValue; | ||
var translation = t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
@@ -1017,0 +1018,0 @@ if (i18n.options.react && i18n.options.react.exposeNamespace) { |
@@ -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){T(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,k(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":P(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),e.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":P(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"===P(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},O=Object.defineProperty,j=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,w=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,_=I&&I(Object),k=function t(e,n,i){if("string"!=typeof n){if(_){var r=I(n);r&&r!==_&&t(e,r,i)}var o=j(n);x&&(o=o.concat(x(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=w(n,s);try{O(e,s,c)}catch(t){}}}return e}return e},P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},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){T(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){T(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 T(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=d("",e,0),p=a(r||c,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:c,count:n});if(o.options.react&&o.options.react.exposeNamespace){var u="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(u=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:u}))}return g.createElement(i,s,y(e,p,o))}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.string,i18nKey:n.string,i18n:n.object,t:n.func},U.defaultProps={parent:"div"},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){T(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){T(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,k(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":P(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),e.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":P(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"===P(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},O=Object.defineProperty,j=Object.getOwnPropertyNames,x=Object.getOwnPropertySymbols,w=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,_=I&&I(Object),k=function t(e,n,i){if("string"!=typeof n){if(_){var r=I(n);r&&r!==_&&t(e,r,i)}var o=j(n);x&&(o=o.concat(x(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=w(n,s);try{O(e,s,c)}catch(t){}}}return e}return e},P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},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){T(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){T(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 T(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=d("",e,0),p=o.options.react&&o.options.react.hashTransKey,u=r||(p?p(c):c),l=u?a(u,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:c,count:n}):c;if(o.options.react&&o.options.react.exposeNamespace){var f="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(f=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:f}))}return g.createElement(i,s,y(e,l,o))}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.string,i18nKey:n.string,i18n:n.object,t:n.func},U.defaultProps={parent:"div"},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){T(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})}); |
@@ -13,2 +13,4 @@ 'use strict'; | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
@@ -15,0 +17,0 @@ |
@@ -138,4 +138,5 @@ 'use strict'; | ||
var defaultValue = nodesToString('', children, 0); | ||
var key = i18nKey || defaultValue; | ||
var translation = t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
@@ -142,0 +143,0 @@ if (i18n.options.react && i18n.options.react.exposeNamespace) { |
@@ -11,3 +11,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import { Component } from 'react'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -14,0 +14,0 @@ import { getDefaults, getI18n } from './context'; |
@@ -122,4 +122,5 @@ 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 defaultValue = nodesToString('', children, 0); | ||
var key = i18nKey || defaultValue; | ||
var translation = t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
@@ -126,0 +127,0 @@ if (i18n.options.react && i18n.options.react.exposeNamespace) { |
@@ -1017,4 +1017,5 @@ (function (global, factory) { | ||
var defaultValue = nodesToString('', children, 0); | ||
var key = i18nKey || defaultValue; | ||
var translation = t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
@@ -1021,0 +1022,0 @@ if (i18n.options.react && i18n.options.react.exposeNamespace) { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){q=E({},q,t)}function r(){return q}function o(t){W=t}function a(){return W}function s(t){return t.displayName||t.name||"Component"}function c(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(e){function n(e,o){T(this,n);var s=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,P(c,o)}}function p(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":k(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),e.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":k(a))||s)e.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(p)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],B.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===k(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=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},O=Object.defineProperty,x=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,w=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,_=I&&I(Object),P=function t(e,n,i){if("string"!=typeof n){if(_){var r=I(n);r&&r!==_&&t(e,r,i)}var o=x(n);j&&(o=o.concat(j(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=w(n,s);try{O(e,s,c)}catch(t){}}}return e}return e},k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},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")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){T(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){T(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 T(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=d("",e,0),p=a(r||c,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:c,count:n});if(o.options.react&&o.options.react.exposeNamespace){var u="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(u=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:u}))}return g.createElement(i,s,y(e,p,o))}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.string,i18nKey:n.string,i18n:n.object,t:n.func},U.defaultProps={parent:"div"},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){T(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=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){q=E({},q,t)}function r(){return q}function o(t){W=t}function a(){return W}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){k(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,P(c,o)}}function p(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":T(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var 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},O=Object.defineProperty,x=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,w=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,_=I&&I(Object),P=function t(e,n,i){if("string"!=typeof n){if(_){var r=I(n);r&&r!==_&&t(e,r,i)}var o=x(n);j&&(o=o.concat(j(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=w(n,s);try{O(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},k=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},N=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},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")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){k(this,e);var i=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){k(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 k(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=d("",e,0),p=o.options.react&&o.options.react.hashTransKey,u=r||(p?p(c):c),l=u?a(u,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:c,count:n}):c;if(o.options.react&&o.options.react.exposeNamespace){var f="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(f=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:f}))}return g.createElement(i,s,y(e,l,o))}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.string,i18nKey:n.string,i18n:n.object,t:n.func},U.defaultProps={parent:"div"},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){k(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=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "react-i18next", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js", |
@@ -1017,4 +1017,5 @@ (function (global, factory) { | ||
var defaultValue = nodesToString('', children, 0); | ||
var key = i18nKey || defaultValue; | ||
var translation = t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }); | ||
var hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count }) : defaultValue; | ||
@@ -1021,0 +1022,0 @@ if (i18n.options.react && i18n.options.react.exposeNamespace) { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){q=E({},q,t)}function r(){return q}function o(t){W=t}function a(){return W}function s(t){return t.displayName||t.name||"Component"}function c(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var c=function(e){function n(e,o){T(this,n);var s=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,P(c,o)}}function p(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":k(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var c=i(h(a),r.children);a.dummy&&(a.children=c),e.push(g.cloneElement(a,E({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":k(a))||s)e.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(p)}}else"text"===r.type&&e.push(r.content);return e},[])}return h(i([{dummy:!0,children:t}],B.parse("<0>"+e+"</0>"))[0])}function v(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===k(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=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},O=Object.defineProperty,x=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,w=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,_=I&&I(Object),P=function t(e,n,i){if("string"!=typeof n){if(_){var r=I(n);r&&r!==_&&t(e,r,i)}var o=x(n);j&&(o=o.concat(j(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=w(n,s);try{O(e,s,c)}catch(t){}}}return e}return e},k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},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")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){T(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){T(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 T(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=d("",e,0),p=a(r||c,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:c,count:n});if(o.options.react&&o.options.react.exposeNamespace){var u="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(u=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:u}))}return g.createElement(i,s,y(e,p,o))}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.string,i18nKey:n.string,i18n:n.object,t:n.func},U.defaultProps={parent:"div"},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){T(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=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],e):e(t.reactI18next={},t.React,t.PropTypes)}(this,function(t,e,n){"use strict";function i(t){q=E({},q,t)}function r(){return q}function o(t){W=t}function a(){return W}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){k(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,P(c,o)}}function p(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function u(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function l(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?u(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(l,"")+"</"+e.name+">"}}function f(t){return t&&(t.children||t.props&&t.props.children)}function h(t){return t&&t.children?t.children:t.props&&t.props.children}function d(t,e,n){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(f(e))t=t+"<"+i+">"+d("",h(e),n+1)+"</"+i+">";else if(g.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":T(e))){var r=E({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length&&(t=t+"<"+i+">{{"+a[0]+"}}</"+i+">")}}),t}function y(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=g.isValidElement(a);if("string"==typeof a)e.push(a);else if(f(a)){var 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},O=Object.defineProperty,x=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols,w=Object.getOwnPropertyDescriptor,I=Object.getPrototypeOf,_=I&&I(Object),P=function t(e,n,i){if("string"!=typeof n){if(_){var r=I(n);r&&r!==_&&t(e,r,i)}var o=x(n);j&&(o=o.concat(j(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(b[s]||S[s]||i&&i[s])){var c=w(n,s);try{O(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},k=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),C=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},R=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},N=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},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")}}(),q={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default"},W=void 0,M={type:"3rdParty",init:function(t){i(t.options.react),o(t)}},D=!1,K=function(t){function e(t,n){k(this,e);var i=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){k(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 k(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=d("",e,0),p=o.options.react&&o.options.react.hashTransKey,u=r||(p?p(c):c),l=u?a(u,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:c,count:n}):c;if(o.options.react&&o.options.react.exposeNamespace){var f="string"==typeof a.ns?a.ns:a.ns[0];r&&o.options.nsSeparator&&r.indexOf(o.options.nsSeparator)>-1&&(f=r.split(o.options.nsSeparator)[0]),a.ns&&(s["data-i18next-options"]=JSON.stringify({ns:f}))}return g.createElement(i,s,y(e,l,o))}}]),e}(g.Component);U.propTypes={count:n.number,parent:n.string,i18nKey:n.string,i18n:n.object,t:n.func},U.defaultProps={parent:"div"},U.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var G=function(t){function n(t,e){k(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=M,t.setDefaults=i,t.getDefaults=r,t.setI18n=o,t.getI18n=a,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -1,2 +0,2 @@ | ||
import { Component } from 'react'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -3,0 +3,0 @@ import { getDefaults, getI18n } from './context'; |
@@ -97,4 +97,5 @@ import React from 'react'; | ||
const defaultValue = nodesToString('', children, 0); | ||
const key = i18nKey || defaultValue; | ||
const translation = t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue, count }); | ||
const hashTransKey = i18n.options.react && i18n.options.react.hashTransKey; | ||
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
const translation = key ? t(key, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue, count }) : defaultValue; | ||
@@ -101,0 +102,0 @@ if (i18n.options.react && i18n.options.react.exposeNamespace) { |
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
252669
4839