react-i18next 10.13.0 β†’ 11.0.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.
@@ -53,16 +53,6 @@
53
53
  "question",
54
54
  "code"
55
55
  ]
56
- },
57
- {
58
- "login": "schettino",
59
- "name": "Matheus Schettino",
60
- "avatar_url": "https://avatars0.githubusercontent.com/u/7825467?v=4",
61
- "profile": "https://github.com/schettino",
62
- "contributions": [
63
- "code",
64
- "question"
65
- ]
66
56
  }
67
57
  ]
68
58
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ### 11.0.1
2
+
3
+ - typescript: Use updated ts export default from i18next [984](https://github.com/i18next/react-i18next/pull/984)
4
+
5
+ ### 11.0.0
6
+
7
+ - **Breaking** based on i18next changes made in [v18.0.0](https://github.com/i18next/i18next/blob/master/CHANGELOG.md#1800) changing the language should not trigger a Suspense anylonger. The state will be ready and `t` bound to the previous language until `languageChanged` get triggered -> this results in a nicer experience for users (no flickering Suspense while changing the language). Based on issue "Suspence is fired during lang change when useTranslation called in between" [975](https://github.com/i18next/react-i18next/issues/975)
8
+ - the default bindI18n is now `languageChanged` and `languageChanging` was removed from that default
9
+ - Adding `languageChanging` to bindI18n will bring back old behaviour where a language change will trigger a Suspense / ready: false while loading those new translations
10
+ - You can now override the defaults in i18next.options.react for `bindI18n`, `bindI18nStore` and `useSuspense` in the hook by `useTranslation(ns, { bindI18n, bindI18nStore, useSuspense})` or in the HOC by passing those as props.
11
+
12
+ ### 10.13.2
13
+
14
+ - typescript: Add t function to TransProps types [969](https://github.com/i18next/react-i18next/pull/969)
15
+ - lint: Fix linter errors [966](https://github.com/i18next/react-i18next/pull/966)
16
+
17
+ ### 10.13.1
18
+
19
+ - avoid conditional hook call in edge case (was only issue in wrong setup useContext outside I18nextProvider) [951](https://github.com/i18next/react-i18next/pull/951)
20
+
1
21
  ### 10.13.0
2
22
 
3
23
  - also use count from `values` object passed to Trans if passed - else use the one on props [947](https://github.com/i18next/react-i18next/pull/947)
package/README.md CHANGED
@@ -136,9 +136,19 @@ $ npm install react-i18next
136
136
  Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
137
137
 
138
138
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
139
- <!-- prettier-ignore -->
140
- | [<img src="https://avatars3.githubusercontent.com/u/977772?v=4" width="100px;"/><br /><sub><b>Jan MΓΌhlemann</b></sub>](http://twitter.com/jamuhl)<br />[πŸ’»](https://github.com/i18next/react-i18next/commits?author=jamuhl "Code") [πŸ’‘](#example-jamuhl "Examples") [πŸ“–](https://github.com/i18next/react-i18next/commits?author=jamuhl "Documentation") [πŸ’¬](#question-jamuhl "Answering Questions") | [<img src="https://avatars0.githubusercontent.com/u/1086194?v=4" width="100px;"/><br /><sub><b>Adriano Raiano</b></sub>](http://twitter.com/#!/adrirai)<br />[πŸ’»](https://github.com/i18next/react-i18next/commits?author=adrai "Code") [πŸ’‘](#example-adrai "Examples") [πŸ“–](https://github.com/i18next/react-i18next/commits?author=adrai "Documentation") [πŸ’¬](#question-adrai "Answering Questions") | [<img src="https://avatars1.githubusercontent.com/u/10575782?v=4" width="100px;"/><br /><sub><b>Isaac Hinman</b></sub>](https://isaachinman.com)<br />[πŸ’»](https://github.com/i18next/react-i18next/commits?author=isaachinman "Code") [πŸ’‘](#example-isaachinman "Examples") [πŸ’¬](#question-isaachinman "Answering Questions") | [<img src="https://avatars1.githubusercontent.com/u/136564?v=4" width="100px;"/><br /><sub><b>Kevin Ross</b></sub>](http://www.alienfast.com)<br />[πŸ’¬](#question-rosskevin "Answering Questions") [πŸ’»](https://github.com/i18next/react-i18next/commits?author=rosskevin "Code") | [<img src="https://avatars0.githubusercontent.com/u/7825467?v=4" width="100px;"/><br /><sub><b>Matheus Schettino</b></sub>](https://github.com/schettino)<br />[πŸ’»](https://github.com/i18next/react-i18next/commits?author=schettino "Code") [πŸ’¬](#question-schettino "Answering Questions") |
141
- | :---: | :---: | :---: | :---: | :---: |
139
+ <!-- prettier-ignore-start -->
140
+ <!-- markdownlint-disable -->
141
+ <table>
142
+ <tr>
143
+ <td align="center"><a href="http://twitter.com/jamuhl"><img src="https://avatars3.githubusercontent.com/u/977772?v=4" width="100px;" alt="Jan MΓΌhlemann"/><br /><sub><b>Jan MΓΌhlemann</b></sub></a><br /><a href="https://github.com/i18next/react-i18next/commits?author=jamuhl" title="Code">πŸ’»</a> <a href="#example-jamuhl" title="Examples">πŸ’‘</a> <a href="https://github.com/i18next/react-i18next/commits?author=jamuhl" title="Documentation">πŸ“–</a> <a href="#question-jamuhl" title="Answering Questions">πŸ’¬</a></td>
144
+ <td align="center"><a href="http://twitter.com/#!/adrirai"><img src="https://avatars0.githubusercontent.com/u/1086194?v=4" width="100px;" alt="Adriano Raiano"/><br /><sub><b>Adriano Raiano</b></sub></a><br /><a href="https://github.com/i18next/react-i18next/commits?author=adrai" title="Code">πŸ’»</a> <a href="#example-adrai" title="Examples">πŸ’‘</a> <a href="https://github.com/i18next/react-i18next/commits?author=adrai" title="Documentation">πŸ“–</a> <a href="#question-adrai" title="Answering Questions">πŸ’¬</a></td>
145
+ <td align="center"><a href="https://isaachinman.com"><img src="https://avatars1.githubusercontent.com/u/10575782?v=4" width="100px;" alt="Isaac Hinman"/><br /><sub><b>Isaac Hinman</b></sub></a><br /><a href="https://github.com/i18next/react-i18next/commits?author=isaachinman" title="Code">πŸ’»</a> <a href="#example-isaachinman" title="Examples">πŸ’‘</a> <a href="#question-isaachinman" title="Answering Questions">πŸ’¬</a></td>
146
+ <td align="center"><a href="http://www.alienfast.com"><img src="https://avatars1.githubusercontent.com/u/136564?v=4" width="100px;" alt="Kevin Ross"/><br /><sub><b>Kevin Ross</b></sub></a><br /><a href="#question-rosskevin" title="Answering Questions">πŸ’¬</a> <a href="https://github.com/i18next/react-i18next/commits?author=rosskevin" title="Code">πŸ’»</a></td>
147
+ </tr>
148
+ </table>
149
+
150
+ <!-- markdownlint-enable -->
151
+ <!-- prettier-ignore-end -->
142
152
 
143
153
  <!-- ALL-CONTRIBUTORS-LIST:END -->
144
154
 
@@ -17,6 +17,24 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
17
17
  return obj;
18
18
  }
19
19
 
20
+ function _extends() {
21
+ _extends = Object.assign || function (target) {
22
+ for (var i = 1; i < arguments.length; i++) {
23
+ var source = arguments[i];
24
+
25
+ for (var key in source) {
26
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
27
+ target[key] = source[key];
28
+ }
29
+ }
30
+ }
31
+
32
+ return target;
33
+ };
34
+
35
+ return _extends.apply(this, arguments);
36
+ }
37
+
20
38
  function ownKeys(object, enumerableOnly) {
21
39
  var keys = Object.keys(object);
22
40
 
@@ -304,7 +322,7 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
304
322
  };
305
323
 
306
324
  var defaultOptions = {
307
- bindI18n: 'languageChanging languageChanged',
325
+ bindI18n: 'languageChanged',
308
326
  bindI18nStore: '',
309
327
  // nsMode: 'fallback' // loop through all namespaces given to hook, HOC, render prop for key lookup
310
328
  transEmptyNodeValue: '',
@@ -446,6 +464,8 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
446
464
  });
447
465
  }
448
466
  function hasLoadedNamespace(ns, i18n) {
467
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
468
+
449
469
  if (!i18n.languages || !i18n.languages.length) {
450
470
  warnOnce('i18n.languages were undefined or empty', i18n.languages);
451
471
  return true;
@@ -460,8 +480,12 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
460
480
  var loadNotPending = (l, n) => {
461
481
  var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
462
482
  return loadState === -1 || loadState === 2;
463
- }; // loaded -> SUCCESS
483
+ }; // bound to trigger on event languageChanging
484
+ // so set ready to false while we are changing the language
485
+ // and namespace pending (depends on having a backend)
486
+
464
487
 
488
+ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false; // loaded -> SUCCESS
465
489
 
466
490
  if (i18n.hasResourceBundle(lng, ns)) return true; // were not loading at all -> SEMI SUCCESS
467
491
 
@@ -488,33 +512,36 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
488
512
  return children.every(child => React__default.isValidElement(child));
489
513
  }
490
514
 
491
- function nodesToString(mem, children, index, i18nOptions) {
515
+ function getAsArray(data) {
516
+ return Array.isArray(data) ? data : [data];
517
+ }
518
+
519
+ function nodesToString(startingString, children, index, i18nOptions) {
492
520
  if (!children) return '';
493
- if (Object.prototype.toString.call(children) !== '[object Array]') children = [children];
521
+ var stringNode = startingString;
522
+ var childrenArray = getAsArray(children);
494
523
  var keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
495
- children.forEach((child, i) => {
496
- // const isElement = React.isValidElement(child);
497
- // const elementKey = `${index !== 0 ? index + '-' : ''}${i}:${typeof child.type === 'function' ? child.type.name : child.type || 'var'}`;
524
+ childrenArray.forEach((child, i) => {
498
525
  var elementKey = "".concat(i);
499
526
 
500
527
  if (typeof child === 'string') {
501
- mem = "".concat(mem).concat(child);
528
+ stringNode = "".concat(stringNode).concat(child);
502
529
  } else if (hasChildren(child)) {
503
530
  var elementTag = keepArray.indexOf(child.type) > -1 && Object.keys(child.props).length === 1 && typeof hasChildren(child) === 'string' ? child.type : elementKey;
504
531
 
505
532
  if (child.props && child.props.i18nIsDynamicList) {
506
533
  // we got a dynamic list like "<ul>{['a', 'b'].map(item => ( <li key={item}>{item}</li> ))}</ul>""
507
534
  // the result should be "<0></0>" and not "<0><0>a</0><1>b</1></0>"
508
- mem = "".concat(mem, "<").concat(elementTag, "></").concat(elementTag, ">");
535
+ stringNode = "".concat(stringNode, "<").concat(elementTag, "></").concat(elementTag, ">");
509
536
  } else {
510
537
  // regular case mapping the inner children
511
- mem = "".concat(mem, "<").concat(elementTag, ">").concat(nodesToString('', getChildren(child), i + 1, i18nOptions), "</").concat(elementTag, ">");
538
+ stringNode = "".concat(stringNode, "<").concat(elementTag, ">").concat(nodesToString('', getChildren(child), i + 1, i18nOptions), "</").concat(elementTag, ">");
512
539
  }
513
540
  } else if (React__default.isValidElement(child)) {
514
541
  if (keepArray.indexOf(child.type) > -1 && Object.keys(child.props).length === 0) {
515
- mem = "".concat(mem, "<").concat(child.type, "/>");
542
+ stringNode = "".concat(stringNode, "<").concat(child.type, "/>");
516
543
  } else {
517
- mem = "".concat(mem, "<").concat(elementKey, "></").concat(elementKey, ">");
544
+ stringNode = "".concat(stringNode, "<").concat(elementKey, "></").concat(elementKey, ">");
518
545
  }
519
546
  } else if (typeof child === 'object') {
520
547
  var clone = _objectSpread2({}, child);
@@ -526,9 +553,9 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
526
553
  var keys = Object.keys(clone);
527
554
 
528
555
  if (format && keys.length === 1) {
529
- mem = "".concat(mem, "{{").concat(keys[0], ", ").concat(format, "}}");
556
+ stringNode = "".concat(stringNode, "{{").concat(keys[0], ", ").concat(format, "}}");
530
557
  } else if (keys.length === 1) {
531
- mem = "".concat(mem, "{{").concat(keys[0], "}}");
558
+ stringNode = "".concat(stringNode, "{{").concat(keys[0], "}}");
532
559
  } else {
533
560
  // not a valid interpolation object (can only contain one value plus format)
534
561
  warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", child);
@@ -537,7 +564,7 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
537
564
  warn("Trans: 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}}.", child);
538
565
  }
539
566
  });
540
- return mem;
567
+ return stringNode;
541
568
  }
542
569
 
543
570
  function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
@@ -551,22 +578,22 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
551
578
  var data = {};
552
579
 
553
580
  function getData(childs) {
554
- if (Object.prototype.toString.call(childs) !== '[object Array]') childs = [childs];
555
- childs.forEach(child => {
581
+ var childrenArray = getAsArray(childs);
582
+ childrenArray.forEach(child => {
556
583
  if (typeof child === 'string') return;
557
584
  if (hasChildren(child)) getData(getChildren(child));else if (typeof child === 'object' && !React__default.isValidElement(child)) Object.assign(data, child);
558
585
  });
559
586
  }
560
587
 
561
588
  getData(children);
562
- targetString = i18n.services.interpolator.interpolate(targetString, _objectSpread2({}, data, {}, combinedTOpts), i18n.language); // parse ast from string with additional wrapper tag
589
+ var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread2({}, data, {}, combinedTOpts), i18n.language); // parse ast from string with additional wrapper tag
563
590
  // -> avoids issues in parser removing prepending text nodes
564
591
 
565
- var ast = htmlParseStringify2.parse("<0>".concat(targetString, "</0>"));
592
+ var ast = htmlParseStringify2.parse("<0>".concat(interpolatedString, "</0>"));
566
593
 
567
- function mapAST(reactNodes, astNodes) {
568
- if (Object.prototype.toString.call(reactNodes) !== '[object Array]') reactNodes = [reactNodes];
569
- if (Object.prototype.toString.call(astNodes) !== '[object Array]') astNodes = [astNodes];
594
+ function mapAST(reactNode, astNode) {
595
+ var reactNodes = getAsArray(reactNode);
596
+ var astNodes = getAsArray(astNode);
570
597
  return astNodes.reduce((mem, node, i) => {
571
598
  var translationContent = node.children && node.children[0] && node.children[0].content;
572
599
 
@@ -596,7 +623,7 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
596
623
  mem.push(React__default.cloneElement(child, _objectSpread2({}, child.props, {
597
624
  key: i
598
625
  }), _inner));
599
- } else if (isNaN(node.name)) {
626
+ } else if (Number.isNaN(parseFloat(node.name))) {
600
627
  if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
601
628
  if (node.voidElement) {
602
629
  mem.push(React__default.createElement(node.name, {
@@ -740,18 +767,18 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
740
767
  return retNotReady;
741
768
  }
742
769
 
743
- var i18nOptions = _objectSpread2({}, getDefaults(), {}, i18n.options.react);
770
+ var i18nOptions = _objectSpread2({}, getDefaults(), {}, i18n.options.react, {}, props);
744
771
 
745
772
  var {
746
- useSuspense = i18nOptions.useSuspense
747
- } = props; // prepare having a namespace
773
+ useSuspense
774
+ } = i18nOptions; // prepare having a namespace
748
775
 
749
776
  var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
750
777
  namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
751
778
 
752
779
  if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
753
780
 
754
- var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n)); // binding t function to namespace (acts also as rerender trigger)
781
+ var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions)); // binding t function to namespace (acts also as rerender trigger)
755
782
 
756
783
  function getT() {
757
784
  return {
@@ -810,17 +837,22 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
810
837
  function withTranslation(ns) {
811
838
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
812
839
  return function Extend(WrappedComponent) {
813
- function I18nextWithTranslation(props, ref) {
814
- var [t, i18n, ready] = useTranslation(ns, props);
840
+ function I18nextWithTranslation(_ref) {
841
+ var {
842
+ forwardedRef
843
+ } = _ref,
844
+ rest = _objectWithoutProperties(_ref, ["forwardedRef"]);
845
+
846
+ var [t, i18n, ready] = useTranslation(ns, rest);
815
847
 
816
- var passDownProps = _objectSpread2({}, props, {
848
+ var passDownProps = _objectSpread2({}, rest, {
817
849
  t,
818
850
  i18n,
819
851
  tReady: ready
820
852
  });
821
853
 
822
- if (options.withRef && ref) {
823
- passDownProps.ref = ref;
854
+ if (options.withRef && forwardedRef) {
855
+ passDownProps.ref = forwardedRef;
824
856
  }
825
857
 
826
858
  return React__default.createElement(WrappedComponent, passDownProps);
@@ -828,7 +860,12 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
828
860
 
829
861
  I18nextWithTranslation.displayName = "withI18nextTranslation(".concat(getDisplayName(WrappedComponent), ")");
830
862
  I18nextWithTranslation.WrappedComponent = WrappedComponent;
831
- return options.withRef ? React__default.forwardRef(I18nextWithTranslation) : I18nextWithTranslation;
863
+
864
+ var forwardRef = (props, ref) => React__default.createElement(I18nextWithTranslation, _extends({}, props, {
865
+ forwardedRef: ref
866
+ }));
867
+
868
+ return options.withRef ? React__default.forwardRef(forwardRef) : I18nextWithTranslation;
832
869
  };
833
870
  }
834
871
 
@@ -866,9 +903,10 @@ define(['exports', 'react'], function (exports, React) { 'use strict';
866
903
  var {
867
904
  i18n: i18nFromProps
868
905
  } = props;
906
+ var ReactI18nContext = React.useContext(I18nContext);
869
907
  var {
870
908
  i18n: i18nFromContext
871
- } = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {};
909
+ } = getHasUsedI18nextProvider() ? ReactI18nContext || {} : {};
872
910
  var i18n = i18nFromProps || i18nFromContext || getI18n(); // opt out if is a cloned instance, eg. created by i18next-express-middleware on request
873
911
  // -> do not set initial stuff on server side
874
912
 
@@ -1 +1 @@
1
- define(["exports","react"],function(e,n){"use strict";var t="default"in n?n.default:n;function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(t,!0).forEach(function(n){r(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(t).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function o(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var c={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},s=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,n,t,r,a){var i=n.indexOf("<",r),o=n.slice(r,-1===i?void 0:i);/^\s*$/.test(o)&&(o=" "),(!a&&i>-1&&t+e.length>=0||" "!==o)&&e.push({type:"text",content:o})}function f(e,n){switch(n.type){case"text":return e+n.content;case"tag":return e+="<"+n.name+(n.attrs?function(e){var n=[];for(var t in e)n.push(t+'="'+e[t]+'"');return n.length?" "+n.join(" "):""}(n.attrs):"")+(n.voidElement?"/>":">"),n.voidElement?e:e+n.children.reduce(f,"")+"</"+n.name+">"}}var d,g,m={parse:function(e,n){n||(n={}),n.components||(n.components=u);var t,r=[],a=-1,i=[],o={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+t.name+">")return;f=!1}var d,g="/"!==l.charAt(1),m=0===l.indexOf("\x3c!--"),h=u+l.length,v=e.charAt(h);g&&!m&&(a++,"tag"===(t=function(e){var n,t=0,r=!0,a={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(s,function(i){if("="===i)return r=!0,void t++;r?0===t?((c[i]||"/"===e.charAt(e.length-2))&&(a.voidElement=!0),a.name=i):(a.attrs[n]=i.replace(/^['"]|['"]$/g,""),n=void 0):(n&&(a.attrs[n]=n),n=i),t++,r=!1}),a}(l)).type&&n.components[t.name]&&(t.type="component",f=!0),t.voidElement||f||!v||"<"===v||p(t.children,e,a,h,n.ignoreWhitespace),o[t.tagName]=t,0===a&&r.push(t),(d=i[a-1])&&d.children.push(t),i[a]=t),(m||!g||t.voidElement)&&(m||a--,!f&&"<"!==v&&v&&p(d=-1===a?r:i[a].children,e,a,h,n.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,n.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,n){return e+f("",n)},"")}},h={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0},v=t.createContext();function y(){return g}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};h=i({},h,{},e)}function O(){return h}class j{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function S(e){d=e}function E(){return d}var w={type:"3rdParty",init(e){b(e.options.react),S(e)}};function N(e){return n=>new Promise(t=>{var r=x();e.getInitialProps?e.getInitialProps(n).then(e=>{t(i({},e,{},r))}):t(r)})}function x(){var e=E(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach(t=>{r[t]={},n.forEach(n=>{r[t][n]=e.getResourceBundle(t,n)||{}})}),t.initialI18nStore=r,t.initialLanguage=e.language,t}function k(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&(n[0]="react-i18next:: ".concat(n[0])),console.warn(...n)}}var I={};function P(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&I[n[0]]||("string"==typeof n[0]&&(I[n[0]]=new Date),k(...n))}function C(e,n,t){e.loadNamespaces(n,()=>{if(e.isInitialized)t();else{var n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function T(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function z(e,n,r,a,o){if(""===n)return[];var c=a.transKeepBasicHtmlNodesFor||[],s=n&&new RegExp(c.join("|")).test(n);if(!e&&!s)return[n];var l={};!function e(n){"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),n.forEach(n=>{"string"!=typeof n&&(A(n)?e(T(n)):"object"!=typeof n||t.isValidElement(n)||Object.assign(l,n))})}(e),n=r.services.interpolator.interpolate(n,i({},l,{},o),r.language);var u=function e(n,r){return"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,o,l)=>{var u=o.children&&o.children[0]&&o.children[0].content;if("tag"===o.type){var p=n[parseInt(o.name,10)]||{},f=t.isValidElement(p);if("string"==typeof p)r.push(p);else if(A(p)){var d=T(p),g=e(d,o.children),m=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>t.isValidElement(e))}(d)&&0===g.length?d:g;p.dummy&&(p.children=m),r.push(t.cloneElement(p,i({},p.props,{key:l}),m))}else if(s&&"object"==typeof p&&p.dummy&&!f){var h=e(n,o.children);r.push(t.cloneElement(p,i({},p.props,{key:l}),h))}else if(isNaN(o.name))if(a.transSupportBasicHtmlNodes&&c.indexOf(o.name)>-1)if(o.voidElement)r.push(t.createElement(o.name,{key:"".concat(o.name,"-").concat(l)}));else{var v=e(n,o.children);r.push(t.createElement(o.name,{key:"".concat(o.name,"-").concat(l)},v))}else if(o.voidElement)r.push("<".concat(o.name," />"));else{var y=e(n,o.children);r.push("<".concat(o.name,">").concat(y,"</").concat(o.name,">"))}else if("object"!=typeof p||f)1===o.children.length&&u?r.push(t.cloneElement(p,i({},p.props,{key:l}),u)):r.push(t.cloneElement(p,i({},p.props,{key:l})));else{var b=o.children[0]?u:null;b&&r.push(b)}}else"text"===o.type&&r.push(o.content);return r},[])}([{dummy:!0,children:e}],m.parse("<0>".concat(n,"</0>")));return T(u[0])}function L(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{i18n:r}=t,a=n.useContext(v),{i18n:o,defaultNS:c}=y()&&a||{},s=r||o||E();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new j),!s){P("You will need pass in an i18next instance by using initReactI18next");var l=[e=>e,{},!1];return l.t=e=>e,l.i18n={},l.ready=!1,l}var u=i({},O(),{},s.options.react),{useSuspense:p=u.useSuspense}=t,f=e||c||s.options&&s.options.defaultNS;f="string"==typeof f?[f]:f||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(f);var d=(s.isInitialized||s.initializedStoreOnce)&&f.every(e=>(function(e,n){if(!n.languages||!n.languages.length)return P("i18n.languages were undefined or empty",n.languages),!0;var t=n.languages[0],r=!!n.options&&n.options.fallbackLng,a=n.languages[n.languages.length-1];if("cimode"===t.toLowerCase())return!0;var i=(e,t)=>{var r=n.services.backendConnector.state["".concat(e,"|").concat(t)];return-1===r||2===r};return!!n.hasResourceBundle(t,e)||(!n.services.backendConnector.backend||!(!i(t,e)||r&&!i(a,e)))})(e,s));function g(){return{t:s.getFixedT(null,"fallback"===u.nsMode?f:f[0])}}var[m,h]=n.useState(g());n.useEffect(()=>{var e=!0,{bindI18n:n,bindI18nStore:t}=u;function r(){e&&h(g())}return d||p||C(s,f,()=>{e&&h(g())}),n&&s&&s.on(n,r),t&&s&&s.store.on(t,r),()=>{e=!1,n&&s&&n.split(" ").forEach(e=>s.off(e,r)),t&&s&&t.split(" ").forEach(e=>s.store.off(e,r))}},[f.join()]);var b=[m.t,s,d];if(b.t=m.t,b.i18n=s,b.ready=d,d)return b;if(!d&&!p)return b;throw new Promise(e=>{C(s,f,()=>{h(g()),e()})})}function D(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{i18n:a}=r,{i18n:i}=y()?n.useContext(v):{},o=a||i||E();o.options&&o.options.isClone||(e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),t&&!o.initializedLanguageOnce&&(o.changeLanguage(t),o.initializedLanguageOnce=!0))}e.I18nContext=v,e.I18nextProvider=function(e){var{i18n:n,defaultNS:r,children:a}=e;return g=!0,t.createElement(v.Provider,{value:{i18n:n,defaultNS:r}},a)},e.Trans=function(e){var{children:r,count:a,parent:c,i18nKey:s,tOptions:l,values:u,defaults:p,components:f,ns:d,i18n:g,t:m}=e,h=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),{i18n:b,defaultNS:j}=y()&&n.useContext(v)||{},S=g||b||E();if(!S)return P("You will need pass in an i18next instance by using i18nextReactModule"),r;var w=m||S.t.bind(S)||(e=>e),N=i({},O(),{},S.options&&S.options.react),x=void 0!==c?c:N.defaultTransParent,I=d||w.ns||j||S.options&&S.options.defaultNS;I="string"==typeof I?[I]:I||["translation"];var C=p||function e(n,r,a,o){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);var c=o.transKeepBasicHtmlNodesFor||[];return r.forEach((r,a)=>{var s="".concat(a);if("string"==typeof r)n="".concat(n).concat(r);else if(A(r)){var l=c.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:s;n=r.props&&r.props.i18nIsDynamicList?"".concat(n,"<").concat(l,"></").concat(l,">"):"".concat(n,"<").concat(l,">").concat(e("",T(r),a+1,o),"</").concat(l,">")}else if(t.isValidElement(r))n=c.indexOf(r.type)>-1&&0===Object.keys(r.props).length?"".concat(n,"<").concat(r.type,"/>"):"".concat(n,"<").concat(s,"></").concat(s,">");else if("object"==typeof r){var u=i({},r),{format:p}=u;delete u.format;var f=Object.keys(u);p&&1===f.length?n="".concat(n,"{{").concat(f[0],", ").concat(p,"}}"):1===f.length?n="".concat(n,"{{").concat(f[0],"}}"):k("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else k("Trans: 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}}.",r)}),n}("",r,0,N)||N.transEmptyNodeValue,{hashTransKey:R}=N,L=s||(R?R(C):C),D=i({},l,{count:a},u,{},u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:C,ns:I}),B=L?w(L,D):C;return x?t.createElement(x,h,z(f||r,B,S,N,D)):z(f||r,B,S,N,D)},e.Translation=function(e){var{ns:n,children:t}=e,r=o(e,["ns","children"]),[a,i,c]=L(n,r);return t(a,{i18n:i,lng:i.language},c)},e.composeInitialProps=N,e.getDefaults=O,e.getI18n=E,e.getInitialProps=x,e.initReactI18next=w,e.setDefaults=b,e.setI18n=S,e.useSSR=D,e.useTranslation=L,e.withSSR=function(){return function(e){function n(n){var{initialI18nStore:r,initialLanguage:a}=n,c=o(n,["initialI18nStore","initialLanguage"]);return D(r,a),t.createElement(e,i({},c))}return n.getInitialProps=N(e),n.displayName="withI18nextSSR(".concat(R(e),")"),n.WrappedComponent=e,n}},e.withTranslation=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function a(a,o){var[c,s,l]=L(e,a),u=i({},a,{t:c,i18n:s,tReady:l});return n.withRef&&o&&(u.ref=o),t.createElement(r,u)}return a.displayName="withI18nextTranslation(".concat(R(r),")"),a.WrappedComponent=r,n.withRef?t.forwardRef(a):a}},Object.defineProperty(e,"__esModule",{value:!0})});
1
+ define(["exports","react"],(function(e,n){"use strict";var t="default"in n?n.default:n;function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function o(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(t,!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(t).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function c(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var s={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,u=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,p=Object.create?Object.create(null):{};function f(e,n,t,r,a){var i=n.indexOf("<",r),o=n.slice(r,-1===i?void 0:i);/^\s*$/.test(o)&&(o=" "),(!a&&i>-1&&t+e.length>=0||" "!==o)&&e.push({type:"text",content:o})}function d(e,n){switch(n.type){case"text":return e+n.content;case"tag":return e+="<"+n.name+(n.attrs?function(e){var n=[];for(var t in e)n.push(t+'="'+e[t]+'"');return n.length?" "+n.join(" "):""}(n.attrs):"")+(n.voidElement?"/>":">"),n.voidElement?e:e+n.children.reduce(d,"")+"</"+n.name+">"}}var g,h,m={parse:function(e,n){n||(n={}),n.components||(n.components=p);var t,r=[],a=-1,i=[],o={},c=!1;return e.replace(u,(function(u,p){if(c){if(u!=="</"+t.name+">")return;c=!1}var d,g="/"!==u.charAt(1),h=0===u.indexOf("\x3c!--"),m=p+u.length,v=e.charAt(m);g&&!h&&(a++,"tag"===(t=function(e){var n,t=0,r=!0,a={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(l,(function(i){if("="===i)return r=!0,void t++;r?0===t?((s[i]||"/"===e.charAt(e.length-2))&&(a.voidElement=!0),a.name=i):(a.attrs[n]=i.replace(/^['"]|['"]$/g,""),n=void 0):(n&&(a.attrs[n]=n),n=i),t++,r=!1})),a}(u)).type&&n.components[t.name]&&(t.type="component",c=!0),t.voidElement||c||!v||"<"===v||f(t.children,e,a,m,n.ignoreWhitespace),o[t.tagName]=t,0===a&&r.push(t),(d=i[a-1])&&d.children.push(t),i[a]=t),(h||!g||t.voidElement)&&(h||a--,!c&&"<"!==v&&v&&f(d=-1===a?r:i[a].children,e,a,m,n.ignoreWhitespace))})),!r.length&&e.length&&f(r,e,0,0,n.ignoreWhitespace),r},stringify:function(e){return e.reduce((function(e,n){return e+d("",n)}),"")}},v={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0},y=t.createContext();function b(){return h}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v=o({},v,{},e)}function w(){return v}class E{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function j(e){g=e}function N(){return g}var S={type:"3rdParty",init(e){O(e.options.react),j(e)}};function x(e){return n=>new Promise(t=>{var r=k();e.getInitialProps?e.getInitialProps(n).then(e=>{t(o({},e,{},r))}):t(r)})}function k(){var e=N(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach(t=>{r[t]={},n.forEach(n=>{r[t][n]=e.getResourceBundle(t,n)||{}})}),t.initialI18nStore=r,t.initialLanguage=e.language,t}function I(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&(n[0]="react-i18next:: ".concat(n[0])),console.warn(...n)}}var P={};function C(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&P[n[0]]||("string"==typeof n[0]&&(P[n[0]]=new Date),I(...n))}function R(e,n,t){e.loadNamespaces(n,()=>{if(e.isInitialized)t();else{var n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}})}function T(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function L(e){return e&&(e.children||e.props&&e.props.children)}function z(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function A(e){return Array.isArray(e)?e:[e]}function D(e,n,r,a,i){if(""===n)return[];var c=a.transKeepBasicHtmlNodesFor||[],s=n&&new RegExp(c.join("|")).test(n);if(!e&&!s)return[n];var l={};!function e(n){A(n).forEach(n=>{"string"!=typeof n&&(L(n)?e(z(n)):"object"!=typeof n||t.isValidElement(n)||Object.assign(l,n))})}(e);var u=r.services.interpolator.interpolate(n,o({},l,{},i),r.language);var p=function e(n,r){var i=A(n);return A(r).reduce((n,r,l)=>{var u=r.children&&r.children[0]&&r.children[0].content;if("tag"===r.type){var p=i[parseInt(r.name,10)]||{},f=t.isValidElement(p);if("string"==typeof p)n.push(p);else if(L(p)){var d=z(p),g=e(d,r.children),h=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>t.isValidElement(e))}(d)&&0===g.length?d:g;p.dummy&&(p.children=h),n.push(t.cloneElement(p,o({},p.props,{key:l}),h))}else if(s&&"object"==typeof p&&p.dummy&&!f){var m=e(i,r.children);n.push(t.cloneElement(p,o({},p.props,{key:l}),m))}else if(Number.isNaN(parseFloat(r.name)))if(a.transSupportBasicHtmlNodes&&c.indexOf(r.name)>-1)if(r.voidElement)n.push(t.createElement(r.name,{key:"".concat(r.name,"-").concat(l)}));else{var v=e(i,r.children);n.push(t.createElement(r.name,{key:"".concat(r.name,"-").concat(l)},v))}else if(r.voidElement)n.push("<".concat(r.name," />"));else{var y=e(i,r.children);n.push("<".concat(r.name,">").concat(y,"</").concat(r.name,">"))}else if("object"!=typeof p||f)1===r.children.length&&u?n.push(t.cloneElement(p,o({},p.props,{key:l}),u)):n.push(t.cloneElement(p,o({},p.props,{key:l})));else{var b=r.children[0]?u:null;b&&n.push(b)}}else"text"===r.type&&n.push(r.content);return n},[])}([{dummy:!0,children:e}],m.parse("<0>".concat(u,"</0>")));return z(p[0])}function B(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{i18n:r}=t,a=n.useContext(y),{i18n:i,defaultNS:c}=b()&&a||{},s=r||i||N();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new E),!s){C("You will need pass in an i18next instance by using initReactI18next");var l=[e=>e,{},!1];return l.t=e=>e,l.i18n={},l.ready=!1,l}var u=o({},w(),{},s.options.react,{},t),{useSuspense:p}=u,f=e||c||s.options&&s.options.defaultNS;f="string"==typeof f?[f]:f||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(f);var d=(s.isInitialized||s.initializedStoreOnce)&&f.every(e=>(function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return C("i18n.languages were undefined or empty",n.languages),!0;var r=n.languages[0],a=!!n.options&&n.options.fallbackLng,i=n.languages[n.languages.length-1];if("cimode"===r.toLowerCase())return!0;var o=(e,t)=>{var r=n.services.backendConnector.state["".concat(e,"|").concat(t)];return-1===r||2===r};return!(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,e))&&(!!n.hasResourceBundle(r,e)||(!n.services.backendConnector.backend||!(!o(r,e)||a&&!o(i,e))))})(e,s,u));function g(){return{t:s.getFixedT(null,"fallback"===u.nsMode?f:f[0])}}var[h,m]=n.useState(g());n.useEffect(()=>{var e=!0,{bindI18n:n,bindI18nStore:t}=u;function r(){e&&m(g())}return d||p||R(s,f,()=>{e&&m(g())}),n&&s&&s.on(n,r),t&&s&&s.store.on(t,r),()=>{e=!1,n&&s&&n.split(" ").forEach(e=>s.off(e,r)),t&&s&&t.split(" ").forEach(e=>s.store.off(e,r))}},[f.join()]);var v=[h.t,s,d];if(v.t=h.t,v.i18n=s,v.ready=d,d)return v;if(!d&&!p)return v;throw new Promise(e=>{R(s,f,()=>{m(g()),e()})})}function V(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{i18n:a}=r,i=n.useContext(y),{i18n:o}=b()&&i||{},c=a||o||N();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.initializedStoreOnce=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}e.I18nContext=y,e.I18nextProvider=function(e){var{i18n:n,defaultNS:r,children:a}=e;return h=!0,t.createElement(y.Provider,{value:{i18n:n,defaultNS:r}},a)},e.Trans=function(e){var{children:r,count:a,parent:i,i18nKey:s,tOptions:l,values:u,defaults:p,components:f,ns:d,i18n:g,t:h}=e,m=c(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]),{i18n:v,defaultNS:O}=b()&&n.useContext(y)||{},E=g||v||N();if(!E)return C("You will need pass in an i18next instance by using i18nextReactModule"),r;var j=h||E.t.bind(E)||(e=>e),S=o({},w(),{},E.options&&E.options.react),x=void 0!==i?i:S.defaultTransParent,k=d||j.ns||O||E.options&&E.options.defaultNS;k="string"==typeof k?[k]:k||["translation"];var P=p||function e(n,r,a,i){if(!r)return"";var c=n,s=A(r),l=i.transKeepBasicHtmlNodesFor||[];return s.forEach((n,r)=>{var a="".concat(r);if("string"==typeof n)c="".concat(c).concat(n);else if(L(n)){var s=l.indexOf(n.type)>-1&&1===Object.keys(n.props).length&&"string"==typeof L(n)?n.type:a;c=n.props&&n.props.i18nIsDynamicList?"".concat(c,"<").concat(s,"></").concat(s,">"):"".concat(c,"<").concat(s,">").concat(e("",z(n),r+1,i),"</").concat(s,">")}else if(t.isValidElement(n))c=l.indexOf(n.type)>-1&&0===Object.keys(n.props).length?"".concat(c,"<").concat(n.type,"/>"):"".concat(c,"<").concat(a,"></").concat(a,">");else if("object"==typeof n){var u=o({},n),{format:p}=u;delete u.format;var f=Object.keys(u);p&&1===f.length?c="".concat(c,"{{").concat(f[0],", ").concat(p,"}}"):1===f.length?c="".concat(c,"{{").concat(f[0],"}}"):I("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",n)}else I("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",n)}),c}("",r,0,S)||S.transEmptyNodeValue,{hashTransKey:R}=S,T=s||(R?R(P):P),B=o({},l,{count:a},u,{},u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:P,ns:k}),V=T?j(T,B):P;return x?t.createElement(x,m,D(f||r,V,E,S,B)):D(f||r,V,E,S,B)},e.Translation=function(e){var{ns:n,children:t}=e,r=c(e,["ns","children"]),[a,i,o]=B(n,r);return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=x,e.getDefaults=w,e.getI18n=N,e.getInitialProps=k,e.initReactI18next=S,e.setDefaults=O,e.setI18n=j,e.useSSR=V,e.useTranslation=B,e.withSSR=function(){return function(e){function n(n){var{initialI18nStore:r,initialLanguage:a}=n,i=c(n,["initialI18nStore","initialLanguage"]);return V(r,a),t.createElement(e,o({},i))}return n.getInitialProps=x(e),n.displayName="withI18nextSSR(".concat(T(e),")"),n.WrappedComponent=e,n}},e.withTranslation=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function i(a){var{forwardedRef:i}=a,s=c(a,["forwardedRef"]),[l,u,p]=B(e,s),f=o({},s,{t:l,i18n:u,tReady:p});return n.withRef&&i&&(f.ref=i),t.createElement(r,f)}i.displayName="withI18nextTranslation(".concat(T(r),")"),i.WrappedComponent=r;return n.withRef?t.forwardRef((e,n)=>t.createElement(i,a({},e,{forwardedRef:n}))):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -44,33 +44,36 @@ function hasValidReactChildren(children) {
44
44
  });
45
45
  }
46
46
 
47
- function nodesToString(mem, children, index, i18nOptions) {
47
+ function getAsArray(data) {
48
+ return Array.isArray(data) ? data : [data];
49
+ }
50
+
51
+ function nodesToString(startingString, children, index, i18nOptions) {
48
52
  if (!children) return '';
49
- if (Object.prototype.toString.call(children) !== '[object Array]') children = [children];
53
+ var stringNode = startingString;
54
+ var childrenArray = getAsArray(children);
50
55
  var keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
51
- children.forEach(function (child, i) {
52
- // const isElement = React.isValidElement(child);
53
- // const elementKey = `${index !== 0 ? index + '-' : ''}${i}:${typeof child.type === 'function' ? child.type.name : child.type || 'var'}`;
56
+ childrenArray.forEach(function (child, i) {
54
57
  var elementKey = "".concat(i);
55
58
 
56
59
  if (typeof child === 'string') {
57
- mem = "".concat(mem).concat(child);
60
+ stringNode = "".concat(stringNode).concat(child);
58
61
  } else if (hasChildren(child)) {
59
62
  var elementTag = keepArray.indexOf(child.type) > -1 && Object.keys(child.props).length === 1 && typeof hasChildren(child) === 'string' ? child.type : elementKey;
60
63
 
61
64
  if (child.props && child.props.i18nIsDynamicList) {
62
65
  // we got a dynamic list like "<ul>{['a', 'b'].map(item => ( <li key={item}>{item}</li> ))}</ul>""
63
66
  // the result should be "<0></0>" and not "<0><0>a</0><1>b</1></0>"
64
- mem = "".concat(mem, "<").concat(elementTag, "></").concat(elementTag, ">");
67
+ stringNode = "".concat(stringNode, "<").concat(elementTag, "></").concat(elementTag, ">");
65
68
  } else {
66
69
  // regular case mapping the inner children
67
- mem = "".concat(mem, "<").concat(elementTag, ">").concat(nodesToString('', getChildren(child), i + 1, i18nOptions), "</").concat(elementTag, ">");
70
+ stringNode = "".concat(stringNode, "<").concat(elementTag, ">").concat(nodesToString('', getChildren(child), i + 1, i18nOptions), "</").concat(elementTag, ">");
68
71
  }
69
72
  } else if (_react["default"].isValidElement(child)) {
70
73
  if (keepArray.indexOf(child.type) > -1 && Object.keys(child.props).length === 0) {
71
- mem = "".concat(mem, "<").concat(child.type, "/>");
74
+ stringNode = "".concat(stringNode, "<").concat(child.type, "/>");
72
75
  } else {
73
- mem = "".concat(mem, "<").concat(elementKey, "></").concat(elementKey, ">");
76
+ stringNode = "".concat(stringNode, "<").concat(elementKey, "></").concat(elementKey, ">");
74
77
  }
75
78
  } else if ((0, _typeof2["default"])(child) === 'object') {
76
79
  var clone = _objectSpread({}, child);
@@ -80,9 +83,9 @@ function nodesToString(mem, children, index, i18nOptions) {
80
83
  var keys = Object.keys(clone);
81
84
 
82
85
  if (format && keys.length === 1) {
83
- mem = "".concat(mem, "{{").concat(keys[0], ", ").concat(format, "}}");
86
+ stringNode = "".concat(stringNode, "{{").concat(keys[0], ", ").concat(format, "}}");
84
87
  } else if (keys.length === 1) {
85
- mem = "".concat(mem, "{{").concat(keys[0], "}}");
88
+ stringNode = "".concat(stringNode, "{{").concat(keys[0], "}}");
86
89
  } else {
87
90
  // not a valid interpolation object (can only contain one value plus format)
88
91
  (0, _utils.warn)("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", child);
@@ -91,7 +94,7 @@ function nodesToString(mem, children, index, i18nOptions) {
91
94
  (0, _utils.warn)("Trans: 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}}.", child);
92
95
  }
93
96
  });
94
- return mem;
97
+ return stringNode;
95
98
  }
96
99
 
97
100
  function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
@@ -105,22 +108,22 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
105
108
  var data = {};
106
109
 
107
110
  function getData(childs) {
108
- if (Object.prototype.toString.call(childs) !== '[object Array]') childs = [childs];
109
- childs.forEach(function (child) {
111
+ var childrenArray = getAsArray(childs);
112
+ childrenArray.forEach(function (child) {
110
113
  if (typeof child === 'string') return;
111
114
  if (hasChildren(child)) getData(getChildren(child));else if ((0, _typeof2["default"])(child) === 'object' && !_react["default"].isValidElement(child)) Object.assign(data, child);
112
115
  });
113
116
  }
114
117
 
115
118
  getData(children);
116
- targetString = i18n.services.interpolator.interpolate(targetString, _objectSpread({}, data, {}, combinedTOpts), i18n.language); // parse ast from string with additional wrapper tag
119
+ var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread({}, data, {}, combinedTOpts), i18n.language); // parse ast from string with additional wrapper tag
117
120
  // -> avoids issues in parser removing prepending text nodes
118
121
 
119
- var ast = _htmlParseStringify["default"].parse("<0>".concat(targetString, "</0>"));
122
+ var ast = _htmlParseStringify["default"].parse("<0>".concat(interpolatedString, "</0>"));
120
123
 
121
- function mapAST(reactNodes, astNodes) {
122
- if (Object.prototype.toString.call(reactNodes) !== '[object Array]') reactNodes = [reactNodes];
123
- if (Object.prototype.toString.call(astNodes) !== '[object Array]') astNodes = [astNodes];
124
+ function mapAST(reactNode, astNode) {
125
+ var reactNodes = getAsArray(reactNode);
126
+ var astNodes = getAsArray(astNode);
124
127
  return astNodes.reduce(function (mem, node, i) {
125
128
  var translationContent = node.children && node.children[0] && node.children[0].content;
126
129
 
@@ -151,7 +154,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
151
154
  mem.push(_react["default"].cloneElement(child, _objectSpread({}, child.props, {
152
155
  key: i
153
156
  }), _inner));
154
- } else if (isNaN(node.name)) {
157
+ } else if (Number.isNaN(parseFloat(node.name))) {
155
158
  if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
156
159
  if (node.voidElement) {
157
160
  mem.push(_react["default"].createElement(node.name, {
@@ -11,8 +11,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
 
12
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
13
 
14
- var _react = _interopRequireDefault(require("react"));
15
-
16
14
  var _useTranslation3 = require("./useTranslation");
17
15
 
18
16
  function Translation(props) {
@@ -28,7 +28,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
28
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
29
 
30
30
  var defaultOptions = {
31
- bindI18n: 'languageChanging languageChanged',
31
+ bindI18n: 'languageChanged',
32
32
  bindI18nStore: '',
33
33
  // nsMode: 'fallback' // loop through all namespaces given to hook, HOC, render prop for key lookup
34
34
  transEmptyNodeValue: '',
@@ -12,8 +12,9 @@ var _context = require("./context");
12
12
  function useSSR(initialI18nStore, initialLanguage) {
13
13
  var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
14
14
  var i18nFromProps = props.i18n;
15
+ var ReactI18nContext = (0, _react.useContext)(_context.I18nContext);
15
16
 
16
- var _ref = (0, _context.getHasUsedI18nextProvider)() ? (0, _react.useContext)(_context.I18nContext) : {},
17
+ var _ref = (0, _context.getHasUsedI18nextProvider)() ? ReactI18nContext || {} : {},
17
18
  i18nFromContext = _ref.i18n;
18
19
 
19
20
  var i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)(); // opt out if is a cloned instance, eg. created by i18next-express-middleware on request
@@ -49,10 +49,9 @@ function useTranslation(ns) {
49
49
  return retNotReady;
50
50
  }
51
51
 
52
- var i18nOptions = _objectSpread({}, (0, _context.getDefaults)(), {}, i18n.options.react);
52
+ var i18nOptions = _objectSpread({}, (0, _context.getDefaults)(), {}, i18n.options.react, {}, props);
53
53
 
54
- var _props$useSuspense = props.useSuspense,
55
- useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace
54
+ var useSuspense = i18nOptions.useSuspense; // prepare having a namespace
56
55
 
57
56
  var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
58
57
  namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
@@ -60,7 +59,7 @@ function useTranslation(ns) {
60
59
  if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
61
60
 
62
61
  var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function (n) {
63
- return (0, _utils.hasLoadedNamespace)(n, i18n);
62
+ return (0, _utils.hasLoadedNamespace)(n, i18n, i18nOptions);
64
63
  }); // binding t function to namespace (acts also as rerender trigger)
65
64
 
66
65
  function getT() {
@@ -63,6 +63,8 @@ function loadNamespaces(i18n, ns, cb) {
63
63
  }
64
64
 
65
65
  function hasLoadedNamespace(ns, i18n) {
66
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
67
+
66
68
  if (!i18n.languages || !i18n.languages.length) {
67
69
  warnOnce('i18n.languages were undefined or empty', i18n.languages);
68
70
  return true;
@@ -77,8 +79,12 @@ function hasLoadedNamespace(ns, i18n) {
77
79
  var loadNotPending = function loadNotPending(l, n) {
78
80
  var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
79
81
  return loadState === -1 || loadState === 2;
80
- }; // loaded -> SUCCESS
82
+ }; // bound to trigger on event languageChanging
83
+ // so set ready to false while we are changing the language
84
+ // and namespace pending (depends on having a backend)
85
+
81
86
 
87
+ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false; // loaded -> SUCCESS
82
88
 
83
89
  if (i18n.hasResourceBundle(lng, ns)) return true; // were not loading at all -> SEMI SUCCESS
84
90
 
@@ -7,10 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.withTranslation = withTranslation;
9
9
 
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
15
 
16
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
+
14
18
  var _react = _interopRequireDefault(require("react"));
15
19
 
16
20
  var _useTranslation3 = require("./useTranslation");
@@ -24,21 +28,24 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
24
28
  function withTranslation(ns) {
25
29
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26
30
  return function Extend(WrappedComponent) {
27
- function I18nextWithTranslation(props, ref) {
28
- var _useTranslation = (0, _useTranslation3.useTranslation)(ns, props),
31
+ function I18nextWithTranslation(_ref) {
32
+ var forwardedRef = _ref.forwardedRef,
33
+ rest = (0, _objectWithoutProperties2["default"])(_ref, ["forwardedRef"]);
34
+
35
+ var _useTranslation = (0, _useTranslation3.useTranslation)(ns, rest),
29
36
  _useTranslation2 = (0, _slicedToArray2["default"])(_useTranslation, 3),
30
37
  t = _useTranslation2[0],
31
38
  i18n = _useTranslation2[1],
32
39
  ready = _useTranslation2[2];
33
40
 
34
- var passDownProps = _objectSpread({}, props, {
41
+ var passDownProps = _objectSpread({}, rest, {
35
42
  t: t,
36
43
  i18n: i18n,
37
44
  tReady: ready
38
45
  });
39
46
 
40
- if (options.withRef && ref) {
41
- passDownProps.ref = ref;
47
+ if (options.withRef && forwardedRef) {
48
+ passDownProps.ref = forwardedRef;
42
49
  }
43
50
 
44
51
  return _react["default"].createElement(WrappedComponent, passDownProps);
@@ -46,6 +53,13 @@ function withTranslation(ns) {
46
53
 
47
54
  I18nextWithTranslation.displayName = "withI18nextTranslation(".concat((0, _utils.getDisplayName)(WrappedComponent), ")");
48
55
  I18nextWithTranslation.WrappedComponent = WrappedComponent;
49
- return options.withRef ? _react["default"].forwardRef(I18nextWithTranslation) : I18nextWithTranslation;
56
+
57
+ var forwardRef = function forwardRef(props, ref) {
58
+ return _react["default"].createElement(I18nextWithTranslation, (0, _extends2["default"])({}, props, {
59
+ forwardedRef: ref
60
+ }));
61
+ };
62
+
63
+ return options.withRef ? _react["default"].forwardRef(forwardRef) : I18nextWithTranslation;
50
64
  };
51
65
  }