react-i18next 7.9.1 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +12 -2
- package/dist/amd/react-i18next.js +31 -17
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/I18nextProvider.js +9 -4
- package/dist/commonjs/translate.js +7 -1
- package/dist/es/I18nextProvider.js +9 -4
- package/dist/es/translate.js +7 -1
- package/dist/umd/react-i18next.js +31 -17
- package/dist/umd/react-i18next.min.js +1 -1
- package/icu.macro.js +331 -0
- package/package.json +15 -9
- package/react-i18next.js +31 -17
- package/react-i18next.min.js +1 -1
- package/src/I18nextProvider.js +9 -4
- package/src/context.js +2 -2
- package/src/translate.js +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
### 7.11.1
|
|
2
|
+
|
|
3
|
+
- fix related to issue #504: also report default Namespace with translate() [506](https://github.com/i18next/react-i18next/pull/506)
|
|
4
|
+
|
|
5
|
+
### 7.11.0
|
|
6
|
+
|
|
7
|
+
- Added reportNS function to I18NextProvider to report used namespaces [500](https://github.com/i18next/react-i18next/pull/500)
|
|
8
|
+
|
|
9
|
+
### 7.10.1
|
|
10
|
+
|
|
11
|
+
- fix small issue in icu.macro introduced on refactoring
|
|
12
|
+
|
|
13
|
+
### 7.10.0
|
|
14
|
+
|
|
15
|
+
- Adds import { Trans, Plural, Select } from `react-i18next/icu.macro` a babel macro to allow nicer components used with ICU format (which as default would result in invalid JSX). [discussion](https://github.com/i18next/react-i18next/issues/439)
|
|
16
|
+
|
|
1
17
|
### 7.9.1
|
|
2
18
|
|
|
3
19
|
- Skip custom html tags in Trans component translation [PR482](https://github.com/i18next/react-i18next/pull/482)
|
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ The documentation is published on [react.i18next.com](https://react.i18next.com)
|
|
|
28
28
|
|
|
29
29
|
**Before:** Your react code would have looked something like:
|
|
30
30
|
|
|
31
|
-
```
|
|
31
|
+
```jsx
|
|
32
32
|
...
|
|
33
33
|
<div>Just simple content</div>
|
|
34
34
|
<div>
|
|
@@ -39,7 +39,7 @@ The documentation is published on [react.i18next.com](https://react.i18next.com)
|
|
|
39
39
|
|
|
40
40
|
**After:** With the trans component just change it to:
|
|
41
41
|
|
|
42
|
-
```
|
|
42
|
+
```jsx
|
|
43
43
|
...
|
|
44
44
|
<div>{t('simpleContent')}</div>
|
|
45
45
|
<Trans i18nKey="userMessagesUnread" count={count}>
|
|
@@ -108,6 +108,16 @@ $ bower install react-i18next
|
|
|
108
108
|
- react >= __0.14.0__ (in case of < v16 or preact you will need to define parent in [Trans component](https://react.i18next.com/components/trans-component.html#props) or globally in [i18next.react options](https://react.i18next.com/components/trans-component.html#additional-options-on-i18nextinit))
|
|
109
109
|
- i18next >= __2.0.0__
|
|
110
110
|
|
|
111
|
+
--------------
|
|
112
|
+
|
|
113
|
+
<h3 align="center">Gold Sponsors</h3>
|
|
114
|
+
|
|
115
|
+
<p align="center">
|
|
116
|
+
<a href="https://locize.com/" target="_blank">
|
|
117
|
+
<img src="https://raw.githubusercontent.com/i18next/i18next/master/assets/locize_sponsor_240.gif" width="240px">
|
|
118
|
+
</a>
|
|
119
|
+
</p>
|
|
120
|
+
|
|
111
121
|
--------------
|
|
112
122
|
**localization as a service - locize.com**
|
|
113
123
|
|
|
@@ -3,31 +3,32 @@ define(['exports', 'react', 'prop-types'], function (exports, React, PropTypes)
|
|
|
3
3
|
var React__default = 'default' in React ? React['default'] : React;
|
|
4
4
|
PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes;
|
|
5
5
|
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* Copyright 2015, Yahoo! Inc.
|
|
8
10
|
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
9
11
|
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
12
|
var REACT_STATICS = {
|
|
13
13
|
childContextTypes: true,
|
|
14
14
|
contextTypes: true,
|
|
15
15
|
defaultProps: true,
|
|
16
16
|
displayName: true,
|
|
17
17
|
getDefaultProps: true,
|
|
18
|
+
getDerivedStateFromProps: true,
|
|
18
19
|
mixins: true,
|
|
19
20
|
propTypes: true,
|
|
20
21
|
type: true
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
var KNOWN_STATICS = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
name: true,
|
|
26
|
+
length: true,
|
|
27
|
+
prototype: true,
|
|
28
|
+
caller: true,
|
|
29
|
+
callee: true,
|
|
30
|
+
arguments: true,
|
|
31
|
+
arity: true
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
var defineProperty = Object.defineProperty;
|
|
@@ -37,7 +38,7 @@ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
|
37
38
|
var getPrototypeOf = Object.getPrototypeOf;
|
|
38
39
|
var objectPrototype = getPrototypeOf && getPrototypeOf(Object);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
|
41
42
|
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
|
|
42
43
|
|
|
43
44
|
if (objectPrototype) {
|
|
@@ -67,7 +68,9 @@ var hoistNonReactStatics = function hoistNonReactStatics(targetComponent, source
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
return targetComponent;
|
|
70
|
-
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
|
71
74
|
|
|
72
75
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
73
76
|
return typeof obj;
|
|
@@ -615,6 +618,11 @@ function translate(namespaceArg) {
|
|
|
615
618
|
var i18nOptions = _this.i18n && _this.i18n.options && _this.i18n.options.react || {};
|
|
616
619
|
_this.options = _extends({}, getDefaults(), i18nOptions, options);
|
|
617
620
|
|
|
621
|
+
if (context.reportNS) {
|
|
622
|
+
var namespaces = _this.namespaces || [undefined];
|
|
623
|
+
namespaces.forEach(context.reportNS);
|
|
624
|
+
}
|
|
625
|
+
|
|
618
626
|
_this.getWrappedInstance = _this.getWrappedInstance.bind(_this);
|
|
619
627
|
return _this;
|
|
620
628
|
}
|
|
@@ -668,14 +676,15 @@ function translate(namespaceArg) {
|
|
|
668
676
|
|
|
669
677
|
Translate.contextTypes = {
|
|
670
678
|
i18n: PropTypes.object,
|
|
671
|
-
defaultNS: PropTypes.string
|
|
679
|
+
defaultNS: PropTypes.string,
|
|
680
|
+
reportNS: PropTypes.func
|
|
672
681
|
};
|
|
673
682
|
|
|
674
683
|
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
|
|
675
684
|
|
|
676
685
|
Translate.namespaces = namespaceArg;
|
|
677
686
|
|
|
678
|
-
return
|
|
687
|
+
return hoistNonReactStatics_cjs(Translate, WrappedComponent);
|
|
679
688
|
};
|
|
680
689
|
}
|
|
681
690
|
|
|
@@ -1166,6 +1175,7 @@ var I18nextProvider = function (_Component) {
|
|
|
1166
1175
|
if (props.initialLanguage) {
|
|
1167
1176
|
_this.i18n.changeLanguage(props.initialLanguage);
|
|
1168
1177
|
}
|
|
1178
|
+
_this.reportNS = props.reportNS;
|
|
1169
1179
|
return _this;
|
|
1170
1180
|
}
|
|
1171
1181
|
|
|
@@ -1174,7 +1184,8 @@ var I18nextProvider = function (_Component) {
|
|
|
1174
1184
|
value: function getChildContext() {
|
|
1175
1185
|
return {
|
|
1176
1186
|
i18n: this.i18n,
|
|
1177
|
-
defaultNS: this.defaultNS
|
|
1187
|
+
defaultNS: this.defaultNS,
|
|
1188
|
+
reportNS: this.reportNS
|
|
1178
1189
|
};
|
|
1179
1190
|
}
|
|
1180
1191
|
}, {
|
|
@@ -1198,16 +1209,19 @@ var I18nextProvider = function (_Component) {
|
|
|
1198
1209
|
I18nextProvider.propTypes = {
|
|
1199
1210
|
i18n: PropTypes.object.isRequired,
|
|
1200
1211
|
children: PropTypes.element.isRequired,
|
|
1201
|
-
defaultNS: PropTypes.string
|
|
1212
|
+
defaultNS: PropTypes.string,
|
|
1213
|
+
reportNS: PropTypes.func
|
|
1202
1214
|
};
|
|
1203
1215
|
|
|
1204
1216
|
I18nextProvider.childContextTypes = {
|
|
1205
1217
|
i18n: PropTypes.object.isRequired,
|
|
1206
|
-
defaultNS: PropTypes.string
|
|
1218
|
+
defaultNS: PropTypes.string,
|
|
1219
|
+
reportNS: PropTypes.func
|
|
1207
1220
|
};
|
|
1208
1221
|
|
|
1209
1222
|
I18nextProvider.defaultProps = {
|
|
1210
|
-
defaultNS: undefined
|
|
1223
|
+
defaultNS: undefined,
|
|
1224
|
+
reportNS: undefined
|
|
1211
1225
|
};
|
|
1212
1226
|
|
|
1213
1227
|
var objectEntries = Object.entries || function (obj) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
define(["exports","react","prop-types"],function(t,e,n){"use strict";function i(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}function r(t,e){if(i(t,e))return!0;if("object"!==(void 0===t?"undefined":C(t))||null===t||"object"!==(void 0===e?"undefined":C(e))||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!K.call(e,n[o])||!i(t[n[o]],e[n[o]]))return!1;return!0}function o(t){M=R({},M,t)}function a(){return M}function s(t){q=t}function c(){return q}function u(t){return t.displayName||t.name||"Component"}function p(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(o){var s=function(e){function n(e,r){N(this,n);var o=W(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,r));o.i18n=e.i18n||i.i18n||r.i18n||c(),o.namespaces="function"==typeof t?t(e):t||r.defaultNS||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=R({},a(),s,i),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return A(n,e),E(n,[{key:"shouldComponentUpdate",value:function(t){return!this.options.usePureComponent||!r(this.props,t)}},{key:"getWrappedInstance",value:function(){return this.options.withRef||console.error("To access the wrapped instance, you need to specify { withRef: true } as the second argument of the translate() call."),this.wrappedInstance}},{key:"render",value:function(){var t=this,e={};return this.options.withRef&&(e.ref=function(e){t.wrappedInstance=e}),S.createElement(B,R({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,i){var r=i.ready,a=L(i,["ready"]);return S.createElement(o,R({tReady:r},t.props,e,a))})}}]),n}(e.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object,defaultNS:n.string},s.displayName="Translate("+u(o)+")",s.namespaces=t,_(s,o)}}function l(t,e,n,i,r){var o=e.indexOf("<",i),a=e.slice(i,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!r&&o>-1&&n+t.length>=0||" "!==a)&&t.push({type:"text",content:a})}function f(t){var e=[];for(var n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}function h(t,e){switch(e.type){case"text":return t+e.content;case"tag":return t+="<"+e.name+(e.attrs?f(e.attrs):"")+(e.voidElement?"/>":">"),e.voidElement?t:t+e.children.reduce(h,"")+"</"+e.name+">"}}function d(t){return t&&(t.children||t.props&&t.props.children)}function y(t){return t&&t.children?t.children:t.props&&t.props.children}function v(t,e,n){return e?("[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,n){var i=""+n;if("string"==typeof e)t=""+t+e;else if(d(e))t=t+"<"+i+">"+v("",y(e),n+1)+"</"+i+">";else if(S.isValidElement(e))t=t+"<"+i+"></"+i+">";else if("object"===(void 0===e?"undefined":C(e))){var r=R({},e),o=r.format;delete r.format;var a=Object.keys(r);o&&1===a.length?t=t+"<"+i+">{{"+a[0]+", "+o+"}}</"+i+">":1===a.length?t=t+"<"+i+">{{"+a[0]+"}}</"+i+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)}),t):""}function m(t,e,n){function i(t,e){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,r,o){if("tag"===r.type){var a=t[parseInt(r.name,10)]||{},s=S.isValidElement(a);if("string"==typeof a)e.push(a);else if(d(a)){var c=i(y(a),r.children);a.dummy&&(a.children=c),e.push(S.cloneElement(a,R({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":C(a))||s)e.push(a);else if(r.children[0]?r.children[0].content:null){var u=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(u)}}else"text"===r.type&&e.push(r.content);return e},[])}return""===e?[]:t?y(i([{dummy:!0,children:t}],Q.parse("<0>"+e+"</0>"))[0]):[e]}function g(t,e){for(var n=0,i=t.length;n<i;n++)if("object"===C(t[n])){var r=!0,o=!1,a=void 0;try{for(var s,c=Z(t[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var u=D(s.value,2),p=u[0];e(u[1],n,p)}}catch(t){o=!0,a=t}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}}else e(t[n],n)}function b(t){var e=[];return g(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}var S="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;var O={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},j={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 t(e,n,i){if("string"!=typeof n){if(T){var r=P(n);r&&r!==T&&t(e,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(!(O[s]||j[s]||i&&i[s])){var c=k(n,s);try{w(e,s,c)}catch(t){}}}return e}return e},C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N=(function(){function t(t){this.value=t}function e(e){function n(r,o){try{var a=e[r](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){n("next",t)},function(t){n("throw",t)}):i(a.done?"return":"normal",a.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):o=null}var r,o;this._invoke=function(t,e){return new Promise(function(i,a){var s={key:t,arg:e,resolve:i,reject:a,next:null};o?o=o.next=s:(r=o=s,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),E=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),R=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},A=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},L=function(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},W=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},D=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),K=Object.prototype.hasOwnProperty,M={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1,omitBoundRerender:!0},q=void 0,$={type:"3rdParty",init:function(t){o(t.options.react),s(t)}},z=!1,B=function(t){function e(t,n){N(this,e);var i=W(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.i18n=t.i18n||n.i18n||c(),i.namespaces=t.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=R({},a(),r,t),t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.options.wait=!1),t.initialLanguage&&i.i18n.changeLanguage(t.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(t){return i.i18n.hasResourceBundle(o,t)});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(e,t),E(e,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var t=this,e=function(){t.options.bindI18n&&t.i18n&&t.i18n.on(t.options.bindI18n,t.onI18nChanged),t.options.bindStore&&t.i18n.store&&t.i18n.store.on(t.options.bindStore,t.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var n=function(){t.mounted&&!t.state.ready&&t.setState({ready:!0}),t.options.wait&&t.mounted&&e()};if(t.i18n.isInitialized)n();else{t.i18n.on("initialized",function e(){setTimeout(function(){t.i18n.off("initialized",e)},1e3),n()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;this.mounted=!1,this.onI18nChanged&&(this.options.bindI18n&&this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)}),this.options.bindStore&&this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)}))}},{key:"onI18nChanged",value:function(){this.mounted&&(!this.state.ready&&this.options.omitBoundRerender||(this.t=this.getI18nTranslate(),this.setState({i18nLoadedAt:new Date})))}},{key:"getI18nTranslate",value:function(){return this.i18n.getFixedT(null,"fallback"===this.options.nsMode?this.namespaces:this.namespaces[0])}},{key:"render",value:function(){var t=this,e=this.props.children,n=this.state.ready;return!n&&this.options.wait?null:(this.i18n.options&&this.i18n.options.isInitialSSR&&!z&&(z=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),e}(e.Component);B.contextTypes={i18n:n.object},B.childContextTypes={t:n.func.isRequired,i18n:n.object},p.setDefaults=o,p.setI18n=s;var H=function(t){function e(t,n){N(this,e);var i=W(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.i18n=t.i18n||n.i18n,i.t=t.t||n.t,i}return A(e,t),E(e,[{key:"render",value:function(){var t=this,e=this.props.parent||"span",n=this.props.regexp||this.i18n.services.interpolator.regexp,i=this.props,r=i.className,o=i.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",c=R({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),u=this.t(this.props.i18nKey,c);if(!u||"string"!=typeof u)return S.createElement("noscript",null);var p=[],l=function(e,n){if(e.indexOf(t.i18n.options.interpolation.formatSeparator)<0)return void 0===n[e]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+u),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+u),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};u.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?S.createElement(s,{dangerouslySetInnerHTML:{__html:n}}):n}else r=l(n,t.props);return e.push(r),e},p);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),S.createElement.apply(this,[e,f].concat(p))}}]),e}(e.Component);H.propTypes={className:n.string},H.defaultProps={className:""},H.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var V={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},F=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,J=function(t){var e,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return t.replace(F,function(o){if("="===o)return i=!0,void n++;i?0===n?((V[o]||"/"===t.charAt(t.length-2))&&(r.voidElement=!0),r.name=o):(r.attrs[e]=o.replace(/^['"]|['"]$/g,""),e=void 0):(e&&(r.attrs[e]=e),e=o),n++,i=!1}),r},U=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,G=Object.create?Object.create(null):{},Q={parse:function(t,e){e||(e={}),e.components||(e.components=G);var n,i=[],r=-1,o=[],a=!1;return t.replace(U,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var u,p="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=c+s.length,d=t.charAt(h);p&&!f&&(r++,"tag"===(n=J(s)).type&&e.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!d||"<"===d||l(n.children,t,r,h,e.ignoreWhitespace),0===r&&i.push(n),(u=o[r-1])&&u.children.push(n),o[r]=n),(f||!p||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&l(u=-1===r?i:o[r].children,t,r,h,e.ignoreWhitespace))}),!i.length&&t.length&&l(i,t,0,0,e.ignoreWhitespace),i},stringify:function(t){return t.reduce(function(t,e){return t+h("",e)},"")}},X=function(t){function e(){return N(this,e),W(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return A(e,t),E(e,[{key:"render",value:function(){var t=R({i18n:this.context.i18n,t:this.context.t},this.props),e=t.children,n=t.count,i=t.parent,r=t.i18nKey,o=t.tOptions,a=t.values,s=t.defaults,c=t.components,u=t.ns,p=t.i18n,l=t.t,f=L(t,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),h=l||p.t.bind(p),d=p.options&&p.options.react||{},y=void 0!==i?i:d.defaultTransParent,g=s||v("",e,0),b=d.hashTransKey,O=r||(b?b(g):g),j=O?h(O,R({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:g,count:n,ns:u})):g;if(d.exposeNamespace){var w="string"==typeof h.ns?h.ns:h.ns[0];r&&p.options&&p.options.nsSeparator&&r.indexOf(p.options.nsSeparator)>-1&&(w=r.split(p.options.nsSeparator)[0]),h.ns&&(f["data-i18next-options"]=JSON.stringify({ns:w}))}return y?S.createElement(y,f,m(c||e,j,p)):m(c||e,j,p)}}]),e}(S.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,t:n.func};var Y=function(t){function n(t,e){N(this,n);var i=W(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.i18n=t.i18n,i.defaultNS=t.defaultNS,t.initialI18nStore&&(i.i18n.services.resourceStore.data=t.initialI18nStore,i.i18n.options.isInitialSSR=!0),t.initialLanguage&&i.i18n.changeLanguage(t.initialLanguage),i}return A(n,t),E(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n,defaultNS:this.defaultNS}}},{key:"componentWillReceiveProps",value:function(t){if(this.props.i18n!==t.i18n)throw new Error("[react-i18next][I18nextProvider]does not support changing the i18n object.")}},{key:"render",value:function(){var t=this.props.children;return e.Children.only(t)}}]),n}(e.Component);Y.propTypes={i18n:n.object.isRequired,children:n.element.isRequired,defaultNS:n.string},Y.childContextTypes={i18n:n.object.isRequired,defaultNS:n.string},Y.defaultProps={defaultNS:void 0};var Z=Object.entries||function(t){for(var e=Object.keys(t),n=e.length,i=new Array(n);n--;)i[n]=[e[n],t[e[n]]];return i};t.translate=p,t.I18n=B,t.Interpolate=H,t.Trans=X,t.I18nextProvider=Y,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,i=b(e);return new Promise(function(t){n.loadNamespaces(i,t)})},t.reactI18nextModule=$,t.setDefaults=o,t.getDefaults=a,t.setI18n=s,t.getI18n=c,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
define(["exports","react","prop-types"],function(e,n,i){"use strict";var O="default"in n?n.default:n;i=i&&i.hasOwnProperty("default")?i.default:i;var c={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},u={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l=Object.defineProperty,f=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,y=Object.getPrototypeOf,v=y&&y(Object);var r=function e(t,n,i){if("string"!=typeof n){if(v){var r=y(n);r&&r!==v&&e(t,r,i)}var o=f(n);h&&(o=o.concat(h(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(c[s]||u[s]||i&&i[s])){var p=d(n,s);try{l(t,s,p)}catch(e){}}}return t}return t},j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=(function(){function c(e){this.value=e}function e(r){var o,a;function s(e,t){try{var n=r[e](t),i=n.value;i instanceof c?Promise.resolve(i.value).then(function(e){s("next",e)},function(e){s("throw",e)}):p(n.done?"return":"normal",n.value)}catch(e){p("throw",e)}}function p(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?s(o.key,o.arg):a=null}this._invoke=function(i,r){return new Promise(function(e,t){var n={key:i,arg:r,resolve:e,reject:t,next:null};a?a=a.next=n:(o=a=n,s(i,r))})},"function"!=typeof r.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(e){return this._invoke("next",e)},e.prototype.throw=function(e){return this._invoke("throw",e)},e.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")}),m=function(){function i(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(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}}(),w=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},g=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)},x=function(e,t){var n={};for(var i in e)0<=t.indexOf(i)||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},S=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")},I=Object.prototype.hasOwnProperty;function N(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}var t={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1,omitBoundRerender:!0},o=void 0;function a(e){t=w({},t,e)}function k(){return t}function s(e){o=e}function P(){return o}var T={type:"3rdParty",init:function(e){a(e.options.react),s(e)}},_=!1,C=function(e){function a(e,t){p(this,a);var n=b(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e,t));n.i18n=e.i18n||t.i18n||P(),n.namespaces=e.ns||n.i18n.options&&n.i18n.options.defaultNS,"string"==typeof n.namespaces&&(n.namespaces=[n.namespaces]);var i=n.i18n&&n.i18n.options&&n.i18n.options.react||{};n.options=w({},k(),i,e),e.initialI18nStore&&(n.i18n.services.resourceStore.data=e.initialI18nStore,n.options.wait=!1),e.initialLanguage&&n.i18n.changeLanguage(e.initialLanguage),n.i18n.options&&n.i18n.options.isInitialSSR&&(n.options.wait=!1);var r=n.i18n.languages&&n.i18n.languages[0],o=!!r&&n.namespaces.every(function(e){return n.i18n.hasResourceBundle(r,e)});return n.state={i18nLoadedAt:null,ready:o},n.t=n.getI18nTranslate(),n.onI18nChanged=n.onI18nChanged.bind(n),n.getI18nTranslate=n.getI18nTranslate.bind(n),n}return g(a,e),m(a,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var n=this,e=function(){n.options.bindI18n&&n.i18n&&n.i18n.on(n.options.bindI18n,n.onI18nChanged),n.options.bindStore&&n.i18n.store&&n.i18n.store.on(n.options.bindStore,n.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var t=function(){n.mounted&&!n.state.ready&&n.setState({ready:!0}),n.options.wait&&n.mounted&&e()};if(n.i18n.isInitialized)t();else{n.i18n.on("initialized",function e(){setTimeout(function(){n.i18n.off("initialized",e)},1e3),t()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n)this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)});if(this.options.bindStore)this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}},{key:"onI18nChanged",value:function(){this.mounted&&(!this.state.ready&&this.options.omitBoundRerender||(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&&!_&&(_=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),a}(n.Component);function E(o){var s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return function(a){var e,t=function(e){function r(e,t){p(this,r);var n=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t));n.i18n=e.i18n||s.i18n||t.i18n||P(),n.namespaces="function"==typeof o?o(e):o||t.defaultNS||n.i18n.options&&n.i18n.options.defaultNS,"string"==typeof n.namespaces&&(n.namespaces=[n.namespaces]);var i=n.i18n&&n.i18n.options&&n.i18n.options.react||{};(n.options=w({},k(),i,s),t.reportNS)&&(n.namespaces||[void 0]).forEach(t.reportNS);return n.getWrappedInstance=n.getWrappedInstance.bind(n),n}return g(r,e),m(r,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!function(e,t){if(N(e,t))return!0;if("object"!==(void 0===e?"undefined":j(e))||null===e||"object"!==(void 0===t?"undefined":j(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(!I.call(t,n[r])||!N(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 r=this,o={};return this.options.withRef&&(o.ref=function(e){r.wrappedInstance=e}),O.createElement(C,w({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(e,t){var n=t.ready,i=x(t,["ready"]);return O.createElement(a,w({tReady:n},r.props,o,i))})}}]),r}(n.Component);return t.WrappedComponent=a,t.contextTypes={i18n:i.object,defaultNS:i.string,reportNS:i.func},t.displayName="Translate("+((e=a).displayName||e.name||"Component")+")",t.namespaces=o,r(t,a)}}C.contextTypes={i18n:i.object},C.childContextTypes={t:i.func.isRequired,i18n:i.object},E.setDefaults=a,E.setI18n=s;var R=function(e){function i(e,t){p(this,i);var n=b(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t));return n.i18n=e.i18n||t.i18n,n.t=e.t||t.t,n}return g(i,e),m(i,[{key:"render",value:function(){var o=this,e=this.props.parent||"span",t=this.props.regexp||this.i18n.services.interpolator.regexp,n=this.props,i=n.className,r=n.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=w({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,p);if(!c||"string"!=typeof c)return O.createElement("noscript",null);var u=[];c.split(t).reduce(function(e,t,n){var i=void 0;if(n%2==0){if(0===t.length)return e;i=a?O.createElement(s,{dangerouslySetInnerHTML:{__html:t}}):t}else i=function(e,t){if(e.indexOf(o.i18n.options.interpolation.formatSeparator)<0)return void 0===t[e]&&o.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+c),t[e];var n=e.split(o.i18n.options.interpolation.formatSeparator),i=n.shift().trim(),r=n.join(o.i18n.options.interpolation.formatSeparator).trim();return void 0===t[i]&&o.i18n.services.logger.warn("interpolator: missed to pass in variable "+i+" for interpolating "+c),o.i18n.options.interpolation.format(t[i],r,o.i18n.language)}(t,o.props);return e.push(i),e},u);var l={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var f="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&-1<this.props.i18nKey.indexOf(this.i18n.options.nsSeparator))f=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0];this.t.ns&&(l["data-i18next-options"]=JSON.stringify({ns:f}))}return i&&(l.className=i),r&&(l.style=r),O.createElement.apply(this,[e,l].concat(u))}}]),i}(n.Component);R.propTypes={className:i.string},R.defaultProps={className:""},R.contextTypes={i18n:i.object.isRequired,t:i.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,D=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,W=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&&-1<o&&0<=n+e.length||" "!==a)&&e.push({type:"text",content:a})}var M=function(f,h){h||(h={}),h.components||(h.components=W);var d,y=[],v=-1,m=[],g=!1;return f.replace(D,function(e,t){if(g){if(e!=="</"+d.name+">")return;g=!1}var n,i,r,o,a,s,p="/"!==e.charAt(1),c=0===e.indexOf("\x3c!--"),u=t+e.length,l=f.charAt(u);p&&!c&&(v++,s={type:"tag",name:"",voidElement:!(a=!(o=0)),attrs:{},children:[]},(i=e).replace(L,function(e){if("="===e)return a=!0,void o++;a?0===o?((A[e]||"/"===i.charAt(i.length-2))&&(s.voidElement=!0),s.name=e):(s.attrs[r]=e.replace(/^['"]|['"]$/g,""),r=void 0):(r&&(s.attrs[r]=r),r=e),o++,a=!1}),"tag"===(d=s).type&&h.components[d.name]&&(d.type="component",g=!0),d.voidElement||g||!l||"<"===l||K(d.children,f,v,u,h.ignoreWhitespace),0===v&&y.push(d),(n=m[v-1])&&n.children.push(d),m[v]=d),(c||!p||d.voidElement)&&(c||v--,!g&&"<"!==l&&l&&K(n=-1===v?y:m[v].children,f,v,u,h.ignoreWhitespace))}),!y.length&&f.length&&K(y,f,0,0,h.ignoreWhitespace),y};function q(e){return e&&(e.children||e.props&&e.props.children)}function $(e){return e&&e.children?e.children:e.props&&e.props.children}function z(e,t,c){if(""===t)return[];if(!e)return[t];return $(function s(p,e){return"[object Array]"!==Object.prototype.toString.call(p)&&(p=[p]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,t,n){if("tag"===t.type){var i=p[parseInt(t.name,10)]||{},r=O.isValidElement(i);if("string"==typeof i)e.push(i);else if(q(i)){var o=s($(i),t.children);i.dummy&&(i.children=o),e.push(O.cloneElement(i,w({},i.props,{key:n}),o))}else if("object"!==(void 0===i?"undefined":j(i))||r)e.push(i);else if(t.children[0]&&t.children[0].content){var a=c.services.interpolator.interpolate(t.children[0].content,i,c.language);e.push(a)}}else"text"===t.type&&e.push(t.content);return e},[])}([{dummy:!0,children:e}],M("<0>"+t+"</0>"))[0])}var B=function(e){function t(){return p(this,t),b(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return g(t,e),m(t,[{key:"render",value:function(){var e=w({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,p=e.components,c=e.ns,u=e.i18n,l=e.t,f=x(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,v=s||function a(s,e,t){return e?("[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,t){var n=""+t;if("string"==typeof e)s=""+s+e;else if(q(e))s=s+"<"+n+">"+a("",$(e),t+1)+"</"+n+">";else if(O.isValidElement(e))s=s+"<"+n+"></"+n+">";else if("object"===(void 0===e?"undefined":j(e))){var i=w({},e),r=i.format;delete i.format;var o=Object.keys(i);r&&1===o.length?s=s+"<"+n+">{{"+o[0]+", "+r+"}}</"+n+">":1===o.length?s=s+"<"+n+">{{"+o[0]+"}}</"+n+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)}),s):""}("",t),m=d.hashTransKey,g=r||(m?m(v):v),b=g?h(g,w({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:v,count:n,ns:c})):v;if(d.exposeNamespace){var S="string"==typeof h.ns?h.ns:h.ns[0];if(r&&u.options&&u.options.nsSeparator&&-1<r.indexOf(u.options.nsSeparator))S=r.split(u.options.nsSeparator)[0];h.ns&&(f["data-i18next-options"]=JSON.stringify({ns:S}))}return y?O.createElement(y,f,z(p||t,b,u)):z(p||t,b,u)}}]),t}(O.Component);B.propTypes={count:i.number,parent:i.oneOfType([i.node,i.func]),i18nKey:i.string,i18n:i.object,t:i.func},B.contextTypes={i18n:i.object,t:i.func};var F=function(e){function i(e,t){p(this,i);var n=b(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t));return n.i18n=e.i18n,n.defaultNS=e.defaultNS,e.initialI18nStore&&(n.i18n.services.resourceStore.data=e.initialI18nStore,n.i18n.options.isInitialSSR=!0),e.initialLanguage&&n.i18n.changeLanguage(e.initialLanguage),n.reportNS=e.reportNS,n}return g(i,e),m(i,[{key:"getChildContext",value:function(){return{i18n:this.i18n,defaultNS:this.defaultNS,reportNS:this.reportNS}}},{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 n.Children.only(e)}}]),i}(n.Component);F.propTypes={i18n:i.object.isRequired,children:i.element.isRequired,defaultNS:i.string,reportNS:i.func},F.childContextTypes={i18n:i.object.isRequired,defaultNS:i.string,reportNS:i.func},F.defaultProps={defaultNS:void 0,reportNS:void 0};var H=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 V(e){var t=[];return function(e,t){for(var n=0,i=e.length;n<i;n++)if("object"===j(e[n])){var r=!0,o=!1,a=void 0;try{for(var s,p=H(e[n])[Symbol.iterator]();!(r=(s=p.next()).done);r=!0){var c=S(s.value,2),u=c[0];t(c[1],n,u)}}catch(e){o=!0,a=e}finally{try{!r&&p.return&&p.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=E,e.I18n=C,e.Interpolate=R,e.Trans=B,e.I18nextProvider=F,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,i=V(t);return new Promise(function(e){n.loadNamespaces(i,e)})},e.reactI18nextModule=T,e.setDefaults=a,e.getDefaults=k,e.setI18n=s,e.getI18n=P,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
@@ -37,6 +37,7 @@ var I18nextProvider = function (_Component) {
|
|
|
37
37
|
if (props.initialLanguage) {
|
|
38
38
|
_this.i18n.changeLanguage(props.initialLanguage);
|
|
39
39
|
}
|
|
40
|
+
_this.reportNS = props.reportNS;
|
|
40
41
|
return _this;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -45,7 +46,8 @@ var I18nextProvider = function (_Component) {
|
|
|
45
46
|
value: function getChildContext() {
|
|
46
47
|
return {
|
|
47
48
|
i18n: this.i18n,
|
|
48
|
-
defaultNS: this.defaultNS
|
|
49
|
+
defaultNS: this.defaultNS,
|
|
50
|
+
reportNS: this.reportNS
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
}, {
|
|
@@ -70,16 +72,19 @@ var I18nextProvider = function (_Component) {
|
|
|
70
72
|
I18nextProvider.propTypes = {
|
|
71
73
|
i18n: _propTypes2.default.object.isRequired,
|
|
72
74
|
children: _propTypes2.default.element.isRequired,
|
|
73
|
-
defaultNS: _propTypes2.default.string
|
|
75
|
+
defaultNS: _propTypes2.default.string,
|
|
76
|
+
reportNS: _propTypes2.default.func
|
|
74
77
|
};
|
|
75
78
|
|
|
76
79
|
I18nextProvider.childContextTypes = {
|
|
77
80
|
i18n: _propTypes2.default.object.isRequired,
|
|
78
|
-
defaultNS: _propTypes2.default.string
|
|
81
|
+
defaultNS: _propTypes2.default.string,
|
|
82
|
+
reportNS: _propTypes2.default.func
|
|
79
83
|
};
|
|
80
84
|
|
|
81
85
|
I18nextProvider.defaultProps = {
|
|
82
|
-
defaultNS: undefined
|
|
86
|
+
defaultNS: undefined,
|
|
87
|
+
reportNS: undefined
|
|
83
88
|
};
|
|
84
89
|
|
|
85
90
|
exports.default = I18nextProvider;
|
|
@@ -66,6 +66,11 @@ function translate(namespaceArg) {
|
|
|
66
66
|
var i18nOptions = _this.i18n && _this.i18n.options && _this.i18n.options.react || {};
|
|
67
67
|
_this.options = _extends({}, (0, _context.getDefaults)(), i18nOptions, options);
|
|
68
68
|
|
|
69
|
+
if (context.reportNS) {
|
|
70
|
+
var namespaces = _this.namespaces || [undefined];
|
|
71
|
+
namespaces.forEach(context.reportNS);
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
_this.getWrappedInstance = _this.getWrappedInstance.bind(_this);
|
|
70
75
|
return _this;
|
|
71
76
|
}
|
|
@@ -121,7 +126,8 @@ function translate(namespaceArg) {
|
|
|
121
126
|
|
|
122
127
|
Translate.contextTypes = {
|
|
123
128
|
i18n: _propTypes2.default.object,
|
|
124
|
-
defaultNS: _propTypes2.default.string
|
|
129
|
+
defaultNS: _propTypes2.default.string,
|
|
130
|
+
reportNS: _propTypes2.default.func
|
|
125
131
|
};
|
|
126
132
|
|
|
127
133
|
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
|
|
@@ -26,6 +26,7 @@ var I18nextProvider = function (_Component) {
|
|
|
26
26
|
if (props.initialLanguage) {
|
|
27
27
|
_this.i18n.changeLanguage(props.initialLanguage);
|
|
28
28
|
}
|
|
29
|
+
_this.reportNS = props.reportNS;
|
|
29
30
|
return _this;
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -34,7 +35,8 @@ var I18nextProvider = function (_Component) {
|
|
|
34
35
|
value: function getChildContext() {
|
|
35
36
|
return {
|
|
36
37
|
i18n: this.i18n,
|
|
37
|
-
defaultNS: this.defaultNS
|
|
38
|
+
defaultNS: this.defaultNS,
|
|
39
|
+
reportNS: this.reportNS
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
}, {
|
|
@@ -59,16 +61,19 @@ var I18nextProvider = function (_Component) {
|
|
|
59
61
|
I18nextProvider.propTypes = {
|
|
60
62
|
i18n: PropTypes.object.isRequired,
|
|
61
63
|
children: PropTypes.element.isRequired,
|
|
62
|
-
defaultNS: PropTypes.string
|
|
64
|
+
defaultNS: PropTypes.string,
|
|
65
|
+
reportNS: PropTypes.func
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
I18nextProvider.childContextTypes = {
|
|
66
69
|
i18n: PropTypes.object.isRequired,
|
|
67
|
-
defaultNS: PropTypes.string
|
|
70
|
+
defaultNS: PropTypes.string,
|
|
71
|
+
reportNS: PropTypes.func
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
I18nextProvider.defaultProps = {
|
|
71
|
-
defaultNS: undefined
|
|
75
|
+
defaultNS: undefined,
|
|
76
|
+
reportNS: undefined
|
|
72
77
|
};
|
|
73
78
|
|
|
74
79
|
export default I18nextProvider;
|
package/dist/es/translate.js
CHANGED
|
@@ -41,6 +41,11 @@ export default function translate(namespaceArg) {
|
|
|
41
41
|
var i18nOptions = _this.i18n && _this.i18n.options && _this.i18n.options.react || {};
|
|
42
42
|
_this.options = _extends({}, getDefaults(), i18nOptions, options);
|
|
43
43
|
|
|
44
|
+
if (context.reportNS) {
|
|
45
|
+
var namespaces = _this.namespaces || [undefined];
|
|
46
|
+
namespaces.forEach(context.reportNS);
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
_this.getWrappedInstance = _this.getWrappedInstance.bind(_this);
|
|
45
50
|
return _this;
|
|
46
51
|
}
|
|
@@ -96,7 +101,8 @@ export default function translate(namespaceArg) {
|
|
|
96
101
|
|
|
97
102
|
Translate.contextTypes = {
|
|
98
103
|
i18n: PropTypes.object,
|
|
99
|
-
defaultNS: PropTypes.string
|
|
104
|
+
defaultNS: PropTypes.string,
|
|
105
|
+
reportNS: PropTypes.func
|
|
100
106
|
};
|
|
101
107
|
|
|
102
108
|
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
|
|
@@ -7,31 +7,32 @@
|
|
|
7
7
|
var React__default = 'default' in React ? React['default'] : React;
|
|
8
8
|
PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes;
|
|
9
9
|
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Copyright 2015, Yahoo! Inc.
|
|
12
14
|
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
13
15
|
*/
|
|
14
|
-
'use strict';
|
|
15
|
-
|
|
16
16
|
var REACT_STATICS = {
|
|
17
17
|
childContextTypes: true,
|
|
18
18
|
contextTypes: true,
|
|
19
19
|
defaultProps: true,
|
|
20
20
|
displayName: true,
|
|
21
21
|
getDefaultProps: true,
|
|
22
|
+
getDerivedStateFromProps: true,
|
|
22
23
|
mixins: true,
|
|
23
24
|
propTypes: true,
|
|
24
25
|
type: true
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
var KNOWN_STATICS = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
name: true,
|
|
30
|
+
length: true,
|
|
31
|
+
prototype: true,
|
|
32
|
+
caller: true,
|
|
33
|
+
callee: true,
|
|
34
|
+
arguments: true,
|
|
35
|
+
arity: true
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
var defineProperty = Object.defineProperty;
|
|
@@ -41,7 +42,7 @@ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
|
41
42
|
var getPrototypeOf = Object.getPrototypeOf;
|
|
42
43
|
var objectPrototype = getPrototypeOf && getPrototypeOf(Object);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
|
45
46
|
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
|
|
46
47
|
|
|
47
48
|
if (objectPrototype) {
|
|
@@ -71,7 +72,9 @@ var hoistNonReactStatics = function hoistNonReactStatics(targetComponent, source
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
return targetComponent;
|
|
74
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
|
75
78
|
|
|
76
79
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
77
80
|
return typeof obj;
|
|
@@ -619,6 +622,11 @@ function translate(namespaceArg) {
|
|
|
619
622
|
var i18nOptions = _this.i18n && _this.i18n.options && _this.i18n.options.react || {};
|
|
620
623
|
_this.options = _extends({}, getDefaults(), i18nOptions, options);
|
|
621
624
|
|
|
625
|
+
if (context.reportNS) {
|
|
626
|
+
var namespaces = _this.namespaces || [undefined];
|
|
627
|
+
namespaces.forEach(context.reportNS);
|
|
628
|
+
}
|
|
629
|
+
|
|
622
630
|
_this.getWrappedInstance = _this.getWrappedInstance.bind(_this);
|
|
623
631
|
return _this;
|
|
624
632
|
}
|
|
@@ -672,14 +680,15 @@ function translate(namespaceArg) {
|
|
|
672
680
|
|
|
673
681
|
Translate.contextTypes = {
|
|
674
682
|
i18n: PropTypes.object,
|
|
675
|
-
defaultNS: PropTypes.string
|
|
683
|
+
defaultNS: PropTypes.string,
|
|
684
|
+
reportNS: PropTypes.func
|
|
676
685
|
};
|
|
677
686
|
|
|
678
687
|
Translate.displayName = 'Translate(' + getDisplayName(WrappedComponent) + ')';
|
|
679
688
|
|
|
680
689
|
Translate.namespaces = namespaceArg;
|
|
681
690
|
|
|
682
|
-
return
|
|
691
|
+
return hoistNonReactStatics_cjs(Translate, WrappedComponent);
|
|
683
692
|
};
|
|
684
693
|
}
|
|
685
694
|
|
|
@@ -1170,6 +1179,7 @@ var I18nextProvider = function (_Component) {
|
|
|
1170
1179
|
if (props.initialLanguage) {
|
|
1171
1180
|
_this.i18n.changeLanguage(props.initialLanguage);
|
|
1172
1181
|
}
|
|
1182
|
+
_this.reportNS = props.reportNS;
|
|
1173
1183
|
return _this;
|
|
1174
1184
|
}
|
|
1175
1185
|
|
|
@@ -1178,7 +1188,8 @@ var I18nextProvider = function (_Component) {
|
|
|
1178
1188
|
value: function getChildContext() {
|
|
1179
1189
|
return {
|
|
1180
1190
|
i18n: this.i18n,
|
|
1181
|
-
defaultNS: this.defaultNS
|
|
1191
|
+
defaultNS: this.defaultNS,
|
|
1192
|
+
reportNS: this.reportNS
|
|
1182
1193
|
};
|
|
1183
1194
|
}
|
|
1184
1195
|
}, {
|
|
@@ -1202,16 +1213,19 @@ var I18nextProvider = function (_Component) {
|
|
|
1202
1213
|
I18nextProvider.propTypes = {
|
|
1203
1214
|
i18n: PropTypes.object.isRequired,
|
|
1204
1215
|
children: PropTypes.element.isRequired,
|
|
1205
|
-
defaultNS: PropTypes.string
|
|
1216
|
+
defaultNS: PropTypes.string,
|
|
1217
|
+
reportNS: PropTypes.func
|
|
1206
1218
|
};
|
|
1207
1219
|
|
|
1208
1220
|
I18nextProvider.childContextTypes = {
|
|
1209
1221
|
i18n: PropTypes.object.isRequired,
|
|
1210
|
-
defaultNS: PropTypes.string
|
|
1222
|
+
defaultNS: PropTypes.string,
|
|
1223
|
+
reportNS: PropTypes.func
|
|
1211
1224
|
};
|
|
1212
1225
|
|
|
1213
1226
|
I18nextProvider.defaultProps = {
|
|
1214
|
-
defaultNS: undefined
|
|
1227
|
+
defaultNS: undefined,
|
|
1228
|
+
reportNS: undefined
|
|
1215
1229
|
};
|
|
1216
1230
|
|
|
1217
1231
|
var objectEntries = Object.entries || function (obj) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.reactI18next={},e.React,e.PropTypes)}(this,function(e,t,n){"use strict";function i(e,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=R({},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){N(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||r.defaultNS||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=R({},a(),s,i),o.getWrappedInstance=o.getWrappedInstance.bind(o),o}return A(n,t),E(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}),S.createElement(B,R({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(n,i){var r=i.ready,a=L(i,["ready"]);return S.createElement(o,R({tReady:r},e.props,t,a))})}}]),n}(t.Component);return s.WrappedComponent=o,s.contextTypes={i18n:n.object,defaultNS:n.string},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 d(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(d,"")+"</"+t.name+">"}}function h(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(h(t))e=e+"<"+i+">"+v("",y(t),n+1)+"</"+i+">";else if(S.isValidElement(t))e=e+"<"+i+"></"+i+">";else if("object"===(void 0===t?"undefined":C(t))){var r=R({},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=S.isValidElement(a);if("string"==typeof a)t.push(a);else if(h(a)){var c=i(y(a),r.children);a.dummy&&(a.children=c),t.push(S.cloneElement(a,R({},a.props,{key:o}),c))}else if("object"!==(void 0===a?"undefined":C(a))||s)t.push(a);else if(r.children[0]?r.children[0].content:null){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=Z(e[n])[Symbol.iterator]();!(r=(s=c.next()).done);r=!0){var p=q(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 S="default"in t?t.default:t;n=n&&n.hasOwnProperty("default")?n.default:n;var O={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},j={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(!(O[s]||j[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},N=(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")}),E=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}}(),R=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},q=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,omitBoundRerender:!0},M=void 0,$={type:"3rdParty",init:function(e){o(e.options.react),s(e)}},z=!1,B=function(e){function t(e,n){N(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=R({},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),E(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.state.ready&&this.options.omitBoundRerender||(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);B.contextTypes={i18n:n.object},B.childContextTypes={t:n.func.isRequired,i18n:n.object},u.setDefaults=o,u.setI18n=s;var H=function(e){function t(e,n){N(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),E(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=R({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),p=this.t(this.props.i18nKey,c);if(!p||"string"!=typeof p)return S.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?S.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 d="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&&(d=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0]),this.t.ns&&(f["data-i18next-options"]=JSON.stringify({ns:d}))}return r&&(f.className=r),o&&(f.style=o),S.createElement.apply(this,[t,f].concat(u))}}]),t}(t.Component);H.propTypes={className:n.string},H.defaultProps={className:""},H.contextTypes={i18n:n.object.isRequired,t:n.func.isRequired};var V={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},F=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,J=function(e){var t,n=0,i=!0,r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(F,function(o){if("="===o)return i=!0,void n++;i?0===n?((V[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},U=/(?:<!--[\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(U,function(s,c){if(a){if(s!=="</"+n.name+">")return;a=!1}var p,u="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),d=c+s.length,h=e.charAt(d);u&&!f&&(r++,"tag"===(n=J(s)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!h||"<"===h||l(n.children,e,r,d,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&&"<"!==h&&h&&l(p=-1===r?i:o[r].children,e,r,d,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+d("",t)},"")}},X=function(e){function t(){return N(this,t),W(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return A(t,e),E(t,[{key:"render",value:function(){var e=R({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"]),d=l||u.t.bind(u),h=u.options&&u.options.react||{},y=void 0!==i?i:h.defaultTransParent,g=s||v("",t,0),b=h.hashTransKey,O=r||(b?b(g):g),j=O?d(O,R({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:g,count:n,ns:p})):g;if(h.exposeNamespace){var w="string"==typeof d.ns?d.ns:d.ns[0];r&&u.options&&u.options.nsSeparator&&r.indexOf(u.options.nsSeparator)>-1&&(w=r.split(u.options.nsSeparator)[0]),d.ns&&(f["data-i18next-options"]=JSON.stringify({ns:w}))}return y?S.createElement(y,f,m(c||t,j,u)):m(c||t,j,u)}}]),t}(S.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,t:n.func};var Y=function(e){function n(e,t){N(this,n);var i=W(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e,t));return i.i18n=e.i18n,i.defaultNS=e.defaultNS,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),E(n,[{key:"getChildContext",value:function(){return{i18n:this.i18n,defaultNS:this.defaultNS}}},{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,defaultNS:n.string},Y.childContextTypes={i18n:n.object.isRequired,defaultNS:n.string},Y.defaultProps={defaultNS:void 0};var Z=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=B,e.Interpolate=H,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})});
|
|
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,n,r){"use strict";var O="default"in n?n.default:n;r=r&&r.hasOwnProperty("default")?r.default:r;var c={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},u={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l=Object.defineProperty,f=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,h=Object.getOwnPropertyDescriptor,y=Object.getPrototypeOf,v=y&&y(Object);var i=function e(t,n,r){if("string"!=typeof n){if(v){var i=y(n);i&&i!==v&&e(t,i,r)}var o=f(n);d&&(o=o.concat(d(n)));for(var a=0;a<o.length;++a){var s=o[a];if(!(c[s]||u[s]||r&&r[s])){var p=h(n,s);try{l(t,s,p)}catch(e){}}}return t}return t},j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p=(function(){function c(e){this.value=e}function e(i){var o,a;function s(e,t){try{var n=i[e](t),r=n.value;r instanceof c?Promise.resolve(r.value).then(function(e){s("next",e)},function(e){s("throw",e)}):p(n.done?"return":"normal",n.value)}catch(e){p("throw",e)}}function p(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?s(o.key,o.arg):a=null}this._invoke=function(r,i){return new Promise(function(e,t){var n={key:r,arg:i,resolve:e,reject:t,next:null};a?a=a.next=n:(o=a=n,s(r,i))})},"function"!=typeof i.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(e){return this._invoke("next",e)},e.prototype.throw=function(e){return this._invoke("throw",e)},e.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")}),m=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),w=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g=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)},x=function(e,t){var n={};for(var r in e)0<=t.indexOf(r)||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);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},S=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},I=Object.prototype.hasOwnProperty;function N(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}var t={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1,omitBoundRerender:!0},o=void 0;function a(e){t=w({},t,e)}function k(){return t}function s(e){o=e}function P(){return o}var T={type:"3rdParty",init:function(e){a(e.options.react),s(e)}},_=!1,C=function(e){function a(e,t){p(this,a);var n=b(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e,t));n.i18n=e.i18n||t.i18n||P(),n.namespaces=e.ns||n.i18n.options&&n.i18n.options.defaultNS,"string"==typeof n.namespaces&&(n.namespaces=[n.namespaces]);var r=n.i18n&&n.i18n.options&&n.i18n.options.react||{};n.options=w({},k(),r,e),e.initialI18nStore&&(n.i18n.services.resourceStore.data=e.initialI18nStore,n.options.wait=!1),e.initialLanguage&&n.i18n.changeLanguage(e.initialLanguage),n.i18n.options&&n.i18n.options.isInitialSSR&&(n.options.wait=!1);var i=n.i18n.languages&&n.i18n.languages[0],o=!!i&&n.namespaces.every(function(e){return n.i18n.hasResourceBundle(i,e)});return n.state={i18nLoadedAt:null,ready:o},n.t=n.getI18nTranslate(),n.onI18nChanged=n.onI18nChanged.bind(n),n.getI18nTranslate=n.getI18nTranslate.bind(n),n}return g(a,e),m(a,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var n=this,e=function(){n.options.bindI18n&&n.i18n&&n.i18n.on(n.options.bindI18n,n.onI18nChanged),n.options.bindStore&&n.i18n.store&&n.i18n.store.on(n.options.bindStore,n.onI18nChanged)};this.mounted=!0,this.i18n.loadNamespaces(this.namespaces,function(){var t=function(){n.mounted&&!n.state.ready&&n.setState({ready:!0}),n.options.wait&&n.mounted&&e()};if(n.i18n.isInitialized)t();else{n.i18n.on("initialized",function e(){setTimeout(function(){n.i18n.off("initialized",e)},1e3),t()})}}),this.options.wait||e()}},{key:"componentWillUnmount",value:function(){var t=this;if(this.mounted=!1,this.onI18nChanged){if(this.options.bindI18n)this.options.bindI18n.split(" ").forEach(function(e){return t.i18n.off(e,t.onI18nChanged)});if(this.options.bindStore)this.options.bindStore.split(" ").forEach(function(e){return t.i18n.store&&t.i18n.store.off(e,t.onI18nChanged)})}}},{key:"onI18nChanged",value:function(){this.mounted&&(!this.state.ready&&this.options.omitBoundRerender||(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&&!_&&(_=!0,setTimeout(function(){delete e.i18n.options.isInitialSSR},100)),t(this.t,{i18n:this.i18n,t:this.t,ready:n}))}}]),a}(n.Component);function E(o){var s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return function(a){var e,t=function(e){function i(e,t){p(this,i);var n=b(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t));n.i18n=e.i18n||s.i18n||t.i18n||P(),n.namespaces="function"==typeof o?o(e):o||t.defaultNS||n.i18n.options&&n.i18n.options.defaultNS,"string"==typeof n.namespaces&&(n.namespaces=[n.namespaces]);var r=n.i18n&&n.i18n.options&&n.i18n.options.react||{};(n.options=w({},k(),r,s),t.reportNS)&&(n.namespaces||[void 0]).forEach(t.reportNS);return n.getWrappedInstance=n.getWrappedInstance.bind(n),n}return g(i,e),m(i,[{key:"shouldComponentUpdate",value:function(e){return!this.options.usePureComponent||!function(e,t){if(N(e,t))return!0;if("object"!==(void 0===e?"undefined":j(e))||null===e||"object"!==(void 0===t?"undefined":j(t))||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var i=0;i<n.length;i++)if(!I.call(t,n[i])||!N(e[n[i]],t[n[i]]))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 i=this,o={};return this.options.withRef&&(o.ref=function(e){i.wrappedInstance=e}),O.createElement(C,w({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(e,t){var n=t.ready,r=x(t,["ready"]);return O.createElement(a,w({tReady:n},i.props,o,r))})}}]),i}(n.Component);return t.WrappedComponent=a,t.contextTypes={i18n:r.object,defaultNS:r.string,reportNS:r.func},t.displayName="Translate("+((e=a).displayName||e.name||"Component")+")",t.namespaces=o,i(t,a)}}C.contextTypes={i18n:r.object},C.childContextTypes={t:r.func.isRequired,i18n:r.object},E.setDefaults=a,E.setI18n=s;var R=function(e){function r(e,t){p(this,r);var n=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t));return n.i18n=e.i18n||t.i18n,n.t=e.t||t.t,n}return g(r,e),m(r,[{key:"render",value:function(){var o=this,e=this.props.parent||"span",t=this.props.regexp||this.i18n.services.interpolator.regexp,n=this.props,r=n.className,i=n.style,a=this.props.useDangerouslySetInnerHTML||!1,s=this.props.dangerouslySetInnerHTMLPartElement||"span",p=w({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,p);if(!c||"string"!=typeof c)return O.createElement("noscript",null);var u=[];c.split(t).reduce(function(e,t,n){var r=void 0;if(n%2==0){if(0===t.length)return e;r=a?O.createElement(s,{dangerouslySetInnerHTML:{__html:t}}):t}else r=function(e,t){if(e.indexOf(o.i18n.options.interpolation.formatSeparator)<0)return void 0===t[e]&&o.i18n.services.logger.warn("interpolator: missed to pass in variable "+e+" for interpolating "+c),t[e];var n=e.split(o.i18n.options.interpolation.formatSeparator),r=n.shift().trim(),i=n.join(o.i18n.options.interpolation.formatSeparator).trim();return void 0===t[r]&&o.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),o.i18n.options.interpolation.format(t[r],i,o.i18n.language)}(t,o.props);return e.push(r),e},u);var l={};if(this.i18n.options.react&&this.i18n.options.react.exposeNamespace){var f="string"==typeof this.t.ns?this.t.ns:this.t.ns[0];if(this.props.i18nKey&&this.i18n.options.nsSeparator&&-1<this.props.i18nKey.indexOf(this.i18n.options.nsSeparator))f=this.props.i18nKey.split(this.i18n.options.nsSeparator)[0];this.t.ns&&(l["data-i18next-options"]=JSON.stringify({ns:f}))}return r&&(l.className=r),i&&(l.style=i),O.createElement.apply(this,[e,l].concat(u))}}]),r}(n.Component);R.propTypes={className:r.string},R.defaultProps={className:""},R.contextTypes={i18n:r.object.isRequired,t:r.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,D=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,W=Object.create?Object.create(null):{};function q(e,t,n,r,i){var o=t.indexOf("<",r),a=t.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&-1<o&&0<=n+e.length||" "!==a)&&e.push({type:"text",content:a})}var K=function(f,d){d||(d={}),d.components||(d.components=W);var h,y=[],v=-1,m=[],g=!1;return f.replace(D,function(e,t){if(g){if(e!=="</"+h.name+">")return;g=!1}var n,r,i,o,a,s,p="/"!==e.charAt(1),c=0===e.indexOf("\x3c!--"),u=t+e.length,l=f.charAt(u);p&&!c&&(v++,s={type:"tag",name:"",voidElement:!(a=!(o=0)),attrs:{},children:[]},(r=e).replace(L,function(e){if("="===e)return a=!0,void o++;a?0===o?((A[e]||"/"===r.charAt(r.length-2))&&(s.voidElement=!0),s.name=e):(s.attrs[i]=e.replace(/^['"]|['"]$/g,""),i=void 0):(i&&(s.attrs[i]=i),i=e),o++,a=!1}),"tag"===(h=s).type&&d.components[h.name]&&(h.type="component",g=!0),h.voidElement||g||!l||"<"===l||q(h.children,f,v,u,d.ignoreWhitespace),0===v&&y.push(h),(n=m[v-1])&&n.children.push(h),m[v]=h),(c||!p||h.voidElement)&&(c||v--,!g&&"<"!==l&&l&&q(n=-1===v?y:m[v].children,f,v,u,d.ignoreWhitespace))}),!y.length&&f.length&&q(y,f,0,0,d.ignoreWhitespace),y};function M(e){return e&&(e.children||e.props&&e.props.children)}function $(e){return e&&e.children?e.children:e.props&&e.props.children}function z(e,t,c){if(""===t)return[];if(!e)return[t];return $(function s(p,e){return"[object Array]"!==Object.prototype.toString.call(p)&&(p=[p]),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.reduce(function(e,t,n){if("tag"===t.type){var r=p[parseInt(t.name,10)]||{},i=O.isValidElement(r);if("string"==typeof r)e.push(r);else if(M(r)){var o=s($(r),t.children);r.dummy&&(r.children=o),e.push(O.cloneElement(r,w({},r.props,{key:n}),o))}else if("object"!==(void 0===r?"undefined":j(r))||i)e.push(r);else if(t.children[0]&&t.children[0].content){var a=c.services.interpolator.interpolate(t.children[0].content,r,c.language);e.push(a)}}else"text"===t.type&&e.push(t.content);return e},[])}([{dummy:!0,children:e}],K("<0>"+t+"</0>"))[0])}var B=function(e){function t(){return p(this,t),b(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return g(t,e),m(t,[{key:"render",value:function(){var e=w({i18n:this.context.i18n,t:this.context.t},this.props),t=e.children,n=e.count,r=e.parent,i=e.i18nKey,o=e.tOptions,a=e.values,s=e.defaults,p=e.components,c=e.ns,u=e.i18n,l=e.t,f=x(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),d=l||u.t.bind(u),h=u.options&&u.options.react||{},y=void 0!==r?r:h.defaultTransParent,v=s||function a(s,e,t){return e?("[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),e.forEach(function(e,t){var n=""+t;if("string"==typeof e)s=""+s+e;else if(M(e))s=s+"<"+n+">"+a("",$(e),t+1)+"</"+n+">";else if(O.isValidElement(e))s=s+"<"+n+"></"+n+">";else if("object"===(void 0===e?"undefined":j(e))){var r=w({},e),i=r.format;delete r.format;var o=Object.keys(r);i&&1===o.length?s=s+"<"+n+">{{"+o[0]+", "+i+"}}</"+n+">":1===o.length?s=s+"<"+n+">{{"+o[0]+"}}</"+n+">":console&&console.warn&&console.warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",e)}else console&&console.warn&&console.warn("react-i18next: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",e)}),s):""}("",t),m=h.hashTransKey,g=i||(m?m(v):v),b=g?d(g,w({},o,a,a?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:v,count:n,ns:c})):v;if(h.exposeNamespace){var S="string"==typeof d.ns?d.ns:d.ns[0];if(i&&u.options&&u.options.nsSeparator&&-1<i.indexOf(u.options.nsSeparator))S=i.split(u.options.nsSeparator)[0];d.ns&&(f["data-i18next-options"]=JSON.stringify({ns:S}))}return y?O.createElement(y,f,z(p||t,b,u)):z(p||t,b,u)}}]),t}(O.Component);B.propTypes={count:r.number,parent:r.oneOfType([r.node,r.func]),i18nKey:r.string,i18n:r.object,t:r.func},B.contextTypes={i18n:r.object,t:r.func};var F=function(e){function r(e,t){p(this,r);var n=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t));return n.i18n=e.i18n,n.defaultNS=e.defaultNS,e.initialI18nStore&&(n.i18n.services.resourceStore.data=e.initialI18nStore,n.i18n.options.isInitialSSR=!0),e.initialLanguage&&n.i18n.changeLanguage(e.initialLanguage),n.reportNS=e.reportNS,n}return g(r,e),m(r,[{key:"getChildContext",value:function(){return{i18n:this.i18n,defaultNS:this.defaultNS,reportNS:this.reportNS}}},{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 n.Children.only(e)}}]),r}(n.Component);F.propTypes={i18n:r.object.isRequired,children:r.element.isRequired,defaultNS:r.string,reportNS:r.func},F.childContextTypes={i18n:r.object.isRequired,defaultNS:r.string,reportNS:r.func},F.defaultProps={defaultNS:void 0,reportNS:void 0};var H=Object.entries||function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r};function V(e){var t=[];return function(e,t){for(var n=0,r=e.length;n<r;n++)if("object"===j(e[n])){var i=!0,o=!1,a=void 0;try{for(var s,p=H(e[n])[Symbol.iterator]();!(i=(s=p.next()).done);i=!0){var c=S(s.value,2),u=c[0];t(c[1],n,u)}}catch(e){o=!0,a=e}finally{try{!i&&p.return&&p.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=E,e.I18n=C,e.Interpolate=R,e.Trans=B,e.I18nextProvider=F,e.loadNamespaces=function(e){var t=e.components,n=e.i18n,r=V(t);return new Promise(function(e){n.loadNamespaces(r,e)})},e.reactI18nextModule=T,e.setDefaults=a,e.getDefaults=k,e.setI18n=s,e.getI18n=P,Object.defineProperty(e,"__esModule",{value:!0})});
|