1
1
( function ( global , factory ) {
2
2
typeof exports === 'object' && typeof module !== 'undefined' ? factory ( exports , require ( 'react' ) , require ( 'prop-types' ) ) :
3
3
typeof define === 'function' && define . amd ? define ( 'reactI18next' , [ 'exports' , 'react' , 'prop-types' ] , factory ) :
4
- ( factory ( ( global . reactI18next = global . reactI18next || { } ) , global . React ) ) ;
4
+ ( factory ( ( global . reactI18next = global . reactI18next || { } ) , global . React , global . PropTypes ) ) ;
5
5
} ( this , ( function ( exports , React , PropTypes ) { 'use strict' ;
6
6
7
7
var React__default = 'default' in React ? React [ 'default' ] : React ;
8
+ PropTypes = 'default' in PropTypes ? PropTypes [ 'default' ] : PropTypes ;
8
9
9
- function interopDefault ( ex ) {
10
- return ex && typeof ex === 'object' && 'default' in ex ? ex [ 'default' ] : ex ;
11
- }
12
-
13
- function createCommonjsModule ( fn , module ) {
14
- return module = { exports : { } } , fn ( module , module . exports ) , module . exports ;
15
- }
16
-
17
- var index = createCommonjsModule ( function ( module ) {
18
10
/**
19
11
* Copyright 2015, Yahoo! Inc.
20
12
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
21
13
*/
22
- 'use strict' ;
23
-
24
14
var REACT_STATICS = {
25
15
childContextTypes : true ,
26
16
contextTypes : true ,
@@ -43,7 +33,7 @@ var KNOWN_STATICS = {
43
33
44
34
var isGetOwnPropertySymbolsAvailable = typeof Object . getOwnPropertySymbols === 'function' ;
45
35
46
- module . exports = function hoistNonReactStatics ( targetComponent , sourceComponent , customStatics ) {
36
+ var index = function hoistNonReactStatics ( targetComponent , sourceComponent , customStatics ) {
47
37
if ( typeof sourceComponent !== 'string' ) { // don't hoist over string (html) components
48
38
var keys = Object . getOwnPropertyNames ( sourceComponent ) ;
49
39
@@ -65,16 +55,23 @@ module.exports = function hoistNonReactStatics(targetComponent, sourceComponent,
65
55
66
56
return targetComponent ;
67
57
} ;
68
- } ) ;
69
-
70
- var hoistStatics = interopDefault ( index ) ;
71
58
72
59
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) {
73
60
return typeof obj ;
74
61
} : function ( obj ) {
75
- return obj && typeof Symbol === "function" && obj . constructor === Symbol ? "symbol" : typeof obj ;
62
+ return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ;
76
63
} ;
77
64
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
78
75
var classCallCheck = function ( instance , Constructor ) {
79
76
if ( ! ( instance instanceof Constructor ) ) {
80
77
throw new TypeError ( "Cannot call a class as a function" ) ;
@@ -99,6 +96,10 @@ var createClass = function () {
99
96
} ;
100
97
} ( ) ;
101
98
99
+
100
+
101
+
102
+
102
103
var defineProperty = function ( obj , key , value ) {
103
104
if ( key in obj ) {
104
105
Object . defineProperty ( obj , key , {
@@ -128,6 +129,8 @@ var _extends = Object.assign || function (target) {
128
129
return target ;
129
130
} ;
130
131
132
+
133
+
131
134
var inherits = function ( subClass , superClass ) {
132
135
if ( typeof superClass !== "function" && superClass !== null ) {
133
136
throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ;
@@ -144,6 +147,16 @@ var inherits = function (subClass, superClass) {
144
147
if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ;
145
148
} ;
146
149
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
147
160
var possibleConstructorReturn = function ( self , call ) {
148
161
if ( ! self ) {
149
162
throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ;
@@ -152,6 +165,10 @@ var possibleConstructorReturn = function (self, call) {
152
165
return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ;
153
166
} ;
154
167
168
+
169
+
170
+
171
+
155
172
var slicedToArray = function ( ) {
156
173
function sliceIterator ( arr , i ) {
157
174
var _arr = [ ] ;
@@ -195,17 +212,17 @@ function getDisplayName(component) {
195
212
}
196
213
197
214
function translate ( namespaces ) {
198
- var options = arguments . length <= 1 || arguments [ 1 ] === undefined ? { } : arguments [ 1 ] ;
199
- var _options$withRef = options . withRef ;
200
- var withRef = _options$withRef === undefined ? false : _options$withRef ;
201
- var _options$wait = options . wait ;
202
- var wait = _options$wait === undefined ? false : _options$wait ;
203
- var _options$bindI18n = options . bindI18n ;
204
- var bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n ;
205
- var _options$bindStore = options . bindStore ;
206
- var bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore ;
207
- var _options$translateFun = options . translateFuncName ;
208
- var translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun ;
215
+ var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
216
+ var _options$withRef = options . withRef ,
217
+ withRef = _options$withRef === undefined ? false : _options$withRef ,
218
+ _options$wait = options . wait ,
219
+ wait = _options$wait === undefined ? false : _options$wait ,
220
+ _options$bindI18n = options . bindI18n ,
221
+ bindI18n = _options$bindI18n === undefined ? 'languageChanged loaded' : _options$bindI18n ,
222
+ _options$bindStore = options . bindStore ,
223
+ bindStore = _options$bindStore === undefined ? 'added removed' : _options$bindStore ,
224
+ _options$translateFun = options . translateFuncName ,
225
+ translateFuncName = _options$translateFun === undefined ? 't' : _options$translateFun ;
209
226
210
227
211
228
return function Wrapper ( WrappedComponent ) {
@@ -215,7 +232,7 @@ function translate(namespaces) {
215
232
function Translate ( props , context ) {
216
233
classCallCheck ( this , Translate ) ;
217
234
218
- var _this = possibleConstructorReturn ( this , Object . getPrototypeOf ( Translate ) . call ( this , props , context ) ) ;
235
+ var _this = possibleConstructorReturn ( this , ( Translate . __proto__ || Object . getPrototypeOf ( Translate ) ) . call ( this , props , context ) ) ;
219
236
220
237
_this . i18n = context . i18n || props . i18n ;
221
238
namespaces = namespaces || _this . i18n . options . defaultNS ;
@@ -312,9 +329,9 @@ function translate(namespaces) {
312
329
value : function render ( ) {
313
330
var _extraProps ;
314
331
315
- var _state = this . state ;
316
- var i18nLoadedAt = _state . i18nLoadedAt ;
317
- var ready = _state . ready ;
332
+ var _state = this . state ,
333
+ i18nLoadedAt = _state . i18nLoadedAt ,
334
+ ready = _state . ready ;
318
335
319
336
var extraProps = ( _extraProps = { i18nLoadedAt : i18nLoadedAt } , defineProperty ( _extraProps , translateFuncName , this [ translateFuncName ] ) , defineProperty ( _extraProps , 'i18n' , this . i18n ) , _extraProps ) ;
320
337
@@ -342,7 +359,7 @@ function translate(namespaces) {
342
359
343
360
Translate . namespaces = namespaces ;
344
361
345
- return hoistStatics ( Translate , WrappedComponent ) ;
362
+ return index ( Translate , WrappedComponent ) ;
346
363
} ;
347
364
}
348
365
@@ -352,7 +369,7 @@ var Interpolate = function (_Component) {
352
369
function Interpolate ( props , context ) {
353
370
classCallCheck ( this , Interpolate ) ;
354
371
355
- var _this = possibleConstructorReturn ( this , Object . getPrototypeOf ( Interpolate ) . call ( this , props , context ) ) ;
372
+ var _this = possibleConstructorReturn ( this , ( Interpolate . __proto__ || Object . getPrototypeOf ( Interpolate ) ) . call ( this , props , context ) ) ;
356
373
357
374
_this . i18n = context . i18n ;
358
375
_this . t = context . t ;
@@ -366,9 +383,9 @@ var Interpolate = function (_Component) {
366
383
367
384
var parent = this . props . parent || 'span' ;
368
385
var REGEXP = this . props . regexp || this . i18n . services . interpolator . regexp ;
369
- var _props = this . props ;
370
- var className = _props . className ;
371
- var style = _props . style ;
386
+ var _props = this . props ,
387
+ className = _props . className ,
388
+ style = _props . style ;
372
389
373
390
// Set to true if you want to use raw HTML in translation values
374
391
// See https://github.com/i18next/react-i18next/issues/189
@@ -437,7 +454,7 @@ var I18nextProvider = function (_Component) {
437
454
function I18nextProvider ( props , context ) {
438
455
classCallCheck ( this , I18nextProvider ) ;
439
456
440
- var _this = possibleConstructorReturn ( this , Object . getPrototypeOf ( I18nextProvider ) . call ( this , props , context ) ) ;
457
+ var _this = possibleConstructorReturn ( this , ( I18nextProvider . __proto__ || Object . getPrototypeOf ( I18nextProvider ) ) . call ( this , props , context ) ) ;
441
458
442
459
_this . i18n = props . i18n ;
443
460
return _this ;
@@ -486,10 +503,9 @@ function eachComponents(components, iterator) {
486
503
487
504
try {
488
505
for ( var _iterator = Object . entries ( components [ i ] ) [ Symbol . iterator ] ( ) , _step ; ! ( _iteratorNormalCompletion = ( _step = _iterator . next ( ) ) . done ) ; _iteratorNormalCompletion = true ) {
489
- var _step$value = slicedToArray ( _step . value , 2 ) ;
490
-
491
- var key = _step$value [ 0 ] ;
492
- var value = _step$value [ 1 ] ;
506
+ var _step$value = slicedToArray ( _step . value , 2 ) ,
507
+ key = _step$value [ 0 ] ,
508
+ value = _step$value [ 1 ] ;
493
509
494
510
iterator ( value , i , key ) ;
495
511
}
@@ -515,10 +531,10 @@ function eachComponents(components, iterator) {
515
531
516
532
function filterAndFlattenComponents ( components ) {
517
533
var flattened = [ ] ;
518
- eachComponents ( components , function ( Component ) {
519
- if ( Component && Component . namespaces ) {
534
+ eachComponents ( components , function ( Component$$1 ) {
535
+ if ( Component$$1 && Component$$1 . namespaces ) {
520
536
521
- Component . namespaces . forEach ( function ( namespace ) {
537
+ Component$$1 . namespaces . forEach ( function ( namespace ) {
522
538
if ( flattened . indexOf ( namespace ) === - 1 ) {
523
539
flattened . push ( namespace ) ;
524
540
}
@@ -529,8 +545,8 @@ function filterAndFlattenComponents(components) {
529
545
}
530
546
531
547
function loadNamespaces ( _ref ) {
532
- var components = _ref . components ;
533
- var i18n = _ref . i18n ;
548
+ var components = _ref . components ,
549
+ i18n = _ref . i18n ;
534
550
535
551
var allNamespaces = filterAndFlattenComponents ( components ) ;
536
552
0 commit comments