react-i18next 7.9.0 → 7.11.0
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 +36 -19
- package/dist/amd/react-i18next.min.js +1 -1
- package/dist/commonjs/I18nextProvider.js +9 -4
- package/dist/commonjs/Trans.js +5 -2
- package/dist/commonjs/translate.js +7 -1
- package/dist/es/I18nextProvider.js +9 -4
- package/dist/es/Trans.js +5 -2
- package/dist/es/translate.js +7 -1
- package/dist/umd/react-i18next.js +36 -19
- package/dist/umd/react-i18next.min.js +1 -1
- package/icu.macro.js +331 -0
- package/package.json +15 -9
- package/react-i18next.js +36 -19
- package/react-i18next.min.js +1 -1
- package/src/I18nextProvider.js +9 -4
- package/src/Trans.js +5 -2
- package/src/context.js +2 -2
- package/src/translate.js +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
### 7.11.0
|
|
2
|
+
|
|
3
|
+
- Added reportNS function to I18NextProvider to report used namespaces [500](https://github.com/i18next/react-i18next/pull/500)
|
|
4
|
+
|
|
5
|
+
### 7.10.1
|
|
6
|
+
|
|
7
|
+
- fix small issue in icu.macro introduced on refactoring
|
|
8
|
+
|
|
9
|
+
### 7.10.0
|
|
10
|
+
|
|
11
|
+
- 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)
|
|
12
|
+
|
|
13
|
+
### 7.9.1
|
|
14
|
+
|
|
15
|
+
- Skip custom html tags in Trans component translation [PR482](https://github.com/i18next/react-i18next/pull/482)
|
|
16
|
+
|
|
1
17
|
### 7.9.0
|
|
2
18
|
|
|
3
19
|
- Support defaultNS from I18nextProvider props [PR478](https://github.com/i18next/react-i18next/pull/478)
|
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 = Array.isArray(namespaceArg) ? namespaceArg : [namespaceArg];
|
|
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
|
|
|
@@ -1057,8 +1066,11 @@ function renderNodes(children, targetString, i18n) {
|
|
|
1057
1066
|
if (child.dummy) child.children = inner; // needed on preact!
|
|
1058
1067
|
mem.push(React__default.cloneElement(child, _extends({}, child.props, { key: i }), inner));
|
|
1059
1068
|
} else if ((typeof child === 'undefined' ? 'undefined' : _typeof(child)) === 'object' && !isElement) {
|
|
1060
|
-
var
|
|
1061
|
-
|
|
1069
|
+
var content = node.children[0] ? node.children[0].content : null;
|
|
1070
|
+
if (content) {
|
|
1071
|
+
var interpolated = i18n.services.interpolator.interpolate(node.children[0].content, child, i18n.language);
|
|
1072
|
+
mem.push(interpolated);
|
|
1073
|
+
}
|
|
1062
1074
|
} else {
|
|
1063
1075
|
mem.push(child);
|
|
1064
1076
|
}
|
|
@@ -1163,6 +1175,7 @@ var I18nextProvider = function (_Component) {
|
|
|
1163
1175
|
if (props.initialLanguage) {
|
|
1164
1176
|
_this.i18n.changeLanguage(props.initialLanguage);
|
|
1165
1177
|
}
|
|
1178
|
+
_this.reportNS = props.reportNS;
|
|
1166
1179
|
return _this;
|
|
1167
1180
|
}
|
|
1168
1181
|
|
|
@@ -1171,7 +1184,8 @@ var I18nextProvider = function (_Component) {
|
|
|
1171
1184
|
value: function getChildContext() {
|
|
1172
1185
|
return {
|
|
1173
1186
|
i18n: this.i18n,
|
|
1174
|
-
defaultNS: this.defaultNS
|
|
1187
|
+
defaultNS: this.defaultNS,
|
|
1188
|
+
reportNS: this.reportNS
|
|
1175
1189
|
};
|
|
1176
1190
|
}
|
|
1177
1191
|
}, {
|
|
@@ -1195,16 +1209,19 @@ var I18nextProvider = function (_Component) {
|
|
|
1195
1209
|
I18nextProvider.propTypes = {
|
|
1196
1210
|
i18n: PropTypes.object.isRequired,
|
|
1197
1211
|
children: PropTypes.element.isRequired,
|
|
1198
|
-
defaultNS: PropTypes.string
|
|
1212
|
+
defaultNS: PropTypes.string,
|
|
1213
|
+
reportNS: PropTypes.func
|
|
1199
1214
|
};
|
|
1200
1215
|
|
|
1201
1216
|
I18nextProvider.childContextTypes = {
|
|
1202
1217
|
i18n: PropTypes.object.isRequired,
|
|
1203
|
-
defaultNS: PropTypes.string
|
|
1218
|
+
defaultNS: PropTypes.string,
|
|
1219
|
+
reportNS: PropTypes.func
|
|
1204
1220
|
};
|
|
1205
1221
|
|
|
1206
1222
|
I18nextProvider.defaultProps = {
|
|
1207
|
-
defaultNS: undefined
|
|
1223
|
+
defaultNS: undefined,
|
|
1224
|
+
reportNS: undefined
|
|
1208
1225
|
};
|
|
1209
1226
|
|
|
1210
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 u(){return q}function c(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||u(),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("+c(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 u=i(y(a),r.children);a.dummy&&(a.children=u),e.push(S.cloneElement(a,R({},a.props,{key:o}),u))}else if("object"!==(void 0===a?"undefined":C(a))||s)e.push(a);else{var c=n.services.interpolator.interpolate(r.children[0].content,a,n.language);e.push(c)}}else"text"===r.type&&e.push(r.content);return e},[])}return""===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,u=Z(t[n])[Symbol.iterator]();!(r=(s=u.next()).done);r=!0){var c=D(s.value,2),p=c[0];e(c[1],n,p)}}catch(t){o=!0,a=t}finally{try{!r&&u.return&&u.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 u=k(n,s);try{w(e,s,u)}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||u(),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",u=R({},this.props.options,{interpolation:{prefix:"#$?",suffix:"?$#"}}),c=this.t(this.props.i18nKey,u);if(!c||"string"!=typeof c)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 "+c),n[e];var i=e.split(t.i18n.options.interpolation.formatSeparator),r=i.shift().trim(),o=i.join(t.i18n.options.interpolation.formatSeparator).trim();return void 0===n[r]&&t.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),t.i18n.options.interpolation.format(n[r],o,t.i18n.language)};c.split(n).reduce(function(e,n,i){var r=void 0;if(i%2==0){if(0===n.length)return e;r=a?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,u){if(a){if(s!=="</"+n.name+">")return;a=!1}var c,p="/"!==s.charAt(1),f=0===s.indexOf("\x3c!--"),h=u+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),(c=o[r-1])&&c.children.push(n),o[r]=n),(f||!p||n.voidElement)&&(f||r--,!a&&"<"!==d&&d&&l(c=-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,u=t.components,c=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:c})):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(u||e,j,p)):m(u||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=u,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
define(["exports","react","prop-types"],function(t,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,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,y=Object.getPrototypeOf,v=y&&y(Object);var i=function t(e,n,r){if("string"!=typeof n){if(v){var i=y(n);i&&i!==v&&t(e,i,r)}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]||r&&r[s])){var p=d(n,s);try{l(e,s,p)}catch(t){}}}return e}return e},j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p=(function(){function c(t){this.value=t}function t(i){var o,a;function s(t,e){try{var n=i[t](e),r=n.value;r instanceof c?Promise.resolve(r.value).then(function(t){s("next",t)},function(t){s("throw",t)}):p(n.done?"return":"normal",n.value)}catch(t){p("throw",t)}}function p(t,e){switch(t){case"return":o.resolve({value:e,done:!0});break;case"throw":o.reject(e);break;default:o.resolve({value:e,done:!1})}(o=o.next)?s(o.key,o.arg):a=null}this._invoke=function(r,i){return new Promise(function(t,e){var n={key:r,arg:i,resolve:t,reject:e,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&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(t){return this._invoke("next",t)},t.prototype.throw=function(t){return this._invoke("throw",t)},t.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")}),m=function(){function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}}(),w=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},g=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)},x=function(t,e){var n={};for(var r in t)0<=e.indexOf(r)||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},b=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},S=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},I=Object.prototype.hasOwnProperty;function N(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!=t&&e!=e}var e={wait:!1,withRef:!1,bindI18n:"languageChanged loaded",bindStore:"added removed",translateFuncName:"t",nsMode:"default",usePureComponent:!1,omitBoundRerender:!0},o=void 0;function a(t){e=w({},e,t)}function k(){return e}function s(t){o=t}function P(){return o}var T={type:"3rdParty",init:function(t){a(t.options.react),s(t)}},_=!1,C=function(t){function a(t,e){p(this,a);var n=b(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,t,e));n.i18n=t.i18n||e.i18n||P(),n.namespaces=t.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,t),t.initialI18nStore&&(n.i18n.services.resourceStore.data=t.initialI18nStore,n.options.wait=!1),t.initialLanguage&&n.i18n.changeLanguage(t.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(t){return n.i18n.hasResourceBundle(i,t)});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,t),m(a,[{key:"getChildContext",value:function(){return{t:this.t,i18n:this.i18n}}},{key:"componentDidMount",value:function(){var n=this,t=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 e=function(){n.mounted&&!n.state.ready&&n.setState({ready:!0}),n.options.wait&&n.mounted&&t()};if(n.i18n.isInitialized)e();else{n.i18n.on("initialized",function t(){setTimeout(function(){n.i18n.off("initialized",t)},1e3),e()})}}),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.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&&!_&&(_=!0,setTimeout(function(){delete t.i18n.options.isInitialSSR},100)),e(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 t,e=function(t){function i(t,e){p(this,i);var n=b(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));n.i18n=t.i18n||s.i18n||e.i18n||P(),n.namespaces="function"==typeof o?o(t):o||e.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),e.reportNS)&&(Array.isArray(o)?o:[o]).forEach(e.reportNS);return n.getWrappedInstance=n.getWrappedInstance.bind(n),n}return g(i,t),m(i,[{key:"shouldComponentUpdate",value:function(t){return!this.options.usePureComponent||!function(t,e){if(N(t,e))return!0;if("object"!==(void 0===t?"undefined":j(t))||null===t||"object"!==(void 0===e?"undefined":j(e))||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=0;i<n.length;i++)if(!I.call(e,n[i])||!N(t[n[i]],e[n[i]]))return!1;return!0}(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 i=this,o={};return this.options.withRef&&(o.ref=function(t){i.wrappedInstance=t}),O.createElement(C,w({ns:this.namespaces},this.options,this.props,{i18n:this.i18n}),function(t,e){var n=e.ready,r=x(e,["ready"]);return O.createElement(a,w({tReady:n},i.props,o,r))})}}]),i}(n.Component);return e.WrappedComponent=a,e.contextTypes={i18n:r.object,defaultNS:r.string,reportNS:r.func},e.displayName="Translate("+((t=a).displayName||t.name||"Component")+")",e.namespaces=o,i(e,a)}}C.contextTypes={i18n:r.object},C.childContextTypes={t:r.func.isRequired,i18n:r.object},E.setDefaults=a,E.setI18n=s;var R=function(t){function r(t,e){p(this,r);var n=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e));return n.i18n=t.i18n||e.i18n,n.t=t.t||e.t,n}return g(r,t),m(r,[{key:"render",value:function(){var o=this,t=this.props.parent||"span",e=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(e).reduce(function(t,e,n){var r=void 0;if(n%2==0){if(0===e.length)return t;r=a?O.createElement(s,{dangerouslySetInnerHTML:{__html:e}}):e}else r=function(t,e){if(t.indexOf(o.i18n.options.interpolation.formatSeparator)<0)return void 0===e[t]&&o.i18n.services.logger.warn("interpolator: missed to pass in variable "+t+" for interpolating "+c),e[t];var n=t.split(o.i18n.options.interpolation.formatSeparator),r=n.shift().trim(),i=n.join(o.i18n.options.interpolation.formatSeparator).trim();return void 0===e[r]&&o.i18n.services.logger.warn("interpolator: missed to pass in variable "+r+" for interpolating "+c),o.i18n.options.interpolation.format(e[r],i,o.i18n.language)}(e,o.props);return t.push(r),t},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,[t,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 K(t,e,n,r,i){var o=e.indexOf("<",r),a=e.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&-1<o&&0<=n+t.length||" "!==a)&&t.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(t,e){if(g){if(t!=="</"+d.name+">")return;g=!1}var n,r,i,o,a,s,p="/"!==t.charAt(1),c=0===t.indexOf("\x3c!--"),u=e+t.length,l=f.charAt(u);p&&!c&&(v++,s={type:"tag",name:"",voidElement:!(a=!(o=0)),attrs:{},children:[]},(r=t).replace(L,function(t){if("="===t)return a=!0,void o++;a?0===o?((A[t]||"/"===r.charAt(r.length-2))&&(s.voidElement=!0),s.name=t):(s.attrs[i]=t.replace(/^['"]|['"]$/g,""),i=void 0):(i&&(s.attrs[i]=i),i=t),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(t){return t&&(t.children||t.props&&t.props.children)}function $(t){return t&&t.children?t.children:t.props&&t.props.children}function z(t,e,c){if(""===e)return[];if(!t)return[e];return $(function s(p,t){return"[object Array]"!==Object.prototype.toString.call(p)&&(p=[p]),"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.reduce(function(t,e,n){if("tag"===e.type){var r=p[parseInt(e.name,10)]||{},i=O.isValidElement(r);if("string"==typeof r)t.push(r);else if(q(r)){var o=s($(r),e.children);r.dummy&&(r.children=o),t.push(O.cloneElement(r,w({},r.props,{key:n}),o))}else if("object"!==(void 0===r?"undefined":j(r))||i)t.push(r);else if(e.children[0]&&e.children[0].content){var a=c.services.interpolator.interpolate(e.children[0].content,r,c.language);t.push(a)}}else"text"===e.type&&t.push(e.content);return t},[])}([{dummy:!0,children:t}],M("<0>"+e+"</0>"))[0])}var B=function(t){function e(){return p(this,e),b(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return g(e,t),m(e,[{key:"render",value:function(){var t=w({i18n:this.context.i18n,t:this.context.t},this.props),e=t.children,n=t.count,r=t.parent,i=t.i18nKey,o=t.tOptions,a=t.values,s=t.defaults,p=t.components,c=t.ns,u=t.i18n,l=t.t,f=x(t,["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!==r?r:d.defaultTransParent,v=s||function a(s,t,e){return t?("[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(function(t,e){var n=""+e;if("string"==typeof t)s=""+s+t;else if(q(t))s=s+"<"+n+">"+a("",$(t),e+1)+"</"+n+">";else if(O.isValidElement(t))s=s+"<"+n+"></"+n+">";else if("object"===(void 0===t?"undefined":j(t))){var r=w({},t),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.",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)}),s):""}("",e),m=d.hashTransKey,g=i||(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(i&&u.options&&u.options.nsSeparator&&-1<i.indexOf(u.options.nsSeparator))S=i.split(u.options.nsSeparator)[0];h.ns&&(f["data-i18next-options"]=JSON.stringify({ns:S}))}return y?O.createElement(y,f,z(p||e,b,u)):z(p||e,b,u)}}]),e}(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(t){function r(t,e){p(this,r);var n=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e));return n.i18n=t.i18n,n.defaultNS=t.defaultNS,t.initialI18nStore&&(n.i18n.services.resourceStore.data=t.initialI18nStore,n.i18n.options.isInitialSSR=!0),t.initialLanguage&&n.i18n.changeLanguage(t.initialLanguage),n.reportNS=t.reportNS,n}return g(r,t),m(r,[{key:"getChildContext",value:function(){return{i18n:this.i18n,defaultNS:this.defaultNS,reportNS:this.reportNS}}},{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 n.Children.only(t)}}]),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(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r};function V(t){var e=[];return function(t,e){for(var n=0,r=t.length;n<r;n++)if("object"===j(t[n])){var i=!0,o=!1,a=void 0;try{for(var s,p=H(t[n])[Symbol.iterator]();!(i=(s=p.next()).done);i=!0){var c=S(s.value,2),u=c[0];e(c[1],n,u)}}catch(t){o=!0,a=t}finally{try{!i&&p.return&&p.return()}finally{if(o)throw a}}}else e(t[n],n)}(t,function(t){t&&t.namespaces&&t.namespaces.forEach(function(t){-1===e.indexOf(t)&&e.push(t)})}),e}t.translate=E,t.I18n=C,t.Interpolate=R,t.Trans=B,t.I18nextProvider=F,t.loadNamespaces=function(t){var e=t.components,n=t.i18n,r=V(e);return new Promise(function(t){n.loadNamespaces(r,t)})},t.reactI18nextModule=T,t.setDefaults=a,t.getDefaults=k,t.setI18n=s,t.getI18n=P,Object.defineProperty(t,"__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;
|
package/dist/commonjs/Trans.js
CHANGED
|
@@ -101,8 +101,11 @@ function renderNodes(children, targetString, i18n) {
|
|
|
101
101
|
if (child.dummy) child.children = inner; // needed on preact!
|
|
102
102
|
mem.push(_react2.default.cloneElement(child, _extends({}, child.props, { key: i }), inner));
|
|
103
103
|
} else if ((typeof child === 'undefined' ? 'undefined' : _typeof(child)) === 'object' && !isElement) {
|
|
104
|
-
var
|
|
105
|
-
|
|
104
|
+
var content = node.children[0] ? node.children[0].content : null;
|
|
105
|
+
if (content) {
|
|
106
|
+
var interpolated = i18n.services.interpolator.interpolate(node.children[0].content, child, i18n.language);
|
|
107
|
+
mem.push(interpolated);
|
|
108
|
+
}
|
|
106
109
|
} else {
|
|
107
110
|
mem.push(child);
|
|
108
111
|
}
|
|
@@ -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 = Array.isArray(namespaceArg) ? namespaceArg : [namespaceArg];
|
|
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/Trans.js
CHANGED
|
@@ -85,8 +85,11 @@ function renderNodes(children, targetString, i18n) {
|
|
|
85
85
|
if (child.dummy) child.children = inner; // needed on preact!
|
|
86
86
|
mem.push(React.cloneElement(child, _extends({}, child.props, { key: i }), inner));
|
|
87
87
|
} else if ((typeof child === 'undefined' ? 'undefined' : _typeof(child)) === 'object' && !isElement) {
|
|
88
|
-
var
|
|
89
|
-
|
|
88
|
+
var content = node.children[0] ? node.children[0].content : null;
|
|
89
|
+
if (content) {
|
|
90
|
+
var interpolated = i18n.services.interpolator.interpolate(node.children[0].content, child, i18n.language);
|
|
91
|
+
mem.push(interpolated);
|
|
92
|
+
}
|
|
90
93
|
} else {
|
|
91
94
|
mem.push(child);
|
|
92
95
|
}
|
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 = Array.isArray(namespaceArg) ? namespaceArg : [namespaceArg];
|
|
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 = Array.isArray(namespaceArg) ? namespaceArg : [namespaceArg];
|
|
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
|
|
|
@@ -1061,8 +1070,11 @@ function renderNodes(children, targetString, i18n) {
|
|
|
1061
1070
|
if (child.dummy) child.children = inner; // needed on preact!
|
|
1062
1071
|
mem.push(React__default.cloneElement(child, _extends({}, child.props, { key: i }), inner));
|
|
1063
1072
|
} else if ((typeof child === 'undefined' ? 'undefined' : _typeof(child)) === 'object' && !isElement) {
|
|
1064
|
-
var
|
|
1065
|
-
|
|
1073
|
+
var content = node.children[0] ? node.children[0].content : null;
|
|
1074
|
+
if (content) {
|
|
1075
|
+
var interpolated = i18n.services.interpolator.interpolate(node.children[0].content, child, i18n.language);
|
|
1076
|
+
mem.push(interpolated);
|
|
1077
|
+
}
|
|
1066
1078
|
} else {
|
|
1067
1079
|
mem.push(child);
|
|
1068
1080
|
}
|
|
@@ -1167,6 +1179,7 @@ var I18nextProvider = function (_Component) {
|
|
|
1167
1179
|
if (props.initialLanguage) {
|
|
1168
1180
|
_this.i18n.changeLanguage(props.initialLanguage);
|
|
1169
1181
|
}
|
|
1182
|
+
_this.reportNS = props.reportNS;
|
|
1170
1183
|
return _this;
|
|
1171
1184
|
}
|
|
1172
1185
|
|
|
@@ -1175,7 +1188,8 @@ var I18nextProvider = function (_Component) {
|
|
|
1175
1188
|
value: function getChildContext() {
|
|
1176
1189
|
return {
|
|
1177
1190
|
i18n: this.i18n,
|
|
1178
|
-
defaultNS: this.defaultNS
|
|
1191
|
+
defaultNS: this.defaultNS,
|
|
1192
|
+
reportNS: this.reportNS
|
|
1179
1193
|
};
|
|
1180
1194
|
}
|
|
1181
1195
|
}, {
|
|
@@ -1199,16 +1213,19 @@ var I18nextProvider = function (_Component) {
|
|
|
1199
1213
|
I18nextProvider.propTypes = {
|
|
1200
1214
|
i18n: PropTypes.object.isRequired,
|
|
1201
1215
|
children: PropTypes.element.isRequired,
|
|
1202
|
-
defaultNS: PropTypes.string
|
|
1216
|
+
defaultNS: PropTypes.string,
|
|
1217
|
+
reportNS: PropTypes.func
|
|
1203
1218
|
};
|
|
1204
1219
|
|
|
1205
1220
|
I18nextProvider.childContextTypes = {
|
|
1206
1221
|
i18n: PropTypes.object.isRequired,
|
|
1207
|
-
defaultNS: PropTypes.string
|
|
1222
|
+
defaultNS: PropTypes.string,
|
|
1223
|
+
reportNS: PropTypes.func
|
|
1208
1224
|
};
|
|
1209
1225
|
|
|
1210
1226
|
I18nextProvider.defaultProps = {
|
|
1211
|
-
defaultNS: undefined
|
|
1227
|
+
defaultNS: undefined,
|
|
1228
|
+
reportNS: undefined
|
|
1212
1229
|
};
|
|
1213
1230
|
|
|
1214
1231
|
var objectEntries = Object.entries || function (obj) {
|