react-i18next 11.18.2 → 11.18.5

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 CHANGED
@@ -1,3 +1,15 @@
1
+ ### 11.18.5
2
+
3
+ - support unescaping forward slash [1548](https://github.com/i18next/react-i18next/pull/1548)
4
+
5
+ ### 11.18.4
6
+
7
+ - fix: reset t when keyPrefix is updated [1544](https://github.com/i18next/react-i18next/pull/1544)
8
+
9
+ ### 11.18.3
10
+
11
+ - types: bindI18n option for UseTranslationOptions
12
+
1
13
  ### 11.18.2
2
14
 
3
15
  - more html entities to unescape by default [1538](https://github.com/i18next/react-i18next/pull/1538)
package/README.md CHANGED
@@ -64,7 +64,7 @@ Head over to the **interactive playground** at [codesandbox](https://codesandbox
64
64
 
65
65
  ### 📖 What others say
66
66
 
67
- - [How to properly internationalize a React application using i18next](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) by Adriano Raiano
67
+ - [How to properly internationalize a React application using i18next](https://locize.com/blog/react-i18next/) by Adriano Raiano
68
68
  - [I18n with React and i18next](https://alligator.io/react/i18n-with-react-and-i18next) via Alligator.io by Danny Hurlburt
69
69
  - [Ultimate Localization of React (Mobx) App with i18next](https://itnext.io/ultimate-localization-of-react-mobx-app-with-i18next-efab77712149) via itnext.io by Viktor Shevchenko
70
70
  - [Internationalization for react done right Using the i18next i18n ecosystem](https://reactjsexample.com/internationalization-for-react-done-right-using-the-i18next-i18n-ecosystem/) via reactjsexample.com
@@ -103,7 +103,7 @@ $ npm install react-i18next
103
103
 
104
104
  ### Do you like to read a more complete step by step tutorial?
105
105
 
106
- [Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.
106
+ [Here](https://locize.com/blog/react-i18next/) you'll find a simple tutorial on how to best use react-i18next.
107
107
  Some basics of i18next and some cool possibilities on how to optimize your localization workflow.
108
108
 
109
109
  ### Examples
@@ -314,7 +314,7 @@ define(['exports', 'react'], function (exports, react) { 'use strict';
314
314
  }
315
315
  };
316
316
 
317
- var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
317
+ var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
318
318
  var htmlEntities = {
319
319
  '&': '&',
320
320
  '&': '&',
@@ -333,7 +333,9 @@ define(['exports', 'react'], function (exports, react) { 'use strict';
333
333
  '®': '®',
334
334
  '®': '®',
335
335
  '…': '…',
336
- '…': '…'
336
+ '…': '…',
337
+ '/': '/',
338
+ '/': '/'
337
339
  };
338
340
 
339
341
  var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
@@ -527,7 +529,7 @@ define(['exports', 'react'], function (exports, react) { 'use strict';
527
529
 
528
530
  function getChildren(node) {
529
531
  if (!node) return [];
530
- return node && node.children ? node.children : node.props && node.props.children;
532
+ return node.props ? node.props.children : node.children;
531
533
  }
532
534
 
533
535
  function hasValidReactChildren(children) {
@@ -875,7 +877,7 @@ define(['exports', 'react'], function (exports, react) { 'use strict';
875
877
  }
876
878
 
877
879
  isInitial.current = false;
878
- }, [i18n]);
880
+ }, [i18n, keyPrefix]);
879
881
  var ret = [t, i18n, ready];
880
882
  ret.t = t;
881
883
  ret.i18n = i18n;
@@ -1 +1 @@
1
- define(["exports","react"],(function(e,n){"use strict";function t(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 r(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,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}function s(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var r,a,i=[],o=!0,c=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(c)throw a}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var l={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function p(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(l[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var a=new RegExp(f),i=null;null!==(i=a.exec(e));)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(n.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return n}var d=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,m=Object.create(null);var h,v=function(e,n){n||(n={}),n.components||(n.components=m);var t,r=[],a=[],i=-1,o=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(d,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),d=s+c.length,m=e.charAt(d);if(f){var h=p(c);return i<0?(r.push(h),r):((u=a[i]).children.push(h),r)}if(l&&(i++,"tag"===(t=p(c)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(d,e.indexOf("<",d))}),0===i&&r.push(t),(u=a[i-1])&&u.children.push(t),a[i]=t),(!l||t.voidElement)&&(i>-1&&(t.voidElement||t.name===c.slice(2,-1))&&(i--,t=-1===i?r:a[i]),!o&&"<"!==m&&m)){u=-1===i?r:a[i].children;var v=e.indexOf("<",d),y=e.slice(d,-1===v?void 0:v);g.test(y)&&(y=" "),(v>-1&&i+u.length>=0||" "!==y)&&u.push({type:"text",content:y})}})),r},y=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…"},O=function(e){return b[e]},x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(y,O)}},w=n.createContext();function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x=r(r({},x),e)}function S(){return x}var j=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function N(e){h=e}function k(){return h}var I={type:"3rdParty",init:function(e){E(e.options.react),N(e)}};function P(e){return function(n){return new Promise((function(t){var a=C();e.getInitialProps?e.getInitialProps(n).then((function(e){t(r(r({},e),a))})):t(a)}))}}function C(){var e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function R(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var T={};function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&T[n[0]]||("string"==typeof n[0]&&(T[n[0]]=new Date),R.apply(void 0,n))}function L(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function z(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},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=function(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&&(!n.options.resources||n.options.partialBundledLanguages))||!(!o(r,e)||a&&!o(i,e))))}function B(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return A("i18n.languages were undefined or empty",n.languages),!0;var r=void 0!==n.options.ignoreJSONStructure;return r?n.hasLoadedNamespace(e,{precheck:function(n,r){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e))return!1}}):z(e,n,t)}function U(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}var D=["format"],H=["children","count","parent","i18nKey","context","tOptions","values","defaults","components","ns","i18n","t","shouldUnescape"];function K(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function V(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function F(e){return Array.isArray(e)?e:[e]}function W(e,t,i,o,c,s){if(""===t)return[];var u=o.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(u.join("|")).test(t);if(!e&&!l)return[t];var f={};!function e(t){F(t).forEach((function(t){"string"!=typeof t&&(K(t)?e(V(t)):"object"!==a(t)||n.isValidElement(t)||Object.assign(f,t))}))}(e);var p=v("<0>".concat(t,"</0>")),d=r(r({},f),c);function g(e,t,r){var a=V(e),i=h(a,t.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return n.isValidElement(e)}))}(a)&&0===i.length?a:i}function m(e,t,a,i,o){e.dummy&&(e.children=t),a.push(n.cloneElement(e,r(r({},e.props),{},{key:i}),o?void 0:t))}function h(t,c,f){var p=F(t);return F(c).reduce((function(t,c,v){var y,b,O,x=c.children&&c.children[0]&&c.children[0].content&&i.services.interpolator.interpolate(c.children[0].content,d,i.language);if("tag"===c.type){var w=p[parseInt(c.name,10)];!w&&1===f.length&&f[0][c.name]&&(w=f[0][c.name]),w||(w={});var E=0!==Object.keys(c.attrs).length?(y={props:c.attrs},(O=r({},b=w)).props=Object.assign(y.props,b.props),O):w,S=n.isValidElement(E),j=S&&K(c,!0)&&!c.voidElement,N=l&&"object"===a(E)&&E.dummy&&!S,k="object"===a(e)&&null!==e&&Object.hasOwnProperty.call(e,c.name);if("string"==typeof E){var I=i.services.interpolator.interpolate(E,d,i.language);t.push(I)}else if(K(E)||j){m(E,g(E,c,f),t,v)}else if(N){var P=h(p,c.children,f);t.push(n.cloneElement(E,r(r({},E.props),{},{key:v}),P))}else if(Number.isNaN(parseFloat(c.name))){if(k)m(E,g(E,c,f),t,v,c.voidElement);else if(o.transSupportBasicHtmlNodes&&u.indexOf(c.name)>-1)if(c.voidElement)t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)}));else{var C=h(p,c.children,f);t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)},C))}else if(c.voidElement)t.push("<".concat(c.name," />"));else{var R=h(p,c.children,f);t.push("<".concat(c.name,">").concat(R,"</").concat(c.name,">"))}}else if("object"!==a(E)||S)1===c.children.length&&x?t.push(n.cloneElement(E,r(r({},E.props),{},{key:v}),x)):t.push(n.cloneElement(E,r(r({},E.props),{},{key:v})));else{var T=c.children[0]?x:null;T&&t.push(T)}}else if("text"===c.type){var A=o.transWrapTextNodes,L=s?o.unescape(i.services.interpolator.interpolate(c.content,d,i.language)):i.services.interpolator.interpolate(c.content,d,i.language);A?t.push(n.createElement(A,{key:"".concat(c.name,"-").concat(v)},L)):t.push(L)}return t}),[])}return V(h([{dummy:!0,children:e||[]}],p,F(e||[]))[0])}var M=function(e,t){var r=n.useRef();return n.useEffect((function(){r.current=t?r.current:e}),[e,t]),r.current};function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.i18n,i=n.useContext(w)||{},o=i.i18n,c=i.defaultNS,u=a||o||k();if(u&&!u.reportNamespaces&&(u.reportNamespaces=new j),!u){A("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}u.options.react&&void 0!==u.options.react.wait&&A("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=r(r(r({},S()),u.options.react),t),d=p.useSuspense,g=p.keyPrefix,m=e||c||u.options&&u.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],u.reportNamespaces.addUsedNamespaces&&u.reportNamespaces.addUsedNamespaces(m);var h=(u.isInitialized||u.initializedStoreOnce)&&m.every((function(e){return B(e,u,p)}));function v(){return u.getFixedT(null,"fallback"===p.nsMode?m:m[0],g)}var y=n.useState(v),b=s(y,2),O=b[0],x=b[1],E=m.join(),N=M(E),I=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){I.current&&x(v)}return I.current=!0,h||d||L(u,m,(function(){I.current&&x(v)})),h&&N&&N!==E&&I.current&&x(v),e&&u&&u.on(e,t),n&&u&&u.store.on(n,t),function(){I.current=!1,e&&u&&e.split(" ").forEach((function(e){return u.off(e,t)})),n&&u&&n.split(" ").forEach((function(e){return u.store.off(e,t)}))}}),[u,E]);var P=n.useRef(!0);n.useEffect((function(){I.current&&!P.current&&x(v),P.current=!1}),[u]);var C=[O,u,h];if(C.t=O,C.i18n=u,C.ready=h,h)return C;if(!h&&!d)return C;throw new Promise((function(e){L(u,m,(function(){e()}))}))}var q=["forwardedRef"];var Y=["ns","children"];function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.i18n,i=n.useContext(w)||{},o=i.i18n,c=a||o||k();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}var J=["initialI18nStore","initialLanguage"];e.I18nContext=w,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,a=e.children,i=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(w.Provider,{value:i},a)},e.Trans=function(e){var t=e.children,i=e.count,o=e.parent,s=e.i18nKey,u=e.context,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,v=e.t,y=e.shouldUnescape,b=c(e,H),O=n.useContext(w)||{},x=O.i18n,E=O.defaultNS,j=h||x||k();if(!j)return A("You will need to pass in an i18next instance by using i18nextReactModule"),t;var N=v||j.t.bind(j)||function(e){return e};u&&(f.context=u);var I=r(r({},S()),j.options&&j.options.react),P=m||N.ns||E||j.options&&j.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var C=d||function e(t,r){if(!t)return"";var i="",o=F(t),s=r.transSupportBasicHtmlNodes&&r.transKeepBasicHtmlNodesFor?r.transKeepBasicHtmlNodesFor:[];return o.forEach((function(t,o){if("string"==typeof t)i+="".concat(t);else if(n.isValidElement(t)){var u=Object.keys(t.props).length,l=s.indexOf(t.type)>-1,f=t.props.children;if(!f&&l&&0===u)i+="<".concat(t.type,"/>");else if(f||l&&0===u)if(t.props.i18nIsDynamicList)i+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)i+="<".concat(t.type,">").concat(f,"</").concat(t.type,">");else{var p=e(f,r);i+="<".concat(o,">").concat(p,"</").concat(o,">")}else i+="<".concat(o,"></").concat(o,">")}else if(null===t)R("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===a(t)){var d=t.format,g=c(t,D),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];i+="{{".concat(h,"}}")}else R("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else R("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}}.",t)})),i}(t,I)||I.transEmptyNodeValue||s,T=I.hashTransKey,L=s||(T?T(C):C),z=p?f.interpolation:{interpolation:r(r({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},B=r(r(r(r({},f),{},{count:i},p),z),{},{defaultValue:C,ns:P}),U=W(g||t,L?N(L,B):C,j,I,B,y),K=void 0!==o?o:I.defaultTransParent;return K?n.createElement(K,b,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=s($(n,c(e,Y)),3),a=r[0],i=r[1],o=r[2];return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=P,e.date=function(){return""},e.getDefaults=S,e.getI18n=k,e.getInitialProps=C,e.initReactI18next=I,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=E,e.setI18n=N,e.time=function(){return""},e.useSSR=_,e.useTranslation=$,e.withSSR=function(){return function(e){function t(t){var a=t.initialI18nStore,i=t.initialLanguage,o=c(t,J);return _(a,i),n.createElement(e,r({},o))}return t.getInitialProps=P(e),t.displayName="withI18nextSSR(".concat(U(e),")"),t.WrappedComponent=e,t}},e.withTranslation=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(a){function i(i){var o=i.forwardedRef,u=c(i,q),l=s($(e,r(r({},u),{},{keyPrefix:t.keyPrefix})),3),f=l[0],p=l[1],d=l[2],g=r(r({},u),{},{t:f,i18n:p,tReady:d});return t.withRef&&o?g.ref=o:!t.withRef&&o&&(g.forwardedRef=o),n.createElement(a,g)}i.displayName="withI18nextTranslation(".concat(U(a),")"),i.WrappedComponent=a;return t.withRef?n.forwardRef((function(e,t){return n.createElement(i,Object.assign({},e,{forwardedRef:t}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ define(["exports","react"],(function(e,n){"use strict";function t(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 r(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,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}function s(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var r,a,i=[],o=!0,c=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(c)throw a}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var l={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function p(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(l[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var a=new RegExp(f),i=null;null!==(i=a.exec(e));)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(n.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return n}var d=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,m=Object.create(null);var h,v=function(e,n){n||(n={}),n.components||(n.components=m);var t,r=[],a=[],i=-1,o=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(d,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),d=s+c.length,m=e.charAt(d);if(f){var h=p(c);return i<0?(r.push(h),r):((u=a[i]).children.push(h),r)}if(l&&(i++,"tag"===(t=p(c)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(d,e.indexOf("<",d))}),0===i&&r.push(t),(u=a[i-1])&&u.children.push(t),a[i]=t),(!l||t.voidElement)&&(i>-1&&(t.voidElement||t.name===c.slice(2,-1))&&(i--,t=-1===i?r:a[i]),!o&&"<"!==m&&m)){u=-1===i?r:a[i].children;var v=e.indexOf("<",d),y=e.slice(d,-1===v?void 0:v);g.test(y)&&(y=" "),(v>-1&&i+u.length>=0||" "!==y)&&u.push({type:"text",content:y})}})),r},y=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},O=function(e){return b[e]},x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(y,O)}},w=n.createContext();function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x=r(r({},x),e)}function S(){return x}var j=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function N(e){h=e}function k(){return h}var I={type:"3rdParty",init:function(e){E(e.options.react),N(e)}};function P(e){return function(n){return new Promise((function(t){var a=C();e.getInitialProps?e.getInitialProps(n).then((function(e){t(r(r({},e),a))})):t(a)}))}}function C(){var e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function R(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var T={};function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&T[n[0]]||("string"==typeof n[0]&&(T[n[0]]=new Date),R.apply(void 0,n))}function L(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function z(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},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=function(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&&(!n.options.resources||n.options.partialBundledLanguages))||!(!o(r,e)||a&&!o(i,e))))}function B(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return A("i18n.languages were undefined or empty",n.languages),!0;var r=void 0!==n.options.ignoreJSONStructure;return r?n.hasLoadedNamespace(e,{precheck:function(n,r){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e))return!1}}):z(e,n,t)}function U(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}var D=["format"],F=["children","count","parent","i18nKey","context","tOptions","values","defaults","components","ns","i18n","t","shouldUnescape"];function H(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function K(e){return e?e.props?e.props.children:e.children:[]}function V(e){return Array.isArray(e)?e:[e]}function W(e,t,i,o,c,s){if(""===t)return[];var u=o.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(u.join("|")).test(t);if(!e&&!l)return[t];var f={};!function e(t){V(t).forEach((function(t){"string"!=typeof t&&(H(t)?e(K(t)):"object"!==a(t)||n.isValidElement(t)||Object.assign(f,t))}))}(e);var p=v("<0>".concat(t,"</0>")),d=r(r({},f),c);function g(e,t,r){var a=K(e),i=h(a,t.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return n.isValidElement(e)}))}(a)&&0===i.length?a:i}function m(e,t,a,i,o){e.dummy&&(e.children=t),a.push(n.cloneElement(e,r(r({},e.props),{},{key:i}),o?void 0:t))}function h(t,c,f){var p=V(t);return V(c).reduce((function(t,c,v){var y,b,O,x=c.children&&c.children[0]&&c.children[0].content&&i.services.interpolator.interpolate(c.children[0].content,d,i.language);if("tag"===c.type){var w=p[parseInt(c.name,10)];!w&&1===f.length&&f[0][c.name]&&(w=f[0][c.name]),w||(w={});var E=0!==Object.keys(c.attrs).length?(y={props:c.attrs},(O=r({},b=w)).props=Object.assign(y.props,b.props),O):w,S=n.isValidElement(E),j=S&&H(c,!0)&&!c.voidElement,N=l&&"object"===a(E)&&E.dummy&&!S,k="object"===a(e)&&null!==e&&Object.hasOwnProperty.call(e,c.name);if("string"==typeof E){var I=i.services.interpolator.interpolate(E,d,i.language);t.push(I)}else if(H(E)||j){m(E,g(E,c,f),t,v)}else if(N){var P=h(p,c.children,f);t.push(n.cloneElement(E,r(r({},E.props),{},{key:v}),P))}else if(Number.isNaN(parseFloat(c.name))){if(k)m(E,g(E,c,f),t,v,c.voidElement);else if(o.transSupportBasicHtmlNodes&&u.indexOf(c.name)>-1)if(c.voidElement)t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)}));else{var C=h(p,c.children,f);t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)},C))}else if(c.voidElement)t.push("<".concat(c.name," />"));else{var R=h(p,c.children,f);t.push("<".concat(c.name,">").concat(R,"</").concat(c.name,">"))}}else if("object"!==a(E)||S)1===c.children.length&&x?t.push(n.cloneElement(E,r(r({},E.props),{},{key:v}),x)):t.push(n.cloneElement(E,r(r({},E.props),{},{key:v})));else{var T=c.children[0]?x:null;T&&t.push(T)}}else if("text"===c.type){var A=o.transWrapTextNodes,L=s?o.unescape(i.services.interpolator.interpolate(c.content,d,i.language)):i.services.interpolator.interpolate(c.content,d,i.language);A?t.push(n.createElement(A,{key:"".concat(c.name,"-").concat(v)},L)):t.push(L)}return t}),[])}return K(h([{dummy:!0,children:e||[]}],p,V(e||[]))[0])}var M=function(e,t){var r=n.useRef();return n.useEffect((function(){r.current=t?r.current:e}),[e,t]),r.current};function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.i18n,i=n.useContext(w)||{},o=i.i18n,c=i.defaultNS,u=a||o||k();if(u&&!u.reportNamespaces&&(u.reportNamespaces=new j),!u){A("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}u.options.react&&void 0!==u.options.react.wait&&A("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=r(r(r({},S()),u.options.react),t),d=p.useSuspense,g=p.keyPrefix,m=e||c||u.options&&u.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],u.reportNamespaces.addUsedNamespaces&&u.reportNamespaces.addUsedNamespaces(m);var h=(u.isInitialized||u.initializedStoreOnce)&&m.every((function(e){return B(e,u,p)}));function v(){return u.getFixedT(null,"fallback"===p.nsMode?m:m[0],g)}var y=n.useState(v),b=s(y,2),O=b[0],x=b[1],E=m.join(),N=M(E),I=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){I.current&&x(v)}return I.current=!0,h||d||L(u,m,(function(){I.current&&x(v)})),h&&N&&N!==E&&I.current&&x(v),e&&u&&u.on(e,t),n&&u&&u.store.on(n,t),function(){I.current=!1,e&&u&&e.split(" ").forEach((function(e){return u.off(e,t)})),n&&u&&n.split(" ").forEach((function(e){return u.store.off(e,t)}))}}),[u,E]);var P=n.useRef(!0);n.useEffect((function(){I.current&&!P.current&&x(v),P.current=!1}),[u,g]);var C=[O,u,h];if(C.t=O,C.i18n=u,C.ready=h,h)return C;if(!h&&!d)return C;throw new Promise((function(e){L(u,m,(function(){e()}))}))}var q=["forwardedRef"];var Y=["ns","children"];function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.i18n,i=n.useContext(w)||{},o=i.i18n,c=a||o||k();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}var J=["initialI18nStore","initialLanguage"];e.I18nContext=w,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,a=e.children,i=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(w.Provider,{value:i},a)},e.Trans=function(e){var t=e.children,i=e.count,o=e.parent,s=e.i18nKey,u=e.context,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,v=e.t,y=e.shouldUnescape,b=c(e,F),O=n.useContext(w)||{},x=O.i18n,E=O.defaultNS,j=h||x||k();if(!j)return A("You will need to pass in an i18next instance by using i18nextReactModule"),t;var N=v||j.t.bind(j)||function(e){return e};u&&(f.context=u);var I=r(r({},S()),j.options&&j.options.react),P=m||N.ns||E||j.options&&j.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var C=d||function e(t,r){if(!t)return"";var i="",o=V(t),s=r.transSupportBasicHtmlNodes&&r.transKeepBasicHtmlNodesFor?r.transKeepBasicHtmlNodesFor:[];return o.forEach((function(t,o){if("string"==typeof t)i+="".concat(t);else if(n.isValidElement(t)){var u=Object.keys(t.props).length,l=s.indexOf(t.type)>-1,f=t.props.children;if(!f&&l&&0===u)i+="<".concat(t.type,"/>");else if(f||l&&0===u)if(t.props.i18nIsDynamicList)i+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)i+="<".concat(t.type,">").concat(f,"</").concat(t.type,">");else{var p=e(f,r);i+="<".concat(o,">").concat(p,"</").concat(o,">")}else i+="<".concat(o,"></").concat(o,">")}else if(null===t)R("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===a(t)){var d=t.format,g=c(t,D),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];i+="{{".concat(h,"}}")}else R("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else R("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}}.",t)})),i}(t,I)||I.transEmptyNodeValue||s,T=I.hashTransKey,L=s||(T?T(C):C),z=p?f.interpolation:{interpolation:r(r({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},B=r(r(r(r({},f),{},{count:i},p),z),{},{defaultValue:C,ns:P}),U=W(g||t,L?N(L,B):C,j,I,B,y),H=void 0!==o?o:I.defaultTransParent;return H?n.createElement(H,b,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=s($(n,c(e,Y)),3),a=r[0],i=r[1],o=r[2];return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=P,e.date=function(){return""},e.getDefaults=S,e.getI18n=k,e.getInitialProps=C,e.initReactI18next=I,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=E,e.setI18n=N,e.time=function(){return""},e.useSSR=_,e.useTranslation=$,e.withSSR=function(){return function(e){function t(t){var a=t.initialI18nStore,i=t.initialLanguage,o=c(t,J);return _(a,i),n.createElement(e,r({},o))}return t.getInitialProps=P(e),t.displayName="withI18nextSSR(".concat(U(e),")"),t.WrappedComponent=e,t}},e.withTranslation=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(a){function i(i){var o=i.forwardedRef,u=c(i,q),l=s($(e,r(r({},u),{},{keyPrefix:t.keyPrefix})),3),f=l[0],p=l[1],d=l[2],g=r(r({},u),{},{t:f,i18n:p,tReady:d});return t.withRef&&o?g.ref=o:!t.withRef&&o&&(g.forwardedRef=o),n.createElement(a,g)}i.displayName="withI18nextTranslation(".concat(U(a),")"),i.WrappedComponent=a;return t.withRef?n.forwardRef((function(e,t){return n.createElement(i,Object.assign({},e,{forwardedRef:t}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -38,7 +38,7 @@ function hasChildren(node, checkLength) {
38
38
 
39
39
  function getChildren(node) {
40
40
  if (!node) return [];
41
- return node && node.children ? node.children : node.props && node.props.children;
41
+ return node.props ? node.props.children : node.children;
42
42
  }
43
43
 
44
44
  function hasValidReactChildren(children) {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.unescape = void 0;
7
- var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
7
+ var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
8
8
  var htmlEntities = {
9
9
  '&amp;': '&',
10
10
  '&#38;': '&',
@@ -23,7 +23,9 @@ var htmlEntities = {
23
23
  '&reg;': '®',
24
24
  '&#174;': '®',
25
25
  '&hellip;': '…',
26
- '&#8230;': '…'
26
+ '&#8230;': '…',
27
+ '&#x2F;': '/',
28
+ '&#47;': '/'
27
29
  };
28
30
 
29
31
  var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
@@ -117,7 +117,7 @@ function useTranslation(ns) {
117
117
  }
118
118
 
119
119
  isInitial.current = false;
120
- }, [i18n]);
120
+ }, [i18n, keyPrefix]);
121
121
  var ret = [t, i18n, ready];
122
122
  ret.t = t;
123
123
  ret.i18n = i18n;
package/dist/es/Trans.js CHANGED
@@ -22,7 +22,7 @@ function hasChildren(node, checkLength) {
22
22
 
23
23
  function getChildren(node) {
24
24
  if (!node) return [];
25
- return node && node.children ? node.children : node.props && node.props.children;
25
+ return node.props ? node.props.children : node.children;
26
26
  }
27
27
 
28
28
  function hasValidReactChildren(children) {
@@ -1,4 +1,4 @@
1
- var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
1
+ var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
2
2
  var htmlEntities = {
3
3
  '&amp;': '&',
4
4
  '&#38;': '&',
@@ -17,7 +17,9 @@ var htmlEntities = {
17
17
  '&reg;': '®',
18
18
  '&#174;': '®',
19
19
  '&hellip;': '…',
20
- '&#8230;': '…'
20
+ '&#8230;': '…',
21
+ '&#x2F;': '/',
22
+ '&#47;': '/'
21
23
  };
22
24
 
23
25
  var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
@@ -105,7 +105,7 @@ export function useTranslation(ns) {
105
105
  }
106
106
 
107
107
  isInitial.current = false;
108
- }, [i18n]);
108
+ }, [i18n, keyPrefix]);
109
109
  var ret = [t, i18n, ready];
110
110
  ret.t = t;
111
111
  ret.i18n = i18n;
@@ -318,7 +318,7 @@
318
318
  }
319
319
  };
320
320
 
321
- var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
321
+ var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
322
322
  var htmlEntities = {
323
323
  '&amp;': '&',
324
324
  '&#38;': '&',
@@ -337,7 +337,9 @@
337
337
  '&reg;': '®',
338
338
  '&#174;': '®',
339
339
  '&hellip;': '…',
340
- '&#8230;': '…'
340
+ '&#8230;': '…',
341
+ '&#x2F;': '/',
342
+ '&#47;': '/'
341
343
  };
342
344
 
343
345
  var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
@@ -531,7 +533,7 @@
531
533
 
532
534
  function getChildren(node) {
533
535
  if (!node) return [];
534
- return node && node.children ? node.children : node.props && node.props.children;
536
+ return node.props ? node.props.children : node.children;
535
537
  }
536
538
 
537
539
  function hasValidReactChildren(children) {
@@ -879,7 +881,7 @@
879
881
  }
880
882
 
881
883
  isInitial.current = false;
882
- }, [i18n]);
884
+ }, [i18n, keyPrefix]);
883
885
  var ret = [t, i18n, ready];
