react-i18next
Advanced tools
Comparing version 7.6.1 to 7.7.0
@@ -0,1 +1,4 @@ | ||
### 7.7.0 | ||
- Allow Trans component to be used with props only for icu use case (next step babel makro) [439](https://github.com/i18next/react-i18next/issues/439) | ||
### 7.6.1 | ||
@@ -2,0 +5,0 @@ - Allow to pass a function as parent for <Trans /> component [PR424](https://github.com/i18next/react-i18next/pull/424) |
@@ -1093,6 +1093,9 @@ define(['exports', 'react', 'prop-types'], function (exports, React, PropTypes) { 'use strict'; | ||
tOptions = contextAndProps.tOptions, | ||
values = contextAndProps.values, | ||
defaults$$1 = contextAndProps.defaults, | ||
components = contextAndProps.components, | ||
namespace = contextAndProps.ns, | ||
i18n = contextAndProps.i18n, | ||
tFromContextAndProps = contextAndProps.t, | ||
additionalProps = objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'ns', 'i18n', 't']); | ||
additionalProps = objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'values', 'defaults', 'components', 'ns', 'i18n', 't']); | ||
@@ -1104,6 +1107,7 @@ var t = tFromContextAndProps || i18n.t.bind(i18n); | ||
var defaultValue = nodesToString('', children, 0); | ||
var defaultValue = defaults$$1 || nodesToString('', children, 0); | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, _extends({}, tOptions, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
var interpolationOverride = values ? {} : { interpolation: { prefix: '#$?', suffix: '?$#' } }; | ||
var translation = key ? t(key, _extends({}, tOptions, values, interpolationOverride, { defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
@@ -1119,5 +1123,5 @@ if (reactI18nextOptions.exposeNamespace) { | ||
if (!useAsParent) return renderNodes(children, translation, i18n); | ||
if (!useAsParent) return renderNodes(components || children, translation, i18n); | ||
return React__default.createElement(useAsParent, additionalProps, renderNodes(children, translation, i18n)); | ||
return React__default.createElement(useAsParent, additionalProps, renderNodes(components || children, translation, i18n)); | ||
} | ||
@@ -1124,0 +1128,0 @@ }]); |
@@ -1,1 +0,1 @@ | ||
define(["exports","react","prop-types"],function(e,t,n){"use strict";var i="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a=Object.defineProperty,s=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,u=Object.getPrototypeOf,l=u&&u(Object),f=function e(t,n,i){if("string"!=typeof n){if(l){var f=u(n);f&&f!==l&&e(t,f,i)}var h=s(n);c&&(h=h.concat(c(n)));for(var d=0;d<h.length;++d){var y=h[d];if(!(r[y]||o[y]||i&&i[y])){var v=p(n,y);try{a(t,y,v)}catch(e){}}}return t}return t},h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=(function(){function e(e){this.value=e}function t(t){var n,i;function r(n,i){try{var a=t[n](i),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){r("next",e)},function(e){r("throw",e)}):o(a.done?"return":"normal",a.value)}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?r(n.key,n.arg):i=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};i?i=i.next=s:(n=i=s,r(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),y=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},g=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},b=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},O=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),j=Object.prototype.hasOwnProperty;function S(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}var w={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1},x=void 0;function I(e){w=v({},w,e)}function k(){return w}function P(e){x=e}function T(){return x}var _={type:"3rdParty",init:function(e){I(e.options.react),P(e)}},C=!1,E=function(e){m(t,e);function t(e,n){d(this,t);var i=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=e.i18n||n.i18n||T(),i.namespaces=e.ns||i.i18n.options&&i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var r=i.i18n&&i.i18n.options&&i.i18n.options.react||{};i.options=v({},k(),r,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options&&i.i18n.options.isInitialSSR&&(i.options.wait=!1);var o=i.i18n.languages&&i.i18n.languages[0],a=!!o&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(o,e)});return i.state={i18nLoadedAt:null,ready:a},i.t=i.getI18nTranslate(),i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return y(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n){this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(this.options.bindStore){this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var e=this,t=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!C&&(C=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),t}(t.Component);E.contextTypes={i18n:n.object},E.childContextTypes={t:n.func.isRequired,i18n:n.object};function R(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var a=function(t){m(n,t);function n(t,i){d(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,i));o.i18n=t.i18n||r.i18n||i.i18n||T(),o.namespaces="function"==typeof e?e(t):e||o.i18n.options&&o.i18n.options.defaultNS,"string"==typeof o.namespaces&&(o.namespaces=[o.namespaces]);var a=o.i18n&&o.i18n.options&&o.i18n.options.react||{};return o.options=v({},k(),a,r),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return y(n,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!function(e,t){if(S(e,t))return!0;if("object"!==(void 0===e?"undefined":h(e))||null===e||"object"!==(void 0===t?"undefined":h(t))||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!j.call(t,n[r])||!S(e[n[r]],t[n[r]]))return!1;return!0}(this.props,e)}},{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,t={};return this.options.withRef&&(t.ref=function(t){e.wrappedInstance=t}),i.createElement(E,v({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,r){var a=r.ready,s=g(r,["ready"]);return i.createElement(o,v({tReady:a},e.props,t,s))})}}]),n}(t.Component);a.WrappedComponent=o,a.contextTypes={i18n:n.object},a.displayName="Translate("+(s=o,s.displayName||s.name||"Component")+")";var s;return a.namespaces=e,f(a,o)}}R.setDefaults=I,R.setI18n=P;var N=function(e){m(t,e);function t(e,n){d(this,t);var i=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return y(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props,o=r.className,a=r.style,s=this.props.useDangerouslySetInnerHTML||!1,c=this.props.dangerouslySetInnerHTMLPartElement||"span",p=v({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return i.createElement("noscript",null);var l=[];u.split(n).reduce(function(t,n,r){var o=void 0;if(r%2==0){if(0===n.length)return t;o=s?i.createElement(c,{dangerouslySetInnerHTML:{__html:n}}):n}else o=function(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+u),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)}(n,e.props);return t.push(o),t},l);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];if(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 o&&(f.className=o),a&&(f.style=a),i.createElement.apply(this,[t,f].concat(l))}}]),t}(t.Component);N.propTypes={className:n.string},N.defaultProps={className:""},N.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var A={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},L=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,W=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,D=Object.create?Object.create(null):{};function K(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function M(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(M,"")+"</"+t.name+">"}}var q={parse:function(e,t){t||(t={}),t.components||(t.components=D);var n,i=[],r=-1,o=[],a=!1;return e.replace(W,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),l=0===s.indexOf("\x3c!--"),f=c+s.length,h=e.charAt(f);u&&!l&&(r++,"tag"===(n=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(L,function(o){if("="===o)return i=!0,void n++;i?0===n?((A[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r}(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!h||"<"===h||K(n.children,e,r,f,t.ignoreWhitespace),0===r&&i.push(n),(p=o[r-1])&&p.children.push(n),o[r]=n),(l||!u||n.voidElement)&&(l||r--,!a&&"<"!==h&&h&&K(p=-1===r?i:o[r].children,e,r,f,t.ignoreWhitespace))}),!i.length&&e.length&&K(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+M("",t)},"")}};function $(e){return e&&(e.children||e.props&&e.props.children)}function z(e){return e&&e.children?e.children:e.props&&e.props.children}function H(e,t,n){if(""===t)return[];if(!e)return[t];return z(function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce(function(r,o,a){if("tag"===o.type){var s=t[parseInt(o.name,10)]||{},c=i.isValidElement(s);if("string"==typeof s)r.push(s);else if($(s)){var p=e(z(s),o.children);s.dummy&&(s.children=p),r.push(i.cloneElement(s,v({},s.props,{key:a}),p))}else if("object"!==(void 0===s?"undefined":h(s))||c)r.push(s);else{var u=n.services.interpolator.interpolate(o.children[0].content,s,n.language);r.push(u)}}else"text"===o.type&&r.push(o.content);return r},[])}([{dummy:!0,children:e}],q.parse("<0>"+t+"</0>"))[0])}var V=function(e){m(t,e);function t(){return d(this,t),b(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return y(t,[{key:"render",value:function(){var e=v({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,r=e.parent,o=e.i18nKey,a=e.tOptions,s=e.ns,c=e.i18n,p=e.t,u=g(e,["children","count","parent","i18nKey","tOptions","ns","i18n","t"]),l=p||c.t.bind(c),f=c.options&&c.options.react||{},d=void 0!==r?r:f.defaultTransParent,y=function e(t,n,r){return n?("[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),n.forEach(function(n,r){var o=""+r;if("string"==typeof n)t=""+t+n;else if($(n))t=t+"<"+o+">"+e("",z(n),r+1)+"</"+o+">";else if(i.isValidElement(n))t=t+"<"+o+"></"+o+">";else if("object"===(void 0===n?"undefined":h(n))){var a=v({},n),s=a.format;delete a.format;var c=Object.keys(a);s&&1===c.length?t=t+"<"+o+">{{"+c[0]+", "+s+"}}</"+o+">":1===c.length?t=t+"<"+o+">{{"+c[0]+"}}</"+o+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",n)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",n)}),t):""}("",t),m=f.hashTransKey,b=o||(m?m(y):y),O=b?l(b,v({},a,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:y,count:n,ns:s})):y;if(f.exposeNamespace){var j="string"==typeof l.ns?l.ns:l.ns[0];if(o&&c.options&&c.options.nsSeparator&&o.indexOf(c.options.nsSeparator)>-1){j=o.split(c.options.nsSeparator)[0]}l.ns&&(u["data-i18next-options"]=JSON.stringify({ns:j}))}return d?i.createElement(d,u,H(t,O,c)):H(t,O,c)}}]),t}(i.Component);V.propTypes={count:n.number,parent:n.oneOfType([n.node,n.func]),i18nKey:n.string,i18n:n.object,t:n.func},V.contextTypes={i18n:n.object.isRequired,t:n.func};var F=function(e){m(n,e);function n(e,t){d(this,n);var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);F.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},F.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i});function J(e){var t=[];return function(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===h(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=O(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}e.translate=R,e.I18n=E,e.Interpolate=N,e.Trans=V,e.I18nextProvider=F,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=J(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=_,e.setDefaults=I,e.getDefaults=k,e.setI18n=P,e.getI18n=T,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
define(["exports","react","prop-types"],function(e,t,n){"use strict";function i(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function r(e,t){if(i(e,t))return!0;if("object"!==(void 0===e?"undefined":C(e))||null===e||"object"!==(void 0===t?"undefined":C(t))||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!K.call(t,n[o])||!i(e[n[o]],t[n[o]]))return!1;return!0}function o(e){M=N({},M,e)}function a(){return M}function s(e){q=e}function c(){return q}function p(e){return e.displayName||e.name||"Component"}function u(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var s=function(t){function n(t,r){E(this,n);var o=W(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r));o.i18n=t.i18n||i.i18n||r.i18n||c(),o.namespaces="function"==typeof e?e(t):e||o.i18n.options&&o.i18n.options.defaultNS,"string"==typeof o.namespaces&&(o.namespaces=[o.namespaces]);var s=o.i18n&&o.i18n.options&&o.i18n.options.react||{};return o.options=N({},a(),s,i),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return A(n,t),R(n,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!r(this.props,e)}},{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,t={};return this.options.withRef&&(t.ref=function(t){e.wrappedInstance=t}),O.createElement(H,N({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,i){var r=i.ready,a=L(i,["ready"]);return O.createElement(o,N({tReady:r},e.props,t,a))})}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object},s.displayName="Translate("+p(o)+")",s.namespaces=e,_(s,o)}}function l(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function h(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?f(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(h,"")+"</"+t.name+">"}}function d(e){return e&&(e.children||e.props&&e.props.children)}function y(e){return e&&e.children?e.children:e.props&&e.props.children}function v(e,t,n){return t?("[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(d(t))e=e+"<"+i+">"+v("",y(t),n+1)+"</"+i+">";else if(O.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":C(t))){var r=N({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e):""}function m(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=O.isValidElement(a);if("string"==typeof a)t.push(a);else if(d(a)){var c=i(y(a),r.children);a.dummy&&(a.children=c),t.push(O.cloneElement(a,N({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":C(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return""===t?[]:e?y(i([{dummy:!0,children:e}],Q.parse("<0>"+t+"</0>"))[0]):[t]}function g(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===C(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=D(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function b(e){var t=[];return g(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var O="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var j={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},w=Object.defineProperty,x=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,k=Object.getOwnPropertyDescriptor,P=Object.getPrototypeOf,T=P&&P(Object),_=function e(t,n,i){if("string"!=typeof n){if(T){var r=P(n);r&&r!==T&&e(t,r,i)}var o=x(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(j[s]||S[s]||i&&i[s])){var c=k(n,s);try{w(t,s,c)}catch(e){}}}return t}return t},C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),R=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),N=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},A=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},L=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},W=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},D=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),K=Object.prototype.hasOwnProperty,M={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1},q=void 0,$={type:"3rdParty",init:function(e){o(e.options.react),s(e)}},z=!1,H=function(e){function t(e,n){E(this,t);var i=W(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=e.i18n||n.i18n||c(),i.namespaces=e.ns||i.i18n.options&&i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var r=i.i18n&&i.i18n.options&&i.i18n.options.react||{};i.options=N({},a(),r,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options&&i.i18n.options.isInitialSSR&&(i.options.wait=!1);var o=i.i18n.languages&&i.i18n.languages[0],s=!!o&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(o,e)});return i.state={i18nLoadedAt:null,ready:s},i.t=i.getI18nTranslate(),i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return A(t,e),R(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var e=this,t=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!z&&(z=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),t}(t.Component);H.contextTypes={i18n:n.object},H.childContextTypes={t:n.func.isRequired,i18n:n.object},u.setDefaults=o,u.setI18n=s;var V=function(e){function t(e,n){E(this,t);var i=W(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return A(t,e),R(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",c=N({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,c);if(!p||"string"!=typeof p)return O.createElement("noscript",null);var u=[],l=function(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?O.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),O.createElement.apply(this,[t,f].concat(u))}}]),t}(t.Component);V.propTypes={className:n.string},V.defaultProps={className:""},V.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var F={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},J=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,U=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(J,function(o){if("="===o)return i=!0,void n++;i?0===n?((F[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},B=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,G=Object.create?Object.create(null):{},Q={parse:function(e,t){t||(t={}),t.components||(t.components=G);var n,i=[],r=-1,o=[],a=!1;return e.replace(B,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=c+s.length,d=e.charAt(h);u&&!f&&(r++,"tag"===(n=U(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||l(n.children,e,r,h,t.ignoreWhitespace),0===r&&i.push(n),(p=o[r-1])&&p.children.push(n),o[r]=n),(f||!u||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&l(p=-1===r?i:o[r].children,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&l(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+h("",t)},"")}},X=function(e){function t(){return E(this,t),W(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return A(t,e),R(t,[{key:"render",value:function(){var e=N({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.tOptions,a=e.values,s=e.defaults,c=e.components,p=e.ns,u=e.i18n,l=e.t,f=L(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),h=l||u.t.bind(u),d=u.options&&u.options.react||{},y=void 0!==i?i:d.defaultTransParent,g=s||v("",t,0),b=d.hashTransKey,j=r||(b?b(g):g),S=j?h(j,N({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:g,count:n,ns:p})):g;if(d.exposeNamespace){var w="string"==typeof h.ns?h.ns:h.ns[0];r&&u.options&&u.options.nsSeparator&&r.indexOf(u.options.nsSeparator)>-1&&(w=r.split(u.options.nsSeparator)[0]),h.ns&&(f["data-i18next-options"]=JSON.stringify({ns:w}))}return y?O.createElement(y,f,m(c||t,S,u)):m(c||t,S,u)}}]),t}(O.Component);X.propTypes={count:n.number,parent:n.oneOfType([n.node,n.func]),i18nKey:n.string,i18n:n.object,t:n.func},X.contextTypes={i18n:n.object.isRequired,t:n.func};var Y=function(e){function n(e,t){E(this,n);var i=W(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return A(n,e),R(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);Y.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},Y.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=u,e.I18n=H,e.Interpolate=V,e.Trans=X,e.I18nextProvider=Y,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=b(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=$,e.setDefaults=o,e.getDefaults=a,e.setI18n=s,e.getI18n=c,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -142,6 +142,9 @@ 'use strict'; | ||
tOptions = contextAndProps.tOptions, | ||
values = contextAndProps.values, | ||
defaults = contextAndProps.defaults, | ||
components = contextAndProps.components, | ||
namespace = contextAndProps.ns, | ||
i18n = contextAndProps.i18n, | ||
tFromContextAndProps = contextAndProps.t, | ||
additionalProps = _objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'ns', 'i18n', 't']); | ||
additionalProps = _objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'values', 'defaults', 'components', 'ns', 'i18n', 't']); | ||
@@ -153,6 +156,7 @@ var t = tFromContextAndProps || i18n.t.bind(i18n); | ||
var defaultValue = nodesToString('', children, 0); | ||
var defaultValue = defaults || nodesToString('', children, 0); | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, _extends({}, tOptions, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
var interpolationOverride = values ? {} : { interpolation: { prefix: '#$?', suffix: '?$#' } }; | ||
var translation = key ? t(key, _extends({}, tOptions, values, interpolationOverride, { defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
@@ -168,5 +172,5 @@ if (reactI18nextOptions.exposeNamespace) { | ||
if (!useAsParent) return renderNodes(children, translation, i18n); | ||
if (!useAsParent) return renderNodes(components || children, translation, i18n); | ||
return _react2.default.createElement(useAsParent, additionalProps, renderNodes(children, translation, i18n)); | ||
return _react2.default.createElement(useAsParent, additionalProps, renderNodes(components || children, translation, i18n)); | ||
} | ||
@@ -173,0 +177,0 @@ }]); |
@@ -126,6 +126,9 @@ 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; }; }(); | ||
tOptions = contextAndProps.tOptions, | ||
values = contextAndProps.values, | ||
defaults = contextAndProps.defaults, | ||
components = contextAndProps.components, | ||
namespace = contextAndProps.ns, | ||
i18n = contextAndProps.i18n, | ||
tFromContextAndProps = contextAndProps.t, | ||
additionalProps = _objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'ns', 'i18n', 't']); | ||
additionalProps = _objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'values', 'defaults', 'components', 'ns', 'i18n', 't']); | ||
@@ -137,6 +140,7 @@ var t = tFromContextAndProps || i18n.t.bind(i18n); | ||
var defaultValue = nodesToString('', children, 0); | ||
var defaultValue = defaults || nodesToString('', children, 0); | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, _extends({}, tOptions, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
var interpolationOverride = values ? {} : { interpolation: { prefix: '#$?', suffix: '?$#' } }; | ||
var translation = key ? t(key, _extends({}, tOptions, values, interpolationOverride, { defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
@@ -152,5 +156,5 @@ if (reactI18nextOptions.exposeNamespace) { | ||
if (!useAsParent) return renderNodes(children, translation, i18n); | ||
if (!useAsParent) return renderNodes(components || children, translation, i18n); | ||
return React.createElement(useAsParent, additionalProps, renderNodes(children, translation, i18n)); | ||
return React.createElement(useAsParent, additionalProps, renderNodes(components || children, translation, i18n)); | ||
} | ||
@@ -157,0 +161,0 @@ }]); |
@@ -1097,6 +1097,9 @@ (function (global, factory) { | ||
tOptions = contextAndProps.tOptions, | ||
values = contextAndProps.values, | ||
defaults$$1 = contextAndProps.defaults, | ||
components = contextAndProps.components, | ||
namespace = contextAndProps.ns, | ||
i18n = contextAndProps.i18n, | ||
tFromContextAndProps = contextAndProps.t, | ||
additionalProps = objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'ns', 'i18n', 't']); | ||
additionalProps = objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'values', 'defaults', 'components', 'ns', 'i18n', 't']); | ||
@@ -1108,6 +1111,7 @@ var t = tFromContextAndProps || i18n.t.bind(i18n); | ||
var defaultValue = nodesToString('', children, 0); | ||
var defaultValue = defaults$$1 || nodesToString('', children, 0); | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, _extends({}, tOptions, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
var interpolationOverride = values ? {} : { interpolation: { prefix: '#$?', suffix: '?$#' } }; | ||
var translation = key ? t(key, _extends({}, tOptions, values, interpolationOverride, { defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
@@ -1123,5 +1127,5 @@ if (reactI18nextOptions.exposeNamespace) { | ||
if (!useAsParent) return renderNodes(children, translation, i18n); | ||
if (!useAsParent) return renderNodes(components || children, translation, i18n); | ||
return React__default.createElement(useAsParent, additionalProps, renderNodes(children, translation, i18n)); | ||
return React__default.createElement(useAsParent, additionalProps, renderNodes(components || children, translation, i18n)); | ||
} | ||
@@ -1128,0 +1132,0 @@ }]); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";var i="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a=Object.defineProperty,s=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,u=Object.getPrototypeOf,l=u&&u(Object),f=function e(t,n,i){if("string"!=typeof n){if(l){var f=u(n);f&&f!==l&&e(t,f,i)}var h=s(n);c&&(h=h.concat(c(n)));for(var d=0;d<h.length;++d){var y=h[d];if(!(r[y]||o[y]||i&&i[y])){var v=p(n,y);try{a(t,y,v)}catch(e){}}}return t}return t},h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=(function(){function e(e){this.value=e}function t(t){var n,i;function r(n,i){try{var a=t[n](i),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){r("next",e)},function(e){r("throw",e)}):o(a.done?"return":"normal",a.value)}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?r(n.key,n.arg):i=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};i?i=i.next=s:(n=i=s,r(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),y=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},g=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},b=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},O=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),j=Object.prototype.hasOwnProperty;function S(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}var w={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1},x=void 0;function I(e){w=v({},w,e)}function k(){return w}function P(e){x=e}function T(){return x}var _={type:"3rdParty",init:function(e){I(e.options.react),P(e)}},C=!1,E=function(e){m(t,e);function t(e,n){d(this,t);var i=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=e.i18n||n.i18n||T(),i.namespaces=e.ns||i.i18n.options&&i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var r=i.i18n&&i.i18n.options&&i.i18n.options.react||{};i.options=v({},k(),r,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options&&i.i18n.options.isInitialSSR&&(i.options.wait=!1);var o=i.i18n.languages&&i.i18n.languages[0],a=!!o&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(o,e)});return i.state={i18nLoadedAt:null,ready:a},i.t=i.getI18nTranslate(),i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return y(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n){this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(this.options.bindStore){this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var e=this,t=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!C&&(C=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),t}(t.Component);E.contextTypes={i18n:n.object},E.childContextTypes={t:n.func.isRequired,i18n:n.object};function R(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var a=function(t){m(n,t);function n(t,i){d(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,i));o.i18n=t.i18n||r.i18n||i.i18n||T(),o.namespaces="function"==typeof e?e(t):e||o.i18n.options&&o.i18n.options.defaultNS,"string"==typeof o.namespaces&&(o.namespaces=[o.namespaces]);var a=o.i18n&&o.i18n.options&&o.i18n.options.react||{};return o.options=v({},k(),a,r),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return y(n,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!function(e,t){if(S(e,t))return!0;if("object"!==(void 0===e?"undefined":h(e))||null===e||"object"!==(void 0===t?"undefined":h(t))||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!j.call(t,n[r])||!S(e[n[r]],t[n[r]]))return!1;return!0}(this.props,e)}},{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,t={};return this.options.withRef&&(t.ref=function(t){e.wrappedInstance=t}),i.createElement(E,v({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,r){var a=r.ready,s=g(r,["ready"]);return i.createElement(o,v({tReady:a},e.props,t,s))})}}]),n}(t.Component);a.WrappedComponent=o,a.contextTypes={i18n:n.object},a.displayName="Translate("+(s=o,s.displayName||s.name||"Component")+")";var s;return a.namespaces=e,f(a,o)}}R.setDefaults=I,R.setI18n=P;var N=function(e){m(t,e);function t(e,n){d(this,t);var i=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return y(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props,o=r.className,a=r.style,s=this.props.useDangerouslySetInnerHTML||!1,c=this.props.dangerouslySetInnerHTMLPartElement||"span",p=v({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return i.createElement("noscript",null);var l=[];u.split(n).reduce(function(t,n,r){var o=void 0;if(r%2==0){if(0===n.length)return t;o=s?i.createElement(c,{dangerouslySetInnerHTML:{__html:n}}):n}else o=function(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+u),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)}(n,e.props);return t.push(o),t},l);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];if(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 o&&(f.className=o),a&&(f.style=a),i.createElement.apply(this,[t,f].concat(l))}}]),t}(t.Component);N.propTypes={className:n.string},N.defaultProps={className:""},N.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var A={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},L=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,q=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,W=Object.create?Object.create(null):{};function D(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function K(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(K,"")+"</"+t.name+">"}}var M={parse:function(e,t){t||(t={}),t.components||(t.components=W);var n,i=[],r=-1,o=[],a=!1;return e.replace(q,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),l=0===s.indexOf("\x3c!--"),f=c+s.length,h=e.charAt(f);u&&!l&&(r++,"tag"===(n=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(L,function(o){if("="===o)return i=!0,void n++;i?0===n?((A[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r}(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!h||"<"===h||D(n.children,e,r,f,t.ignoreWhitespace),0===r&&i.push(n),(p=o[r-1])&&p.children.push(n),o[r]=n),(l||!u||n.voidElement)&&(l||r--,!a&&"<"!==h&&h&&D(p=-1===r?i:o[r].children,e,r,f,t.ignoreWhitespace))}),!i.length&&e.length&&D(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+K("",t)},"")}};function $(e){return e&&(e.children||e.props&&e.props.children)}function z(e){return e&&e.children?e.children:e.props&&e.props.children}function H(e,t,n){if(""===t)return[];if(!e)return[t];return z(function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce(function(r,o,a){if("tag"===o.type){var s=t[parseInt(o.name,10)]||{},c=i.isValidElement(s);if("string"==typeof s)r.push(s);else if($(s)){var p=e(z(s),o.children);s.dummy&&(s.children=p),r.push(i.cloneElement(s,v({},s.props,{key:a}),p))}else if("object"!==(void 0===s?"undefined":h(s))||c)r.push(s);else{var u=n.services.interpolator.interpolate(o.children[0].content,s,n.language);r.push(u)}}else"text"===o.type&&r.push(o.content);return r},[])}([{dummy:!0,children:e}],M.parse("<0>"+t+"</0>"))[0])}var V=function(e){m(t,e);function t(){return d(this,t),b(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return y(t,[{key:"render",value:function(){var e=v({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,r=e.parent,o=e.i18nKey,a=e.tOptions,s=e.ns,c=e.i18n,p=e.t,u=g(e,["children","count","parent","i18nKey","tOptions","ns","i18n","t"]),l=p||c.t.bind(c),f=c.options&&c.options.react||{},d=void 0!==r?r:f.defaultTransParent,y=function e(t,n,r){return n?("[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),n.forEach(function(n,r){var o=""+r;if("string"==typeof n)t=""+t+n;else if($(n))t=t+"<"+o+">"+e("",z(n),r+1)+"</"+o+">";else if(i.isValidElement(n))t=t+"<"+o+"></"+o+">";else if("object"===(void 0===n?"undefined":h(n))){var a=v({},n),s=a.format;delete a.format;var c=Object.keys(a);s&&1===c.length?t=t+"<"+o+">{{"+c[0]+", "+s+"}}</"+o+">":1===c.length?t=t+"<"+o+">{{"+c[0]+"}}</"+o+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",n)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",n)}),t):""}("",t),m=f.hashTransKey,b=o||(m?m(y):y),O=b?l(b,v({},a,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:y,count:n,ns:s})):y;if(f.exposeNamespace){var j="string"==typeof l.ns?l.ns:l.ns[0];if(o&&c.options&&c.options.nsSeparator&&o.indexOf(c.options.nsSeparator)>-1){j=o.split(c.options.nsSeparator)[0]}l.ns&&(u["data-i18next-options"]=JSON.stringify({ns:j}))}return d?i.createElement(d,u,H(t,O,c)):H(t,O,c)}}]),t}(i.Component);V.propTypes={count:n.number,parent:n.oneOfType([n.node,n.func]),i18nKey:n.string,i18n:n.object,t:n.func},V.contextTypes={i18n:n.object.isRequired,t:n.func};var F=function(e){m(n,e);function n(e,t){d(this,n);var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);F.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},F.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i});function J(e){var t=[];return function(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===h(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=O(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}e.translate=R,e.I18n=E,e.Interpolate=N,e.Trans=V,e.I18nextProvider=F,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=J(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=_,e.setDefaults=I,e.getDefaults=k,e.setI18n=P,e.getI18n=T,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function r(e,t){if(i(e,t))return!0;if("object"!==(void 0===e?"undefined":C(e))||null===e||"object"!==(void 0===t?"undefined":C(t))||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!D.call(t,n[o])||!i(e[n[o]],t[n[o]]))return!1;return!0}function o(e){K=N({},K,e)}function a(){return K}function s(e){M=e}function c(){return M}function p(e){return e.displayName||e.name||"Component"}function u(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var s=function(t){function n(t,r){E(this,n);var o=q(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r));o.i18n=t.i18n||i.i18n||r.i18n||c(),o.namespaces="function"==typeof e?e(t):e||o.i18n.options&&o.i18n.options.defaultNS,"string"==typeof o.namespaces&&(o.namespaces=[o.namespaces]);var s=o.i18n&&o.i18n.options&&o.i18n.options.react||{};return o.options=N({},a(),s,i),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return A(n,t),R(n,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!r(this.props,e)}},{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,t={};return this.options.withRef&&(t.ref=function(t){e.wrappedInstance=t}),O.createElement(H,N({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,i){var r=i.ready,a=L(i,["ready"]);return O.createElement(o,N({tReady:r},e.props,t,a))})}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object},s.displayName="Translate("+p(o)+")",s.namespaces=e,_(s,o)}}function l(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function h(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?f(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(h,"")+"</"+t.name+">"}}function d(e){return e&&(e.children||e.props&&e.props.children)}function y(e){return e&&e.children?e.children:e.props&&e.props.children}function v(e,t,n){return t?("[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(d(t))e=e+"<"+i+">"+v("",y(t),n+1)+"</"+i+">";else if(O.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":C(t))){var r=N({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e):""}function m(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=O.isValidElement(a);if("string"==typeof a)t.push(a);else if(d(a)){var c=i(y(a),r.children);a.dummy&&(a.children=c),t.push(O.cloneElement(a,N({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":C(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return""===t?[]:e?y(i([{dummy:!0,children:e}],Q.parse("<0>"+t+"</0>"))[0]):[t]}function g(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===C(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=W(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function b(e){var t=[];return g(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var O="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var j={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},w=Object.defineProperty,x=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,k=Object.getOwnPropertyDescriptor,P=Object.getPrototypeOf,T=P&&P(Object),_=function e(t,n,i){if("string"!=typeof n){if(T){var r=P(n);r&&r!==T&&e(t,r,i)}var o=x(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(j[s]||S[s]||i&&i[s])){var c=k(n,s);try{w(t,s,c)}catch(e){}}}return t}return t},C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),R=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),N=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},A=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},L=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},q=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},W=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),D=Object.prototype.hasOwnProperty,K={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1},M=void 0,$={type:"3rdParty",init:function(e){o(e.options.react),s(e)}},z=!1,H=function(e){function t(e,n){E(this,t);var i=q(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=e.i18n||n.i18n||c(),i.namespaces=e.ns||i.i18n.options&&i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var r=i.i18n&&i.i18n.options&&i.i18n.options.react||{};i.options=N({},a(),r,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options&&i.i18n.options.isInitialSSR&&(i.options.wait=!1);var o=i.i18n.languages&&i.i18n.languages[0],s=!!o&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(o,e)});return i.state={i18nLoadedAt:null,ready:s},i.t=i.getI18nTranslate(),i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return A(t,e),R(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var e=this,t=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!z&&(z=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),t}(t.Component);H.contextTypes={i18n:n.object},H.childContextTypes={t:n.func.isRequired,i18n:n.object},u.setDefaults=o,u.setI18n=s;var V=function(e){function t(e,n){E(this,t);var i=q(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return A(t,e),R(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",c=N({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,c);if(!p||"string"!=typeof p)return O.createElement("noscript",null);var u=[],l=function(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?O.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),O.createElement.apply(this,[t,f].concat(u))}}]),t}(t.Component);V.propTypes={className:n.string},V.defaultProps={className:""},V.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var F={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},J=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,U=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(J,function(o){if("="===o)return i=!0,void n++;i?0===n?((F[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},B=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,G=Object.create?Object.create(null):{},Q={parse:function(e,t){t||(t={}),t.components||(t.components=G);var n,i=[],r=-1,o=[],a=!1;return e.replace(B,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=c+s.length,d=e.charAt(h);u&&!f&&(r++,"tag"===(n=U(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||l(n.children,e,r,h,t.ignoreWhitespace),0===r&&i.push(n),(p=o[r-1])&&p.children.push(n),o[r]=n),(f||!u||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&l(p=-1===r?i:o[r].children,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&l(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+h("",t)},"")}},X=function(e){function t(){return E(this,t),q(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return A(t,e),R(t,[{key:"render",value:function(){var e=N({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.tOptions,a=e.values,s=e.defaults,c=e.components,p=e.ns,u=e.i18n,l=e.t,f=L(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),h=l||u.t.bind(u),d=u.options&&u.options.react||{},y=void 0!==i?i:d.defaultTransParent,g=s||v("",t,0),b=d.hashTransKey,j=r||(b?b(g):g),S=j?h(j,N({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:g,count:n,ns:p})):g;if(d.exposeNamespace){var w="string"==typeof h.ns?h.ns:h.ns[0];r&&u.options&&u.options.nsSeparator&&r.indexOf(u.options.nsSeparator)>-1&&(w=r.split(u.options.nsSeparator)[0]),h.ns&&(f["data-i18next-options"]=JSON.stringify({ns:w}))}return y?O.createElement(y,f,m(c||t,S,u)):m(c||t,S,u)}}]),t}(O.Component);X.propTypes={count:n.number,parent:n.oneOfType([n.node,n.func]),i18nKey:n.string,i18n:n.object,t:n.func},X.contextTypes={i18n:n.object.isRequired,t:n.func};var Y=function(e){function n(e,t){E(this,n);var i=q(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return A(n,e),R(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);Y.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},Y.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=u,e.I18n=H,e.Interpolate=V,e.Trans=X,e.I18nextProvider=Y,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=b(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=$,e.setDefaults=o,e.getDefaults=a,e.setI18n=s,e.getI18n=c,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "react-i18next", | ||
"version": "7.6.1", | ||
"version": "7.7.0", | ||
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js", |
@@ -1097,6 +1097,9 @@ (function (global, factory) { | ||
tOptions = contextAndProps.tOptions, | ||
values = contextAndProps.values, | ||
defaults$$1 = contextAndProps.defaults, | ||
components = contextAndProps.components, | ||
namespace = contextAndProps.ns, | ||
i18n = contextAndProps.i18n, | ||
tFromContextAndProps = contextAndProps.t, | ||
additionalProps = objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'ns', 'i18n', 't']); | ||
additionalProps = objectWithoutProperties(contextAndProps, ['children', 'count', 'parent', 'i18nKey', 'tOptions', 'values', 'defaults', 'components', 'ns', 'i18n', 't']); | ||
@@ -1108,6 +1111,7 @@ var t = tFromContextAndProps || i18n.t.bind(i18n); | ||
var defaultValue = nodesToString('', children, 0); | ||
var defaultValue = defaults$$1 || nodesToString('', children, 0); | ||
var hashTransKey = reactI18nextOptions.hashTransKey; | ||
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
var translation = key ? t(key, _extends({}, tOptions, { interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
var interpolationOverride = values ? {} : { interpolation: { prefix: '#$?', suffix: '?$#' } }; | ||
var translation = key ? t(key, _extends({}, tOptions, values, interpolationOverride, { defaultValue: defaultValue, count: count, ns: namespace })) : defaultValue; | ||
@@ -1123,5 +1127,5 @@ if (reactI18nextOptions.exposeNamespace) { | ||
if (!useAsParent) return renderNodes(children, translation, i18n); | ||
if (!useAsParent) return renderNodes(components || children, translation, i18n); | ||
return React__default.createElement(useAsParent, additionalProps, renderNodes(children, translation, i18n)); | ||
return React__default.createElement(useAsParent, additionalProps, renderNodes(components || children, translation, i18n)); | ||
} | ||
@@ -1128,0 +1132,0 @@ }]); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";var i="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a=Object.defineProperty,s=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,p=Object.getOwnPropertyDescriptor,u=Object.getPrototypeOf,l=u&&u(Object),f=function e(t,n,i){if("string"!=typeof n){if(l){var f=u(n);f&&f!==l&&e(t,f,i)}var h=s(n);c&&(h=h.concat(c(n)));for(var d=0;d<h.length;++d){var y=h[d];if(!(r[y]||o[y]||i&&i[y])){var v=p(n,y);try{a(t,y,v)}catch(e){}}}return t}return t},h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=(function(){function e(e){this.value=e}function t(t){var n,i;function r(n,i){try{var a=t[n](i),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){r("next",e)},function(e){r("throw",e)}):o(a.done?"return":"normal",a.value)}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?r(n.key,n.arg):i=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};i?i=i.next=s:(n=i=s,r(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),y=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},m=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},g=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},b=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},O=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),j=Object.prototype.hasOwnProperty;function S(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}var w={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1},x=void 0;function I(e){w=v({},w,e)}function k(){return w}function P(e){x=e}function T(){return x}var _={type:"3rdParty",init:function(e){I(e.options.react),P(e)}},C=!1,E=function(e){m(t,e);function t(e,n){d(this,t);var i=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=e.i18n||n.i18n||T(),i.namespaces=e.ns||i.i18n.options&&i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var r=i.i18n&&i.i18n.options&&i.i18n.options.react||{};i.options=v({},k(),r,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options&&i.i18n.options.isInitialSSR&&(i.options.wait=!1);var o=i.i18n.languages&&i.i18n.languages[0],a=!!o&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(o,e)});return i.state={i18nLoadedAt:null,ready:a},i.t=i.getI18nTranslate(),i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return y(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n){this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)})}if(this.options.bindStore){this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.onI18nChanged)})}}}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var e=this,t=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!C&&(C=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),t}(t.Component);E.contextTypes={i18n:n.object},E.childContextTypes={t:n.func.isRequired,i18n:n.object};function R(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var a=function(t){m(n,t);function n(t,i){d(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,i));o.i18n=t.i18n||r.i18n||i.i18n||T(),o.namespaces="function"==typeof e?e(t):e||o.i18n.options&&o.i18n.options.defaultNS,"string"==typeof o.namespaces&&(o.namespaces=[o.namespaces]);var a=o.i18n&&o.i18n.options&&o.i18n.options.react||{};return o.options=v({},k(),a,r),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return y(n,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!function(e,t){if(S(e,t))return!0;if("object"!==(void 0===e?"undefined":h(e))||null===e||"object"!==(void 0===t?"undefined":h(t))||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!j.call(t,n[r])||!S(e[n[r]],t[n[r]]))return!1;return!0}(this.props,e)}},{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,t={};return this.options.withRef&&(t.ref=function(t){e.wrappedInstance=t}),i.createElement(E,v({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,r){var a=r.ready,s=g(r,["ready"]);return i.createElement(o,v({tReady:a},e.props,t,s))})}}]),n}(t.Component);a.WrappedComponent=o,a.contextTypes={i18n:n.object},a.displayName="Translate("+(s=o,s.displayName||s.name||"Component")+")";var s;return a.namespaces=e,f(a,o)}}R.setDefaults=I,R.setI18n=P;var N=function(e){m(t,e);function t(e,n){d(this,t);var i=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return y(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,r=this.props,o=r.className,a=r.style,s=this.props.useDangerouslySetInnerHTML||!1,c=this.props.dangerouslySetInnerHTMLPartElement||"span",p=v({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,p);if(!u||"string"!=typeof u)return i.createElement("noscript",null);var l=[];u.split(n).reduce(function(t,n,r){var o=void 0;if(r%2==0){if(0===n.length)return t;o=s?i.createElement(c,{dangerouslySetInnerHTML:{__html:n}}):n}else o=function(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+u),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)}(n,e.props);return t.push(o),t},l);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];if(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 o&&(f.className=o),a&&(f.style=a),i.createElement.apply(this,[t,f].concat(l))}}]),t}(t.Component);N.propTypes={className:n.string},N.defaultProps={className:""},N.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var A={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},L=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,q=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,W=Object.create?Object.create(null):{};function D(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function K(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(K,"")+"</"+t.name+">"}}var M={parse:function(e,t){t||(t={}),t.components||(t.components=W);var n,i=[],r=-1,o=[],a=!1;return e.replace(q,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),l=0===s.indexOf("\x3c!--"),f=c+s.length,h=e.charAt(f);u&&!l&&(r++,"tag"===(n=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(L,function(o){if("="===o)return i=!0,void n++;i?0===n?((A[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r}(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!h||"<"===h||D(n.children,e,r,f,t.ignoreWhitespace),0===r&&i.push(n),(p=o[r-1])&&p.children.push(n),o[r]=n),(l||!u||n.voidElement)&&(l||r--,!a&&"<"!==h&&h&&D(p=-1===r?i:o[r].children,e,r,f,t.ignoreWhitespace))}),!i.length&&e.length&&D(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+K("",t)},"")}};function $(e){return e&&(e.children||e.props&&e.props.children)}function z(e){return e&&e.children?e.children:e.props&&e.props.children}function H(e,t,n){if(""===t)return[];if(!e)return[t];return z(function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce(function(r,o,a){if("tag"===o.type){var s=t[parseInt(o.name,10)]||{},c=i.isValidElement(s);if("string"==typeof s)r.push(s);else if($(s)){var p=e(z(s),o.children);s.dummy&&(s.children=p),r.push(i.cloneElement(s,v({},s.props,{key:a}),p))}else if("object"!==(void 0===s?"undefined":h(s))||c)r.push(s);else{var u=n.services.interpolator.interpolate(o.children[0].content,s,n.language);r.push(u)}}else"text"===o.type&&r.push(o.content);return r},[])}([{dummy:!0,children:e}],M.parse("<0>"+t+"</0>"))[0])}var V=function(e){m(t,e);function t(){return d(this,t),b(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return y(t,[{key:"render",value:function(){var e=v({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,r=e.parent,o=e.i18nKey,a=e.tOptions,s=e.ns,c=e.i18n,p=e.t,u=g(e,["children","count","parent","i18nKey","tOptions","ns","i18n","t"]),l=p||c.t.bind(c),f=c.options&&c.options.react||{},d=void 0!==r?r:f.defaultTransParent,y=function e(t,n,r){return n?("[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),n.forEach(function(n,r){var o=""+r;if("string"==typeof n)t=""+t+n;else if($(n))t=t+"<"+o+">"+e("",z(n),r+1)+"</"+o+">";else if(i.isValidElement(n))t=t+"<"+o+"></"+o+">";else if("object"===(void 0===n?"undefined":h(n))){var a=v({},n),s=a.format;delete a.format;var c=Object.keys(a);s&&1===c.length?t=t+"<"+o+">{{"+c[0]+", "+s+"}}</"+o+">":1===c.length?t=t+"<"+o+">{{"+c[0]+"}}</"+o+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",n)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",n)}),t):""}("",t),m=f.hashTransKey,b=o||(m?m(y):y),O=b?l(b,v({},a,{interpolation:{prefix:"#$?",suffix:"?$#"},defaultValue:y,count:n,ns:s})):y;if(f.exposeNamespace){var j="string"==typeof l.ns?l.ns:l.ns[0];if(o&&c.options&&c.options.nsSeparator&&o.indexOf(c.options.nsSeparator)>-1){j=o.split(c.options.nsSeparator)[0]}l.ns&&(u["data-i18next-options"]=JSON.stringify({ns:j}))}return d?i.createElement(d,u,H(t,O,c)):H(t,O,c)}}]),t}(i.Component);V.propTypes={count:n.number,parent:n.oneOfType([n.node,n.func]),i18nKey:n.string,i18n:n.object,t:n.func},V.contextTypes={i18n:n.object.isRequired,t:n.func};var F=function(e){m(n,e);function n(e,t){d(this,n);var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return y(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);F.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},F.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i});function J(e){var t=[];return function(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===h(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=O(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}e.translate=R,e.I18n=E,e.Interpolate=N,e.Trans=V,e.I18nextProvider=F,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=J(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=_,e.setDefaults=I,e.getDefaults=k,e.setI18n=P,e.getI18n=T,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function r(e,t){if(i(e,t))return!0;if("object"!==(void 0===e?"undefined":C(e))||null===e||"object"!==(void 0===t?"undefined":C(t))||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!D.call(t,n[o])||!i(e[n[o]],t[n[o]]))return!1;return!0}function o(e){K=N({},K,e)}function a(){return K}function s(e){M=e}function c(){return M}function p(e){return e.displayName||e.name||"Component"}function u(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var s=function(t){function n(t,r){E(this,n);var o=q(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r));o.i18n=t.i18n||i.i18n||r.i18n||c(),o.namespaces="function"==typeof e?e(t):e||o.i18n.options&&o.i18n.options.defaultNS,"string"==typeof o.namespaces&&(o.namespaces=[o.namespaces]);var s=o.i18n&&o.i18n.options&&o.i18n.options.react||{};return o.options=N({},a(),s,i),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return A(n,t),R(n,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!r(this.props,e)}},{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,t={};return this.options.withRef&&(t.ref=function(t){e.wrappedInstance=t}),O.createElement(H,N({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,i){var r=i.ready,a=L(i,["ready"]);return O.createElement(o,N({tReady:r},e.props,t,a))})}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object},s.displayName="Translate("+p(o)+")",s.namespaces=e,_(s,o)}}function l(e,t,n,i,r){var o=t.indexOf("<",i),a=t.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}function h(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?f(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(h,"")+"</"+t.name+">"}}function d(e){return e&&(e.children||e.props&&e.props.children)}function y(e){return e&&e.children?e.children:e.props&&e.props.children}function v(e,t,n){return t?("[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,n){var i=""+n;if("string"==typeof t)e=""+e+t;else if(d(t))e=e+"<"+i+">"+v("",y(t),n+1)+"</"+i+">";else if(O.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":C(t))){var r=N({},t),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?e=e+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?e=e+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",t)}),e):""}function m(e,t,n){function i(e,t){return"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,r,o){if("tag"===r.type){var a=e[parseInt(r.name,10)]||{},s=O.isValidElement(a);if("string"==typeof a)t.push(a);else if(d(a)){var c=i(y(a),r.children);a.dummy&&(a.children=c),t.push(O.cloneElement(a,N({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":C(a))||s)t.push(a);else{var p=n.services.interpolator.interpolate(r.children[0].content,a,n.language);t.push(p)}}else"text"===r.type&&t.push(r.content);return t},[])}return""===t?[]:e?y(i([{dummy:!0,children:e}],Q.parse("<0>"+t+"</0>"))[0]):[t]}function g(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===C(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Object.entries(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=W(s.value,2),u=p[0];t(p[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else t(e[n],n)}function b(e){var t=[];return g(e,function(e){e&&e.namespaces&&e.namespaces.forEach(function(e){-1===t.indexOf(e)&&t.push(e)})}),t}var O="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var j={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},w=Object.defineProperty,x=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,k=Object.getOwnPropertyDescriptor,P=Object.getPrototypeOf,T=P&&P(Object),_=function e(t,n,i){if("string"!=typeof n){if(T){var r=P(n);r&&r!==T&&e(t,r,i)}var o=x(n);I&&(o=o.concat(I(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(j[s]||S[s]||i&&i[s])){var c=k(n,s);try{w(t,s,c)}catch(e){}}}return t}return t},C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E=(function(){function e(e){this.value=e}function t(t){function n(r,o){try{var a=t[r](o),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){n("next",e)},function(e){n("throw",e)}):i(a.done?"return":"normal",a.value)}catch(e){i("throw",e)}}function i(e,t){switch(e){case"return":r.resolve({value:t,done:!0});break;case"throw":r.reject(t);break;default:r.resolve({value:t,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),R=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),N=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},A=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},L=function(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},q=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},W=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),D=Object.prototype.hasOwnProperty,K={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1},M=void 0,$={type:"3rdParty",init:function(e){o(e.options.react),s(e)}},z=!1,H=function(e){function t(e,n){E(this,t);var i=q(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.i18n=e.i18n||n.i18n||c(),i.namespaces=e.ns||i.i18n.options&&i.i18n.options.defaultNS,"string"==typeof i.namespaces&&(i.namespaces=[i.namespaces]);var r=i.i18n&&i.i18n.options&&i.i18n.options.react||{};i.options=N({},a(),r,e),e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.options.wait=!1),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i.i18n.options&&i.i18n.options.isInitialSSR&&(i.options.wait=!1);var o=i.i18n.languages&&i.i18n.languages[0],s=!!o&&i.namespaces.every(function(e){return i.i18n.hasResourceBundle(o,e)});return i.state={i18nLoadedAt:null,ready:s},i.t=i.getI18nTranslate(),i.onI18nChanged=i.onI18nChanged.bind(i),i.getI18nTranslate=i.getI18nTranslate.bind(i),i}return A(t,e),R(t,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var e=this,t=function(){e.options.bindI18n&&e.i18n&&e.i18n.on(e.options.bindI18n,e.onI18nChanged),e.options.bindStore&&e.i18n.store&&e.i18n.store.on(e.options.bindStore,e.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){e.mounted&&!e.state.ready&&e.setState({ready:!0}),e.options.wait&&e.mounted&&t()};if(e.i18n.isInitialized)n();else{e.i18n.on("initialized",function t(){setTimeout(function(){e.i18n.off("initialized",t)},1e3),n()})}}),this.options.wait||t()}},{key:"componentWillUnmount",value:function(){var e=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(t){return e.i18n.off(t,e.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(t){return e.i18n.store&&e.i18n.store.off(t,e.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date}))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var e=this,t=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!z&&(z=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),t}(t.Component);H.contextTypes={i18n:n.object},H.childContextTypes={t:n.func.isRequired,i18n:n.object},u.setDefaults=o,u.setI18n=s;var V=function(e){function t(e,n){E(this,t);var i=q(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return i.i18n=e.i18n||n.i18n,i.t=e.t||n.t,i}return A(t,e),R(t,[{key:"render",value:function(){var e=this,t=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",c=N({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,c);if(!p||"string"!=typeof p)return O.createElement("noscript",null);var u=[],l=function(t,n){if(t.indexOf(e.i18n.options.interpolation.formatSeparator)<0)return void 0===n[t]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+p),n[t];var i=t.split(e.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(e.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&e.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+p),e.i18n.options.interpolation.format(n[r],o,e.i18n.language)};p.split(n).reduce(function(t,n,i){var r=void 0;if(i%2==0){if(0===n.length)return t;r=a?O.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,e.props);return t.push(r),t},u);var f={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var h="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];this.props.i18nKey&&this.i18n.options.nsSeparator&&this.props.i18nKey.indexOf(this.i18n.options.nsSeparator)>-1&&(h=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:h}))}return r&&(f.className=r),o&&(f.style=o),O.createElement.apply(this,[t,f].concat(u))}}]),t}(t.Component);V.propTypes={className:n.string},V.defaultProps={className:""},V.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var F={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},J=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,U=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(J,function(o){if("="===o)return i=!0,void n++;i?0===n?((F[o]||"/"===e.charAt(e.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(r.attrs[t]=t),t=o),n++,i=!1}),r},B=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,G=Object.create?Object.create(null):{},Q={parse:function(e,t){t||(t={}),t.components||(t.components=G);var n,i=[],r=-1,o=[],a=!1;return e.replace(B,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=c+s.length,d=e.charAt(h);u&&!f&&(r++,"tag"===(n=U(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||l(n.children,e,r,h,t.ignoreWhitespace),0===r&&i.push(n),(p=o[r-1])&&p.children.push(n),o[r]=n),(f||!u||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&l(p=-1===r?i:o[r].children,e,r,h,t.ignoreWhitespace))}),!i.length&&e.length&&l(i,e,0,0,t.ignoreWhitespace),i},stringify:function(e){return e.reduce(function(e,t){return e+h("",t)},"")}},X=function(e){function t(){return E(this,t),q(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return A(t,e),R(t,[{key:"render",value:function(){var e=N({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,i=e.parent,r=e.i18nKey,o=e.tOptions,a=e.values,s=e.defaults,c=e.components,p=e.ns,u=e.i18n,l=e.t,f=L(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),h=l||u.t.bind(u),d=u.options&&u.options.react||{},y=void 0!==i?i:d.defaultTransParent,g=s||v("",t,0),b=d.hashTransKey,j=r||(b?b(g):g),S=j?h(j,N({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:g,count:n,ns:p})):g;if(d.exposeNamespace){var w="string"==typeof h.ns?h.ns:h.ns[0];r&&u.options&&u.options.nsSeparator&&r.indexOf(u.options.nsSeparator)>-1&&(w=r.split(u.options.nsSeparator)[0]),h.ns&&(f["data-i18next-options"]=JSON.stringify({ns:w}))}return y?O.createElement(y,f,m(c||t,S,u)):m(c||t,S,u)}}]),t}(O.Component);X.propTypes={count:n.number,parent:n.oneOfType([n.node,n.func]),i18nKey:n.string,i18n:n.object,t:n.func},X.contextTypes={i18n:n.object.isRequired,t:n.func};var Y=function(e){function n(e,t){E(this,n);var i=q(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,e.initialI18nStore&&(i.i18n.services.resourceStore.data=e.initialI18nStore,i.i18n.options.isInitialSSR=!0),e.initialLanguage&&i.i18n.changeLanguage(e.initialLanguage),i}return A(n,e),R(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n}}},{key:"componentWillReceiveProps",value:function(e){if(this.props.i18n!==e.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var e=this.props.children;return t.Children.only(e)}}]),n}(t.Component);Y.propTypes={i18n:n.object.isRequired,children:n.element.isRequired},Y.childContextTypes={i18n:n.object.isRequired},Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,i=new Array(n);n--;)i[n]=[t[n],e[t[n]]];return i}),e.translate=u,e.I18n=H,e.Interpolate=V,e.Trans=X,e.I18nextProvider=Y,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=b(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=$,e.setDefaults=o,e.getDefaults=a,e.setI18n=s,e.getI18n=c,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -104,2 +104,3 @@ # react-i18next [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Awesome%20react-i18next%20for%20react.js%20based%20on%20i18next%20internationalization%20ecosystem%20&url=https://github.com/i18next/react-i18next&via=jamuhl&hashtags=i18n,reactjs,js,dev) | ||
* [Example locize.com](https://github.com/i18next/react-i18next/tree/master/example/locize-example) | ||
* [Example test with jest](https://github.com/i18next/react-i18next/tree/master/example/test-jest) | ||
@@ -106,0 +107,0 @@ ### Requirements |
@@ -102,3 +102,3 @@ import React from 'react'; | ||
const contextAndProps = { i18n: this.context.i18n, t: this.context.t, ...this.props }; | ||
const { children, count, parent, i18nKey, tOptions, ns: namespace, i18n, t: tFromContextAndProps, ...additionalProps } = contextAndProps; | ||
const { children, count, parent, i18nKey, tOptions, values, defaults, components, ns: namespace, i18n, t: tFromContextAndProps, ...additionalProps } = contextAndProps; | ||
const t = tFromContextAndProps || i18n.t.bind(i18n); | ||
@@ -109,6 +109,7 @@ | ||
const defaultValue = nodesToString('', children, 0); | ||
const defaultValue = defaults || nodesToString('', children, 0); | ||
const hashTransKey = reactI18nextOptions.hashTransKey; | ||
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue); | ||
const translation = key ? t(key, { ...tOptions, ...{ interpolation: { prefix: '#$?', suffix: '?$#' }, defaultValue, count, ns: namespace } }) : defaultValue; | ||
const interpolationOverride = values ? {} : { interpolation: { prefix: '#$?', suffix: '?$#' } }; | ||
const translation = key ? t(key, { ...tOptions, ...values, ...interpolationOverride, defaultValue, count, ns: namespace }) : defaultValue; | ||
@@ -124,3 +125,3 @@ if (reactI18nextOptions.exposeNamespace) { | ||
if (!useAsParent) return renderNodes(children, translation, i18n); | ||
if (!useAsParent) return renderNodes(components || children, translation, i18n); | ||
@@ -130,3 +131,3 @@ return React.createElement( | ||
additionalProps, | ||
renderNodes(children, translation, i18n) | ||
renderNodes(components || children, translation, i18n) | ||
); | ||
@@ -133,0 +134,0 @@ } |
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
285074
5370
121