884
886
  ret.t = t;
885
887
  ret.i18n = i18n;
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(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 r(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,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}function s(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var r,a,i=[],o=!0,c=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(c)throw a}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var l={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function p(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(l[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var a=new RegExp(f),i=null;null!==(i=a.exec(e));)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(n.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return n}var d=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,m=Object.create(null);var h,v=function(e,n){n||(n={}),n.components||(n.components=m);var t,r=[],a=[],i=-1,o=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(d,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),d=s+c.length,m=e.charAt(d);if(f){var h=p(c);return i<0?(r.push(h),r):((u=a[i]).children.push(h),r)}if(l&&(i++,"tag"===(t=p(c)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(d,e.indexOf("<",d))}),0===i&&r.push(t),(u=a[i-1])&&u.children.push(t),a[i]=t),(!l||t.voidElement)&&(i>-1&&(t.voidElement||t.name===c.slice(2,-1))&&(i--,t=-1===i?r:a[i]),!o&&"<"!==m&&m)){u=-1===i?r:a[i].children;var v=e.indexOf("<",d),y=e.slice(d,-1===v?void 0:v);g.test(y)&&(y=" "),(v>-1&&i+u.length>=0||" "!==y)&&u.push({type:"text",content:y})}})),r},y=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…"},O=function(e){return b[e]},x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(y,O)}},w=n.createContext();function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x=r(r({},x),e)}function E(){return x}var S=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function N(e){h=e}function k(){return h}var I={type:"3rdParty",init:function(e){j(e.options.react),N(e)}};function P(e){return function(n){return new Promise((function(t){var a=R();e.getInitialProps?e.getInitialProps(n).then((function(e){t(r(r({},e),a))})):t(a)}))}}function R(){var e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function C(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var T={};function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&T[n[0]]||("string"==typeof n[0]&&(T[n[0]]=new Date),C.apply(void 0,n))}function L(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function z(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},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=function(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&&(!n.options.resources||n.options.partialBundledLanguages))||!(!o(r,e)||a&&!o(i,e))))}function B(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return A("i18n.languages were undefined or empty",n.languages),!0;var r=void 0!==n.options.ignoreJSONStructure;return r?n.hasLoadedNamespace(e,{precheck:function(n,r){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e))return!1}}):z(e,n,t)}function U(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}var D=["format"],H=["children","count","parent","i18nKey","context","tOptions","values","defaults","components","ns","i18n","t","shouldUnescape"];function K(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function V(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function F(e){return Array.isArray(e)?e:[e]}function W(e,t,i,o,c,s){if(""===t)return[];var u=o.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(u.join("|")).test(t);if(!e&&!l)return[t];var f={};!function e(t){F(t).forEach((function(t){"string"!=typeof t&&(K(t)?e(V(t)):"object"!==a(t)||n.isValidElement(t)||Object.assign(f,t))}))}(e);var p=v("<0>".concat(t,"</0>")),d=r(r({},f),c);function g(e,t,r){var a=V(e),i=h(a,t.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return n.isValidElement(e)}))}(a)&&0===i.length?a:i}function m(e,t,a,i,o){e.dummy&&(e.children=t),a.push(n.cloneElement(e,r(r({},e.props),{},{key:i}),o?void 0:t))}function h(t,c,f){var p=F(t);return F(c).reduce((function(t,c,v){var y,b,O,x=c.children&&c.children[0]&&c.children[0].content&&i.services.interpolator.interpolate(c.children[0].content,d,i.language);if("tag"===c.type){var w=p[parseInt(c.name,10)];!w&&1===f.length&&f[0][c.name]&&(w=f[0][c.name]),w||(w={});var j=0!==Object.keys(c.attrs).length?(y={props:c.attrs},(O=r({},b=w)).props=Object.assign(y.props,b.props),O):w,E=n.isValidElement(j),S=E&&K(c,!0)&&!c.voidElement,N=l&&"object"===a(j)&&j.dummy&&!E,k="object"===a(e)&&null!==e&&Object.hasOwnProperty.call(e,c.name);if("string"==typeof j){var I=i.services.interpolator.interpolate(j,d,i.language);t.push(I)}else if(K(j)||S){m(j,g(j,c,f),t,v)}else if(N){var P=h(p,c.children,f);t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),P))}else if(Number.isNaN(parseFloat(c.name))){if(k)m(j,g(j,c,f),t,v,c.voidElement);else if(o.transSupportBasicHtmlNodes&&u.indexOf(c.name)>-1)if(c.voidElement)t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)}));else{var R=h(p,c.children,f);t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)},R))}else if(c.voidElement)t.push("<".concat(c.name," />"));else{var C=h(p,c.children,f);t.push("<".concat(c.name,">").concat(C,"</").concat(c.name,">"))}}else if("object"!==a(j)||E)1===c.children.length&&x?t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),x)):t.push(n.cloneElement(j,r(r({},j.props),{},{key:v})));else{var T=c.children[0]?x:null;T&&t.push(T)}}else if("text"===c.type){var A=o.transWrapTextNodes,L=s?o.unescape(i.services.interpolator.interpolate(c.content,d,i.language)):i.services.interpolator.interpolate(c.content,d,i.language);A?t.push(n.createElement(A,{key:"".concat(c.name,"-").concat(v)},L)):t.push(L)}return t}),[])}return V(h([{dummy:!0,children:e||[]}],p,F(e||[]))[0])}var M=function(e,t){var r=n.useRef();return n.useEffect((function(){r.current=t?r.current:e}),[e,t]),r.current};function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.i18n,i=n.useContext(w)||{},o=i.i18n,c=i.defaultNS,u=a||o||k();if(u&&!u.reportNamespaces&&(u.reportNamespaces=new S),!u){A("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}u.options.react&&void 0!==u.options.react.wait&&A("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=r(r(r({},E()),u.options.react),t),d=p.useSuspense,g=p.keyPrefix,m=e||c||u.options&&u.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],u.reportNamespaces.addUsedNamespaces&&u.reportNamespaces.addUsedNamespaces(m);var h=(u.isInitialized||u.initializedStoreOnce)&&m.every((function(e){return B(e,u,p)}));function v(){return u.getFixedT(null,"fallback"===p.nsMode?m:m[0],g)}var y=n.useState(v),b=s(y,2),O=b[0],x=b[1],j=m.join(),N=M(j),I=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){I.current&&x(v)}return I.current=!0,h||d||L(u,m,(function(){I.current&&x(v)})),h&&N&&N!==j&&I.current&&x(v),e&&u&&u.on(e,t),n&&u&&u.store.on(n,t),function(){I.current=!1,e&&u&&e.split(" ").forEach((function(e){return u.off(e,t)})),n&&u&&n.split(" ").forEach((function(e){return u.store.off(e,t)}))}}),[u,j]);var P=n.useRef(!0);n.useEffect((function(){I.current&&!P.current&&x(v),P.current=!1}),[u]);var R=[O,u,h];if(R.t=O,R.i18n=u,R.ready=h,h)return R;if(!h&&!d)return R;throw new Promise((function(e){L(u,m,(function(){e()}))}))}var q=["forwardedRef"];var Y=["ns","children"];function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.i18n,i=n.useContext(w)||{},o=i.i18n,c=a||o||k();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}var J=["initialI18nStore","initialLanguage"];e.I18nContext=w,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,a=e.children,i=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(w.Provider,{value:i},a)},e.Trans=function(e){var t=e.children,i=e.count,o=e.parent,s=e.i18nKey,u=e.context,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,v=e.t,y=e.shouldUnescape,b=c(e,H),O=n.useContext(w)||{},x=O.i18n,j=O.defaultNS,S=h||x||k();if(!S)return A("You will need to pass in an i18next instance by using i18nextReactModule"),t;var N=v||S.t.bind(S)||function(e){return e};u&&(f.context=u);var I=r(r({},E()),S.options&&S.options.react),P=m||N.ns||j||S.options&&S.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var R=d||function e(t,r){if(!t)return"";var i="",o=F(t),s=r.transSupportBasicHtmlNodes&&r.transKeepBasicHtmlNodesFor?r.transKeepBasicHtmlNodesFor:[];return o.forEach((function(t,o){if("string"==typeof t)i+="".concat(t);else if(n.isValidElement(t)){var u=Object.keys(t.props).length,l=s.indexOf(t.type)>-1,f=t.props.children;if(!f&&l&&0===u)i+="<".concat(t.type,"/>");else if(f||l&&0===u)if(t.props.i18nIsDynamicList)i+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)i+="<".concat(t.type,">").concat(f,"</").concat(t.type,">");else{var p=e(f,r);i+="<".concat(o,">").concat(p,"</").concat(o,">")}else i+="<".concat(o,"></").concat(o,">")}else if(null===t)C("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===a(t)){var d=t.format,g=c(t,D),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];i+="{{".concat(h,"}}")}else C("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else C("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}}.",t)})),i}(t,I)||I.transEmptyNodeValue||s,T=I.hashTransKey,L=s||(T?T(R):R),z=p?f.interpolation:{interpolation:r(r({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},B=r(r(r(r({},f),{},{count:i},p),z),{},{defaultValue:R,ns:P}),U=W(g||t,L?N(L,B):R,S,I,B,y),K=void 0!==o?o:I.defaultTransParent;return K?n.createElement(K,b,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=s($(n,c(e,Y)),3),a=r[0],i=r[1],o=r[2];return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=P,e.date=function(){return""},e.getDefaults=E,e.getI18n=k,e.getInitialProps=R,e.initReactI18next=I,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=j,e.setI18n=N,e.time=function(){return""},e.useSSR=_,e.useTranslation=$,e.withSSR=function(){return function(e){function t(t){var a=t.initialI18nStore,i=t.initialLanguage,o=c(t,J);return _(a,i),n.createElement(e,r({},o))}return t.getInitialProps=P(e),t.displayName="withI18nextSSR(".concat(U(e),")"),t.WrappedComponent=e,t}},e.withTranslation=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(a){function i(i){var o=i.forwardedRef,u=c(i,q),l=s($(e,r(r({},u),{},{keyPrefix:t.keyPrefix})),3),f=l[0],p=l[1],d=l[2],g=r(r({},u),{},{t:f,i18n:p,tReady:d});return t.withRef&&o?g.ref=o:!t.withRef&&o&&(g.forwardedRef=o),n.createElement(a,g)}i.displayName="withI18nextTranslation(".concat(U(a),")"),i.WrappedComponent=a;return t.withRef?n.forwardRef((function(e,t){return n.createElement(i,Object.assign({},e,{forwardedRef:t}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(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 r(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,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}function s(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var r,a,i=[],o=!0,c=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(c)throw a}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var l={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function p(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(l[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var a=new RegExp(f),i=null;null!==(i=a.exec(e));)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(n.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return n}var d=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,m=Object.create(null);var h,v=function(e,n){n||(n={}),n.components||(n.components=m);var t,r=[],a=[],i=-1,o=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(d,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),d=s+c.length,m=e.charAt(d);if(f){var h=p(c);return i<0?(r.push(h),r):((u=a[i]).children.push(h),r)}if(l&&(i++,"tag"===(t=p(c)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(d,e.indexOf("<",d))}),0===i&&r.push(t),(u=a[i-1])&&u.children.push(t),a[i]=t),(!l||t.voidElement)&&(i>-1&&(t.voidElement||t.name===c.slice(2,-1))&&(i--,t=-1===i?r:a[i]),!o&&"<"!==m&&m)){u=-1===i?r:a[i].children;var v=e.indexOf("<",d),y=e.slice(d,-1===v?void 0:v);g.test(y)&&(y=" "),(v>-1&&i+u.length>=0||" "!==y)&&u.push({type:"text",content:y})}})),r},y=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},O=function(e){return b[e]},x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(y,O)}},w=n.createContext();function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x=r(r({},x),e)}function E(){return x}var S=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function N(e){h=e}function k(){return h}var I={type:"3rdParty",init:function(e){j(e.options.react),N(e)}};function P(e){return function(n){return new Promise((function(t){var a=R();e.getInitialProps?e.getInitialProps(n).then((function(e){t(r(r({},e),a))})):t(a)}))}}function R(){var e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function C(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var T={};function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&T[n[0]]||("string"==typeof n[0]&&(T[n[0]]=new Date),C.apply(void 0,n))}function L(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function z(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},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=function(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&&(!n.options.resources||n.options.partialBundledLanguages))||!(!o(r,e)||a&&!o(i,e))))}function B(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return A("i18n.languages were undefined or empty",n.languages),!0;var r=void 0!==n.options.ignoreJSONStructure;return r?n.hasLoadedNamespace(e,{precheck:function(n,r){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e))return!1}}):z(e,n,t)}function U(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}var D=["format"],F=["children","count","parent","i18nKey","context","tOptions","values","defaults","components","ns","i18n","t","shouldUnescape"];function H(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function K(e){return e?e.props?e.props.children:e.children:[]}function V(e){return Array.isArray(e)?e:[e]}function W(e,t,i,o,c,s){if(""===t)return[];var u=o.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(u.join("|")).test(t);if(!e&&!l)return[t];var f={};!function e(t){V(t).forEach((function(t){"string"!=typeof t&&(H(t)?e(K(t)):"object"!==a(t)||n.isValidElement(t)||Object.assign(f,t))}))}(e);var p=v("<0>".concat(t,"</0>")),d=r(r({},f),c);function g(e,t,r){var a=K(e),i=h(a,t.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return n.isValidElement(e)}))}(a)&&0===i.length?a:i}function m(e,t,a,i,o){e.dummy&&(e.children=t),a.push(n.cloneElement(e,r(r({},e.props),{},{key:i}),o?void 0:t))}function h(t,c,f){var p=V(t);return V(c).reduce((function(t,c,v){var y,b,O,x=c.children&&c.children[0]&&c.children[0].content&&i.services.interpolator.interpolate(c.children[0].content,d,i.language);if("tag"===c.type){var w=p[parseInt(c.name,10)];!w&&1===f.length&&f[0][c.name]&&(w=f[0][c.name]),w||(w={});var j=0!==Object.keys(c.attrs).length?(y={props:c.attrs},(O=r({},b=w)).props=Object.assign(y.props,b.props),O):w,E=n.isValidElement(j),S=E&&H(c,!0)&&!c.voidElement,N=l&&"object"===a(j)&&j.dummy&&!E,k="object"===a(e)&&null!==e&&Object.hasOwnProperty.call(e,c.name);if("string"==typeof j){var I=i.services.interpolator.interpolate(j,d,i.language);t.push(I)}else if(H(j)||S){m(j,g(j,c,f),t,v)}else if(N){var P=h(p,c.children,f);t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),P))}else if(Number.isNaN(parseFloat(c.name))){if(k)m(j,g(j,c,f),t,v,c.voidElement);else if(o.transSupportBasicHtmlNodes&&u.indexOf(c.name)>-1)if(c.voidElement)t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)}));else{var R=h(p,c.children,f);t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)},R))}else if(c.voidElement)t.push("<".concat(c.name," />"));else{var C=h(p,c.children,f);t.push("<".concat(c.name,">").concat(C,"</").concat(c.name,">"))}}else if("object"!==a(j)||E)1===c.children.length&&x?t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),x)):t.push(n.cloneElement(j,r(r({},j.props),{},{key:v})));else{var T=c.children[0]?x:null;T&&t.push(T)}}else if("text"===c.type){var A=o.transWrapTextNodes,L=s?o.unescape(i.services.interpolator.interpolate(c.content,d,i.language)):i.services.interpolator.interpolate(c.content,d,i.language);A?t.push(n.createElement(A,{key:"".concat(c.name,"-").concat(v)},L)):t.push(L)}return t}),[])}return K(h([{dummy:!0,children:e||[]}],p,V(e||[]))[0])}var M=function(e,t){var r=n.useRef();return n.useEffect((function(){r.current=t?r.current:e}),[e,t]),r.current};function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.i18n,i=n.useContext(w)||{},o=i.i18n,c=i.defaultNS,u=a||o||k();if(u&&!u.reportNamespaces&&(u.reportNamespaces=new S),!u){A("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}u.options.react&&void 0!==u.options.react.wait&&A("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=r(r(r({},E()),u.options.react),t),d=p.useSuspense,g=p.keyPrefix,m=e||c||u.options&&u.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],u.reportNamespaces.addUsedNamespaces&&u.reportNamespaces.addUsedNamespaces(m);var h=(u.isInitialized||u.initializedStoreOnce)&&m.every((function(e){return B(e,u,p)}));function v(){return u.getFixedT(null,"fallback"===p.nsMode?m:m[0],g)}var y=n.useState(v),b=s(y,2),O=b[0],x=b[1],j=m.join(),N=M(j),I=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){I.current&&x(v)}return I.current=!0,h||d||L(u,m,(function(){I.current&&x(v)})),h&&N&&N!==j&&I.current&&x(v),e&&u&&u.on(e,t),n&&u&&u.store.on(n,t),function(){I.current=!1,e&&u&&e.split(" ").forEach((function(e){return u.off(e,t)})),n&&u&&n.split(" ").forEach((function(e){return u.store.off(e,t)}))}}),[u,j]);var P=n.useRef(!0);n.useEffect((function(){I.current&&!P.current&&x(v),P.current=!1}),[u,g]);var R=[O,u,h];if(R.t=O,R.i18n=u,R.ready=h,h)return R;if(!h&&!d)return R;throw new Promise((function(e){L(u,m,(function(){e()}))}))}var q=["forwardedRef"];var Y=["ns","children"];function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.i18n,i=n.useContext(w)||{},o=i.i18n,c=a||o||k();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}var J=["initialI18nStore","initialLanguage"];e.I18nContext=w,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,a=e.children,i=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(w.Provider,{value:i},a)},e.Trans=function(e){var t=e.children,i=e.count,o=e.parent,s=e.i18nKey,u=e.context,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,v=e.t,y=e.shouldUnescape,b=c(e,F),O=n.useContext(w)||{},x=O.i18n,j=O.defaultNS,S=h||x||k();if(!S)return A("You will need to pass in an i18next instance by using i18nextReactModule"),t;var N=v||S.t.bind(S)||function(e){return e};u&&(f.context=u);var I=r(r({},E()),S.options&&S.options.react),P=m||N.ns||j||S.options&&S.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var R=d||function e(t,r){if(!t)return"";var i="",o=V(t),s=r.transSupportBasicHtmlNodes&&r.transKeepBasicHtmlNodesFor?r.transKeepBasicHtmlNodesFor:[];return o.forEach((function(t,o){if("string"==typeof t)i+="".concat(t);else if(n.isValidElement(t)){var u=Object.keys(t.props).length,l=s.indexOf(t.type)>-1,f=t.props.children;if(!f&&l&&0===u)i+="<".concat(t.type,"/>");else if(f||l&&0===u)if(t.props.i18nIsDynamicList)i+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)i+="<".concat(t.type,">").concat(f,"</").concat(t.type,">");else{var p=e(f,r);i+="<".concat(o,">").concat(p,"</").concat(o,">")}else i+="<".concat(o,"></").concat(o,">")}else if(null===t)C("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===a(t)){var d=t.format,g=c(t,D),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];i+="{{".concat(h,"}}")}else C("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else C("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}}.",t)})),i}(t,I)||I.transEmptyNodeValue||s,T=I.hashTransKey,L=s||(T?T(R):R),z=p?f.interpolation:{interpolation:r(r({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},B=r(r(r(r({},f),{},{count:i},p),z),{},{defaultValue:R,ns:P}),U=W(g||t,L?N(L,B):R,S,I,B,y),H=void 0!==o?o:I.defaultTransParent;return H?n.createElement(H,b,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=s($(n,c(e,Y)),3),a=r[0],i=r[1],o=r[2];return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=P,e.date=function(){return""},e.getDefaults=E,e.getI18n=k,e.getInitialProps=R,e.initReactI18next=I,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=j,e.setI18n=N,e.time=function(){return""},e.useSSR=_,e.useTranslation=$,e.withSSR=function(){return function(e){function t(t){var a=t.initialI18nStore,i=t.initialLanguage,o=c(t,J);return _(a,i),n.createElement(e,r({},o))}return t.getInitialProps=P(e),t.displayName="withI18nextSSR(".concat(U(e),")"),t.WrappedComponent=e,t}},e.withTranslation=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(a){function i(i){var o=i.forwardedRef,u=c(i,q),l=s($(e,r(r({},u),{},{keyPrefix:t.keyPrefix})),3),f=l[0],p=l[1],d=l[2],g=r(r({},u),{},{t:f,i18n:p,tReady:d});return t.withRef&&o?g.ref=o:!t.withRef&&o&&(g.forwardedRef=o),n.createElement(a,g)}i.displayName="withI18nextTranslation(".concat(U(a),")"),i.WrappedComponent=a;return t.withRef?n.forwardRef((function(e,t){return n.createElement(i,Object.assign({},e,{forwardedRef:t}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
package/index.d.ts CHANGED
@@ -55,6 +55,8 @@ export interface UseTranslationOptions {
55
55
  i18n?: i18n;
56
56
  useSuspense?: boolean;
57
57
  keyPrefix?: string;
58
+ bindI18n?: string | false;
59
+ // other of these options might also work: https://github.com/i18next/i18next/blob/master/index.d.ts#L127
58
60
  }
59
61
  export type UseTranslationResponse = [TFunction, i18n, boolean] & {
60
62
  t: TFunction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-i18next",
3
- "version": "11.18.2",
3
+ "version": "11.18.5",
4
4
  "description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "types": "./index.d.ts",
package/react-i18next.js CHANGED
@@ -318,7 +318,7 @@
318
318
  }
319
319
  };
320
320
 
321
- var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
321
+ var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
322
322
  var htmlEntities = {
323
323
  '&amp;': '&',
324
324
  '&#38;': '&',
@@ -337,7 +337,9 @@
337
337
  '&reg;': '®',
338
338
  '&#174;': '®',
339
339
  '&hellip;': '…',
340
- '&#8230;': '…'
340
+ '&#8230;': '…',
341
+ '&#x2F;': '/',
342
+ '&#47;': '/'
341
343
  };
342
344
 
343
345
  var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
@@ -531,7 +533,7 @@
531
533
 
532
534
  function getChildren(node) {
533
535
  if (!node) return [];
534
- return node && node.children ? node.children : node.props && node.props.children;
536
+ return node.props ? node.props.children : node.children;
535
537
  }
536
538
 
537
539
  function hasValidReactChildren(children) {
@@ -879,7 +881,7 @@
879
881
  }
880
882
 
881
883
  isInitial.current = false;
882
- }, [i18n]);
884
+ }, [i18n, keyPrefix]);
883
885
  var ret = [t, i18n, ready];
884
886
  ret.t = t;
885
887
  ret.i18n = i18n;
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(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 r(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,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}function s(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var r,a,i=[],o=!0,c=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(c)throw a}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var l={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function p(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(l[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var a=new RegExp(f),i=null;null!==(i=a.exec(e));)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(n.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return n}var d=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,m=Object.create(null);var h,v=function(e,n){n||(n={}),n.components||(n.components=m);var t,r=[],a=[],i=-1,o=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(d,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),d=s+c.length,m=e.charAt(d);if(f){var h=p(c);return i<0?(r.push(h),r):((u=a[i]).children.push(h),r)}if(l&&(i++,"tag"===(t=p(c)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(d,e.indexOf("<",d))}),0===i&&r.push(t),(u=a[i-1])&&u.children.push(t),a[i]=t),(!l||t.voidElement)&&(i>-1&&(t.voidElement||t.name===c.slice(2,-1))&&(i--,t=-1===i?r:a[i]),!o&&"<"!==m&&m)){u=-1===i?r:a[i].children;var v=e.indexOf("<",d),y=e.slice(d,-1===v?void 0:v);g.test(y)&&(y=" "),(v>-1&&i+u.length>=0||" "!==y)&&u.push({type:"text",content:y})}})),r},y=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…"},O=function(e){return b[e]},x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(y,O)}},w=n.createContext();function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x=r(r({},x),e)}function E(){return x}var S=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function N(e){h=e}function k(){return h}var I={type:"3rdParty",init:function(e){j(e.options.react),N(e)}};function P(e){return function(n){return new Promise((function(t){var a=R();e.getInitialProps?e.getInitialProps(n).then((function(e){t(r(r({},e),a))})):t(a)}))}}function R(){var e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function C(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var T={};function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&T[n[0]]||("string"==typeof n[0]&&(T[n[0]]=new Date),C.apply(void 0,n))}function L(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function z(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},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=function(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&&(!n.options.resources||n.options.partialBundledLanguages))||!(!o(r,e)||a&&!o(i,e))))}function B(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return A("i18n.languages were undefined or empty",n.languages),!0;var r=void 0!==n.options.ignoreJSONStructure;return r?n.hasLoadedNamespace(e,{precheck:function(n,r){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e))return!1}}):z(e,n,t)}function U(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}var D=["format"],H=["children","count","parent","i18nKey","context","tOptions","values","defaults","components","ns","i18n","t","shouldUnescape"];function K(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function V(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function F(e){return Array.isArray(e)?e:[e]}function W(e,t,i,o,c,s){if(""===t)return[];var u=o.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(u.join("|")).test(t);if(!e&&!l)return[t];var f={};!function e(t){F(t).forEach((function(t){"string"!=typeof t&&(K(t)?e(V(t)):"object"!==a(t)||n.isValidElement(t)||Object.assign(f,t))}))}(e);var p=v("<0>".concat(t,"</0>")),d=r(r({},f),c);function g(e,t,r){var a=V(e),i=h(a,t.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return n.isValidElement(e)}))}(a)&&0===i.length?a:i}function m(e,t,a,i,o){e.dummy&&(e.children=t),a.push(n.cloneElement(e,r(r({},e.props),{},{key:i}),o?void 0:t))}function h(t,c,f){var p=F(t);return F(c).reduce((function(t,c,v){var y,b,O,x=c.children&&c.children[0]&&c.children[0].content&&i.services.interpolator.interpolate(c.children[0].content,d,i.language);if("tag"===c.type){var w=p[parseInt(c.name,10)];!w&&1===f.length&&f[0][c.name]&&(w=f[0][c.name]),w||(w={});var j=0!==Object.keys(c.attrs).length?(y={props:c.attrs},(O=r({},b=w)).props=Object.assign(y.props,b.props),O):w,E=n.isValidElement(j),S=E&&K(c,!0)&&!c.voidElement,N=l&&"object"===a(j)&&j.dummy&&!E,k="object"===a(e)&&null!==e&&Object.hasOwnProperty.call(e,c.name);if("string"==typeof j){var I=i.services.interpolator.interpolate(j,d,i.language);t.push(I)}else if(K(j)||S){m(j,g(j,c,f),t,v)}else if(N){var P=h(p,c.children,f);t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),P))}else if(Number.isNaN(parseFloat(c.name))){if(k)m(j,g(j,c,f),t,v,c.voidElement);else if(o.transSupportBasicHtmlNodes&&u.indexOf(c.name)>-1)if(c.voidElement)t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)}));else{var R=h(p,c.children,f);t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)},R))}else if(c.voidElement)t.push("<".concat(c.name," />"));else{var C=h(p,c.children,f);t.push("<".concat(c.name,">").concat(C,"</").concat(c.name,">"))}}else if("object"!==a(j)||E)1===c.children.length&&x?t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),x)):t.push(n.cloneElement(j,r(r({},j.props),{},{key:v})));else{var T=c.children[0]?x:null;T&&t.push(T)}}else if("text"===c.type){var A=o.transWrapTextNodes,L=s?o.unescape(i.services.interpolator.interpolate(c.content,d,i.language)):i.services.interpolator.interpolate(c.content,d,i.language);A?t.push(n.createElement(A,{key:"".concat(c.name,"-").concat(v)},L)):t.push(L)}return t}),[])}return V(h([{dummy:!0,children:e||[]}],p,F(e||[]))[0])}var M=function(e,t){var r=n.useRef();return n.useEffect((function(){r.current=t?r.current:e}),[e,t]),r.current};function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.i18n,i=n.useContext(w)||{},o=i.i18n,c=i.defaultNS,u=a||o||k();if(u&&!u.reportNamespaces&&(u.reportNamespaces=new S),!u){A("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}u.options.react&&void 0!==u.options.react.wait&&A("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=r(r(r({},E()),u.options.react),t),d=p.useSuspense,g=p.keyPrefix,m=e||c||u.options&&u.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],u.reportNamespaces.addUsedNamespaces&&u.reportNamespaces.addUsedNamespaces(m);var h=(u.isInitialized||u.initializedStoreOnce)&&m.every((function(e){return B(e,u,p)}));function v(){return u.getFixedT(null,"fallback"===p.nsMode?m:m[0],g)}var y=n.useState(v),b=s(y,2),O=b[0],x=b[1],j=m.join(),N=M(j),I=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){I.current&&x(v)}return I.current=!0,h||d||L(u,m,(function(){I.current&&x(v)})),h&&N&&N!==j&&I.current&&x(v),e&&u&&u.on(e,t),n&&u&&u.store.on(n,t),function(){I.current=!1,e&&u&&e.split(" ").forEach((function(e){return u.off(e,t)})),n&&u&&n.split(" ").forEach((function(e){return u.store.off(e,t)}))}}),[u,j]);var P=n.useRef(!0);n.useEffect((function(){I.current&&!P.current&&x(v),P.current=!1}),[u]);var R=[O,u,h];if(R.t=O,R.i18n=u,R.ready=h,h)return R;if(!h&&!d)return R;throw new Promise((function(e){L(u,m,(function(){e()}))}))}var q=["forwardedRef"];var Y=["ns","children"];function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.i18n,i=n.useContext(w)||{},o=i.i18n,c=a||o||k();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}var J=["initialI18nStore","initialLanguage"];e.I18nContext=w,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,a=e.children,i=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(w.Provider,{value:i},a)},e.Trans=function(e){var t=e.children,i=e.count,o=e.parent,s=e.i18nKey,u=e.context,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,v=e.t,y=e.shouldUnescape,b=c(e,H),O=n.useContext(w)||{},x=O.i18n,j=O.defaultNS,S=h||x||k();if(!S)return A("You will need to pass in an i18next instance by using i18nextReactModule"),t;var N=v||S.t.bind(S)||function(e){return e};u&&(f.context=u);var I=r(r({},E()),S.options&&S.options.react),P=m||N.ns||j||S.options&&S.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var R=d||function e(t,r){if(!t)return"";var i="",o=F(t),s=r.transSupportBasicHtmlNodes&&r.transKeepBasicHtmlNodesFor?r.transKeepBasicHtmlNodesFor:[];return o.forEach((function(t,o){if("string"==typeof t)i+="".concat(t);else if(n.isValidElement(t)){var u=Object.keys(t.props).length,l=s.indexOf(t.type)>-1,f=t.props.children;if(!f&&l&&0===u)i+="<".concat(t.type,"/>");else if(f||l&&0===u)if(t.props.i18nIsDynamicList)i+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)i+="<".concat(t.type,">").concat(f,"</").concat(t.type,">");else{var p=e(f,r);i+="<".concat(o,">").concat(p,"</").concat(o,">")}else i+="<".concat(o,"></").concat(o,">")}else if(null===t)C("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===a(t)){var d=t.format,g=c(t,D),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];i+="{{".concat(h,"}}")}else C("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else C("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}}.",t)})),i}(t,I)||I.transEmptyNodeValue||s,T=I.hashTransKey,L=s||(T?T(R):R),z=p?f.interpolation:{interpolation:r(r({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},B=r(r(r(r({},f),{},{count:i},p),z),{},{defaultValue:R,ns:P}),U=W(g||t,L?N(L,B):R,S,I,B,y),K=void 0!==o?o:I.defaultTransParent;return K?n.createElement(K,b,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=s($(n,c(e,Y)),3),a=r[0],i=r[1],o=r[2];return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=P,e.date=function(){return""},e.getDefaults=E,e.getI18n=k,e.getInitialProps=R,e.initReactI18next=I,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=j,e.setI18n=N,e.time=function(){return""},e.useSSR=_,e.useTranslation=$,e.withSSR=function(){return function(e){function t(t){var a=t.initialI18nStore,i=t.initialLanguage,o=c(t,J);return _(a,i),n.createElement(e,r({},o))}return t.getInitialProps=P(e),t.displayName="withI18nextSSR(".concat(U(e),")"),t.WrappedComponent=e,t}},e.withTranslation=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(a){function i(i){var o=i.forwardedRef,u=c(i,q),l=s($(e,r(r({},u),{},{keyPrefix:t.keyPrefix})),3),f=l[0],p=l[1],d=l[2],g=r(r({},u),{},{t:f,i18n:p,tReady:d});return t.withRef&&o?g.ref=o:!t.withRef&&o&&(g.forwardedRef=o),n.createElement(a,g)}i.displayName="withI18nextTranslation(".concat(U(a),")"),i.WrappedComponent=a;return t.withRef?n.forwardRef((function(e,t){return n.createElement(i,Object.assign({},e,{forwardedRef:t}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).ReactI18next={},e.React)}(this,(function(e,n){"use strict";function t(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 r(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(n){o(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,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}function s(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var r,a,i=[],o=!0,c=!1;try{for(t=t.call(e);!(o=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);o=!0);}catch(e){c=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(c)throw a}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var l={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},f=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function p(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(l[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var r=e.indexOf("--\x3e");return{type:"comment",comment:-1!==r?e.slice(4,r):""}}for(var a=new RegExp(f),i=null;null!==(i=a.exec(e));)if(i[0].trim())if(i[1]){var o=i[1].trim(),c=[o,""];o.indexOf("=")>-1&&(c=o.split("=")),n.attrs[c[0]]=c[1],a.lastIndex--}else i[2]&&(n.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return n}var d=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/^\s*$/,m=Object.create(null);var h,v=function(e,n){n||(n={}),n.components||(n.components=m);var t,r=[],a=[],i=-1,o=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");r.push({type:"text",content:-1===c?e:e.substring(0,c)})}return e.replace(d,(function(c,s){if(o){if(c!=="</"+t.name+">")return;o=!1}var u,l="/"!==c.charAt(1),f=c.startsWith("\x3c!--"),d=s+c.length,m=e.charAt(d);if(f){var h=p(c);return i<0?(r.push(h),r):((u=a[i]).children.push(h),r)}if(l&&(i++,"tag"===(t=p(c)).type&&n.components[t.name]&&(t.type="component",o=!0),t.voidElement||o||!m||"<"===m||t.children.push({type:"text",content:e.slice(d,e.indexOf("<",d))}),0===i&&r.push(t),(u=a[i-1])&&u.children.push(t),a[i]=t),(!l||t.voidElement)&&(i>-1&&(t.voidElement||t.name===c.slice(2,-1))&&(i--,t=-1===i?r:a[i]),!o&&"<"!==m&&m)){u=-1===i?r:a[i].children;var v=e.indexOf("<",d),y=e.slice(d,-1===v?void 0:v);g.test(y)&&(y=" "),(v>-1&&i+u.length>=0||" "!==y)&&u.push({type:"text",content:y})}})),r},y=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,b={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},O=function(e){return b[e]},x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:function(e){return e.replace(y,O)}},w=n.createContext();function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x=r(r({},x),e)}function E(){return x}var S=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.usedNamespaces={}}var n,t,r;return n=e,(t=[{key:"addUsedNamespaces",value:function(e){var n=this;e.forEach((function(e){n.usedNamespaces[e]||(n.usedNamespaces[e]=!0)}))}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}])&&i(n.prototype,t),r&&i(n,r),e}();function N(e){h=e}function k(){return h}var I={type:"3rdParty",init:function(e){j(e.options.react),N(e)}};function P(e){return function(n){return new Promise((function(t){var a=R();e.getInitialProps?e.getInitialProps(n).then((function(e){t(r(r({},e),a))})):t(a)}))}}function R(){var e=k(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach((function(t){r[t]={},n.forEach((function(n){r[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=r,t.initialLanguage=e.language,t}function C(){if(console&&console.warn){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];"string"==typeof t[0]&&(t[0]="react-i18next:: ".concat(t[0])),(e=console).warn.apply(e,t)}}var T={};function A(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&T[n[0]]||("string"==typeof n[0]&&(T[n[0]]=new Date),C.apply(void 0,n))}function L(e,n,t){e.loadNamespaces(n,(function(){if(e.isInitialized)t();else{e.on("initialized",(function n(){setTimeout((function(){e.off("initialized",n)}),0),t()}))}}))}function z(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},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=function(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&&(!n.options.resources||n.options.partialBundledLanguages))||!(!o(r,e)||a&&!o(i,e))))}function B(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n.languages||!n.languages.length)return A("i18n.languages were undefined or empty",n.languages),!0;var r=void 0!==n.options.ignoreJSONStructure;return r?n.hasLoadedNamespace(e,{precheck:function(n,r){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!r(n.isLanguageChangingTo,e))return!1}}):z(e,n,t)}function U(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}var D=["format"],F=["children","count","parent","i18nKey","context","tOptions","values","defaults","components","ns","i18n","t","shouldUnescape"];function H(e,n){if(!e)return!1;var t=e.props?e.props.children:e.children;return n?t.length>0:!!t}function K(e){return e?e.props?e.props.children:e.children:[]}function V(e){return Array.isArray(e)?e:[e]}function W(e,t,i,o,c,s){if(""===t)return[];var u=o.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(u.join("|")).test(t);if(!e&&!l)return[t];var f={};!function e(t){V(t).forEach((function(t){"string"!=typeof t&&(H(t)?e(K(t)):"object"!==a(t)||n.isValidElement(t)||Object.assign(f,t))}))}(e);var p=v("<0>".concat(t,"</0>")),d=r(r({},f),c);function g(e,t,r){var a=K(e),i=h(a,t.children,r);return function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every((function(e){return n.isValidElement(e)}))}(a)&&0===i.length?a:i}function m(e,t,a,i,o){e.dummy&&(e.children=t),a.push(n.cloneElement(e,r(r({},e.props),{},{key:i}),o?void 0:t))}function h(t,c,f){var p=V(t);return V(c).reduce((function(t,c,v){var y,b,O,x=c.children&&c.children[0]&&c.children[0].content&&i.services.interpolator.interpolate(c.children[0].content,d,i.language);if("tag"===c.type){var w=p[parseInt(c.name,10)];!w&&1===f.length&&f[0][c.name]&&(w=f[0][c.name]),w||(w={});var j=0!==Object.keys(c.attrs).length?(y={props:c.attrs},(O=r({},b=w)).props=Object.assign(y.props,b.props),O):w,E=n.isValidElement(j),S=E&&H(c,!0)&&!c.voidElement,N=l&&"object"===a(j)&&j.dummy&&!E,k="object"===a(e)&&null!==e&&Object.hasOwnProperty.call(e,c.name);if("string"==typeof j){var I=i.services.interpolator.interpolate(j,d,i.language);t.push(I)}else if(H(j)||S){m(j,g(j,c,f),t,v)}else if(N){var P=h(p,c.children,f);t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),P))}else if(Number.isNaN(parseFloat(c.name))){if(k)m(j,g(j,c,f),t,v,c.voidElement);else if(o.transSupportBasicHtmlNodes&&u.indexOf(c.name)>-1)if(c.voidElement)t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)}));else{var R=h(p,c.children,f);t.push(n.createElement(c.name,{key:"".concat(c.name,"-").concat(v)},R))}else if(c.voidElement)t.push("<".concat(c.name," />"));else{var C=h(p,c.children,f);t.push("<".concat(c.name,">").concat(C,"</").concat(c.name,">"))}}else if("object"!==a(j)||E)1===c.children.length&&x?t.push(n.cloneElement(j,r(r({},j.props),{},{key:v}),x)):t.push(n.cloneElement(j,r(r({},j.props),{},{key:v})));else{var T=c.children[0]?x:null;T&&t.push(T)}}else if("text"===c.type){var A=o.transWrapTextNodes,L=s?o.unescape(i.services.interpolator.interpolate(c.content,d,i.language)):i.services.interpolator.interpolate(c.content,d,i.language);A?t.push(n.createElement(A,{key:"".concat(c.name,"-").concat(v)},L)):t.push(L)}return t}),[])}return K(h([{dummy:!0,children:e||[]}],p,V(e||[]))[0])}var M=function(e,t){var r=n.useRef();return n.useEffect((function(){r.current=t?r.current:e}),[e,t]),r.current};function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.i18n,i=n.useContext(w)||{},o=i.i18n,c=i.defaultNS,u=a||o||k();if(u&&!u.reportNamespaces&&(u.reportNamespaces=new S),!u){A("You will need to pass in an i18next instance by using initReactI18next");var l=function(e){return Array.isArray(e)?e[e.length-1]:e},f=[l,{},!1];return f.t=l,f.i18n={},f.ready=!1,f}u.options.react&&void 0!==u.options.react.wait&&A("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var p=r(r(r({},E()),u.options.react),t),d=p.useSuspense,g=p.keyPrefix,m=e||c||u.options&&u.options.defaultNS;m="string"==typeof m?[m]:m||["translation"],u.reportNamespaces.addUsedNamespaces&&u.reportNamespaces.addUsedNamespaces(m);var h=(u.isInitialized||u.initializedStoreOnce)&&m.every((function(e){return B(e,u,p)}));function v(){return u.getFixedT(null,"fallback"===p.nsMode?m:m[0],g)}var y=n.useState(v),b=s(y,2),O=b[0],x=b[1],j=m.join(),N=M(j),I=n.useRef(!0);n.useEffect((function(){var e=p.bindI18n,n=p.bindI18nStore;function t(){I.current&&x(v)}return I.current=!0,h||d||L(u,m,(function(){I.current&&x(v)})),h&&N&&N!==j&&I.current&&x(v),e&&u&&u.on(e,t),n&&u&&u.store.on(n,t),function(){I.current=!1,e&&u&&e.split(" ").forEach((function(e){return u.off(e,t)})),n&&u&&n.split(" ").forEach((function(e){return u.store.off(e,t)}))}}),[u,j]);var P=n.useRef(!0);n.useEffect((function(){I.current&&!P.current&&x(v),P.current=!1}),[u,g]);var R=[O,u,h];if(R.t=O,R.i18n=u,R.ready=h,h)return R;if(!h&&!d)return R;throw new Promise((function(e){L(u,m,(function(){e()}))}))}var q=["forwardedRef"];var Y=["ns","children"];function _(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.i18n,i=n.useContext(w)||{},o=i.i18n,c=a||o||k();c.options&&c.options.isClone||(e&&!c.initializedStoreOnce&&(c.services.resourceStore.data=e,c.options.ns=Object.values(e).reduce((function(e,n){return Object.keys(n).forEach((function(n){e.indexOf(n)<0&&e.push(n)})),e}),c.options.ns),c.initializedStoreOnce=!0,c.isInitialized=!0),t&&!c.initializedLanguageOnce&&(c.changeLanguage(t),c.initializedLanguageOnce=!0))}var J=["initialI18nStore","initialLanguage"];e.I18nContext=w,e.I18nextProvider=function(e){var t=e.i18n,r=e.defaultNS,a=e.children,i=n.useMemo((function(){return{i18n:t,defaultNS:r}}),[t,r]);return n.createElement(w.Provider,{value:i},a)},e.Trans=function(e){var t=e.children,i=e.count,o=e.parent,s=e.i18nKey,u=e.context,l=e.tOptions,f=void 0===l?{}:l,p=e.values,d=e.defaults,g=e.components,m=e.ns,h=e.i18n,v=e.t,y=e.shouldUnescape,b=c(e,F),O=n.useContext(w)||{},x=O.i18n,j=O.defaultNS,S=h||x||k();if(!S)return A("You will need to pass in an i18next instance by using i18nextReactModule"),t;var N=v||S.t.bind(S)||function(e){return e};u&&(f.context=u);var I=r(r({},E()),S.options&&S.options.react),P=m||N.ns||j||S.options&&S.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];var R=d||function e(t,r){if(!t)return"";var i="",o=V(t),s=r.transSupportBasicHtmlNodes&&r.transKeepBasicHtmlNodesFor?r.transKeepBasicHtmlNodesFor:[];return o.forEach((function(t,o){if("string"==typeof t)i+="".concat(t);else if(n.isValidElement(t)){var u=Object.keys(t.props).length,l=s.indexOf(t.type)>-1,f=t.props.children;if(!f&&l&&0===u)i+="<".concat(t.type,"/>");else if(f||l&&0===u)if(t.props.i18nIsDynamicList)i+="<".concat(o,"></").concat(o,">");else if(l&&1===u&&"string"==typeof f)i+="<".concat(t.type,">").concat(f,"</").concat(t.type,">");else{var p=e(f,r);i+="<".concat(o,">").concat(p,"</").concat(o,">")}else i+="<".concat(o,"></").concat(o,">")}else if(null===t)C("Trans: the passed in value is invalid - seems you passed in a null child.");else if("object"===a(t)){var d=t.format,g=c(t,D),m=Object.keys(g);if(1===m.length){var h=d?"".concat(m[0],", ").concat(d):m[0];i+="{{".concat(h,"}}")}else C("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",t)}else C("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}}.",t)})),i}(t,I)||I.transEmptyNodeValue||s,T=I.hashTransKey,L=s||(T?T(R):R),z=p?f.interpolation:{interpolation:r(r({},f.interpolation),{},{prefix:"#$?",suffix:"?$#"})},B=r(r(r(r({},f),{},{count:i},p),z),{},{defaultValue:R,ns:P}),U=W(g||t,L?N(L,B):R,S,I,B,y),H=void 0!==o?o:I.defaultTransParent;return H?n.createElement(H,b,U):U},e.Translation=function(e){var n=e.ns,t=e.children,r=s($(n,c(e,Y)),3),a=r[0],i=r[1],o=r[2];return t(a,{i18n:i,lng:i.language},o)},e.composeInitialProps=P,e.date=function(){return""},e.getDefaults=E,e.getI18n=k,e.getInitialProps=R,e.initReactI18next=I,e.number=function(){return""},e.plural=function(){return""},e.select=function(){return""},e.selectOrdinal=function(){return""},e.setDefaults=j,e.setI18n=N,e.time=function(){return""},e.useSSR=_,e.useTranslation=$,e.withSSR=function(){return function(e){function t(t){var a=t.initialI18nStore,i=t.initialLanguage,o=c(t,J);return _(a,i),n.createElement(e,r({},o))}return t.getInitialProps=P(e),t.displayName="withI18nextSSR(".concat(U(e),")"),t.WrappedComponent=e,t}},e.withTranslation=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(a){function i(i){var o=i.forwardedRef,u=c(i,q),l=s($(e,r(r({},u),{},{keyPrefix:t.keyPrefix})),3),f=l[0],p=l[1],d=l[2],g=r(r({},u),{},{t:f,i18n:p,tReady:d});return t.withRef&&o?g.ref=o:!t.withRef&&o&&(g.forwardedRef=o),n.createElement(a,g)}i.displayName="withI18nextTranslation(".concat(U(a),")"),i.WrappedComponent=a;return t.withRef?n.forwardRef((function(e,t){return n.createElement(i,Object.assign({},e,{forwardedRef:t}))})):i}},Object.defineProperty(e,"__esModule",{value:!0})}));
package/src/Trans.js CHANGED
@@ -12,7 +12,7 @@ function hasChildren(node, checkLength) {
12
12
 
13
13
  function getChildren(node) {
14
14
  if (!node) return [];
15
- return node && node.children ? node.children : node.props && node.props.children;
15
+ return node.props ? node.props.children : node.children;
16
16
  }
17
17
 
18
18
  function hasValidReactChildren(children) {
package/src/unescape.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // unescape common html entities
2
2
 
3
- const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
3
+ const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
4
4
 
5
5
  const htmlEntities = {
6
6
  '&amp;': '&',
@@ -21,6 +21,8 @@ const htmlEntities = {
21
21
  '&#174;': '®',
22
22
  '&hellip;': '…',
23
23
  '&#8230;': '…',
24
+ '&#x2F;': '/',
25
+ '&#47;': '/',
24
26
  };
25
27
 
26
28
  const unescapeHtmlEntity = (m) => htmlEntities[m];
@@ -101,7 +101,7 @@ export function useTranslation(ns, props = {}) {
101
101
  setT(getT);
102
102
  }
103
103
  isInitial.current = false;
104
- }, [i18n]); // re-run when i18n instance was replaced
104
+ }, [i18n, keyPrefix]); // re-run when i18n instance or keyPrefix were replaced
105
105
 
106
106
  const ret = [t, i18n, ready];
107
107
  ret.t = t;