Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: react-i18next @ 10.10.0 .. 10.11.0

CHANGELOG.md

@@ -1,3 +1,7 @@
+### 10.11.0
+
+- Restore support passing the defaultNS via I18nextProvider prop [860](https://github.com/i18next/react-i18next/pull/860)
+
### 10.10.0
- HOC: expose wrapped component as WrappedComponent property [853](https://github.com/i18next/react-i18next/pull/853)

dist/amd/react-i18next.js

@@ -678,7 +678,8 @@
additionalProps = _objectWithoutProperties(_ref, ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"]);
const _ref2 = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
- i18nFromContext = _ref2.i18n;
+ i18nFromContext = _ref2.i18n,
+ defaultNSFromContext = _ref2.defaultNS;
const i18n = i18nFromProps || i18nFromContext || getI18n();
@@ -691,7 +692,10 @@
const reactI18nextOptions = _objectSpread({}, getDefaults(), i18n.options && i18n.options.react);
- const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
+ const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; // prepare having a namespace
+
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
const defaultValue = defaults || nodesToString('', children, 0, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue;
const hashTransKey = reactI18nextOptions.hashTransKey;
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
@@ -705,7 +709,7 @@
const combinedTOpts = _objectSpread({}, tOptions, values, interpolationOverride, {
defaultValue,
count,
- ns
+ ns: namespaces
});
const translation = key ? t(key, combinedTOpts) : defaultValue;
@@ -719,7 +723,8 @@
const i18nFromProps = props.i18n;
const _ref = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
- i18nFromContext = _ref.i18n;
+ i18nFromContext = _ref.i18n,
+ defaultNSFromContext = _ref.defaultNS;
const i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
@@ -740,7 +745,7 @@
const _props$useSuspense = props.useSuspense,
useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace
- let namespaces = ns || i18n.options && i18n.options.defaultNS;
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
@@ -851,11 +856,13 @@
function I18nextProvider(_ref) {
let i18n = _ref.i18n,
+ defaultNS = _ref.defaultNS,
children = _ref.children;
usedI18nextProvider(true);
return React__default.createElement(I18nContext.Provider, {
value: {
- i18n
+ i18n,
+ defaultNS
}
}, children);
}

dist/amd/react-i18next.min.js

@@ -1 +1 @@
-define(["exports","react"],function(e,n){"use strict";var t="default"in n?n.default:n;function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},i=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.forEach(function(n){r(e,n,t[n])})}return e}function o(e,n){if(null==e)return{};var t,r,i=function(e,n){if(null==e)return{};var t,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}function a(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return t}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var s={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},c=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,n,t,r,i){var o=n.indexOf("<",r),a=n.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&o>-1&&t+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e,n){switch(n.type){case"text":return e+n.content;case"tag":return e+="<"+n.name+(n.attrs?function(e){var n=[];for(var t in e)n.push(t+'="'+e[t]+'"');return n.length?" "+n.join(" "):""}(n.attrs):"")+(n.voidElement?"/>":">"),n.voidElement?e:e+n.children.reduce(f,"")+"</"+n.name+">"}}var d={parse:function(e,n){n||(n={}),n.components||(n.components=u);var t,r=[],i=-1,o=[],a={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+t.name+">")return;f=!1}var d,g="/"!==l.charAt(1),h=0===l.indexOf("\x3c!--"),m=u+l.length,y=e.charAt(m);g&&!h&&(i++,"tag"===(t=function(e){var n,t=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(c,function(o){if("="===o)return r=!0,void t++;r?0===t?((s[o]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=o):(i.attrs[n]=o.replace(/^['"]|['"]$/g,""),n=void 0):(n&&(i.attrs[n]=n),n=o),t++,r=!1}),i}(l)).type&&n.components[t.name]&&(t.type="component",f=!0),t.voidElement||f||!y||"<"===y||p(t.children,e,i,m,n.ignoreWhitespace),a[t.tagName]=t,0===i&&r.push(t),(d=o[i-1])&&d.children.push(t),o[i]=t),(h||!g||t.voidElement)&&(h||i--,!f&&"<"!==y&&y&&p(d=-1===i?r:o[i].children,e,i,m,n.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,n.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,n){return e+f("",n)},"")}};let g,h,m={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0};const y=t.createContext();function b(){return h}function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m=i({},m,e)}function O(){return m}class j{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function w(e){g=e}function E(){return g}const S={type:"3rdParty",init(e){v(e.options.react),w(e)}};function $(e){return n=>new Promise(t=>{const r=x();e.getInitialProps?e.getInitialProps(n).then(e=>{t(i({},e,r))}):t(r)})}function x(){const e=E(),n=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],t={},r={};return e.languages.forEach(t=>{r[t]={},n.forEach(n=>{r[t][n]=e.getResourceBundle(t,n)||{}})}),t.initialI18nStore=r,t.initialLanguage=e.language,t}function N(){if(console&&console.warn){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&(n[0]=`react-i18next:: ${n[0]}`),console.warn(...n)}}const I={};function k(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];"string"==typeof n[0]&&I[n[0]]||("string"==typeof n[0]&&(I[n[0]]=new Date),N(...n))}function P(e,n,t){e.loadNamespaces(n,()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function C(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function T(e,n,r,o,a){if(""===n)return[];const s=o.transKeepBasicHtmlNodesFor||[],c=n&&new RegExp(s.join("|")).test(n);if(!e&&!c)return[n];const l={};!function e(n){"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),n.forEach(n=>{"string"!=typeof n&&(A(n)?e(C(n)):"object"!=typeof n||t.isValidElement(n)||Object.assign(l,n))})}(e),n=r.services.interpolator.interpolate(n,i({},l,a),r.language);const u=function e(n,r){return"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,a,s)=>{const l=a.children&&a.children[0]&&a.children[0].content;if("tag"===a.type){const u=n[parseInt(a.name,10)]||{},p=t.isValidElement(u);if("string"==typeof u)r.push(u);else if(A(u)){const n=C(u),o=e(n,a.children),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>t.isValidElement(e))}(n)&&0===o.length?n:o;u.dummy&&(u.children=c),r.push(t.cloneElement(u,i({},u.props,{key:s}),c))}else if(c&&"object"==typeof u&&u.dummy&&!p){const o=e(n,a.children);r.push(t.cloneElement(u,i({},u.props,{key:s}),o))}else if(isNaN(a.name)&&o.transSupportBasicHtmlNodes)if(a.voidElement)r.push(t.createElement(a.name,{key:`${a.name}-${s}`}));else{const i=e(n,a.children);r.push(t.createElement(a.name,{key:`${a.name}-${s}`},i))}else if("object"!=typeof u||p)1===a.children.length&&l?r.push(t.cloneElement(u,i({},u.props,{key:s}),l)):r.push(u);else{const e=a.children[0]?l:null;e&&r.push(e)}}else"text"===a.type&&r.push(a.content);return r},[])}([{dummy:!0,children:e}],d.parse(`<0>${n}</0>`));return C(u[0])}function z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=t.i18n,o=(b()?n.useContext(y):{}).i18n,s=r||o||E();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new j),!s){k("You will need pass in an i18next instance by using initReactI18next");const e=[e=>e,{},!0];return e.t=(e=>e),e.i18n={},e.ready=!0,e}const c=i({},O(),s.options.react),l=t.useSuspense,u=void 0===l?c.useSuspense:l;let p=e||s.options&&s.options.defaultNS;p="string"==typeof p?[p]:p||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(p);const f=(s.isInitialized||s.initializedStoreOnce)&&p.every(e=>(function(e,n){if(!n.languages||!n.languages.length)return k("i18n.languages were undefined or empty",n.languages),!0;const t=n.languages[0],r=!!n.options&&n.options.fallbackLng,i=n.languages[n.languages.length-1];if("cimode"===t.toLowerCase())return!0;const o=(e,t)=>{const r=n.services.backendConnector.state[`${e}|${t}`];return-1===r||2===r};return!!n.hasResourceBundle(t,e)||!n.services.backendConnector.backend||!(!o(t,e)||r&&!o(i,e))})(e,s));function d(){return{t:s.getFixedT(null,"fallback"===c.nsMode?p:p[0])}}const g=a(n.useState(d()),2),h=g[0],m=g[1];n.useEffect(()=>{let e=!0;const n=c.bindI18n,t=c.bindI18nStore;function r(){e&&m(d())}return f||u||P(s,p,()=>{e&&m(d())}),n&&s&&s.on(n,r),t&&s&&s.store.on(t,r),()=>{e=!1,n&&s&&n.split(" ").forEach(e=>s.off(e,r)),t&&s&&t.split(" ").forEach(e=>s.store.off(e,r))}},[]);const v=[h.t,s,f];if(v.t=h.t,v.i18n=s,v.ready=f,f)return v;if(!f&&!u)return v;throw new Promise(e=>{P(s,p,()=>{m(d()),e()})})}function L(e,t){const r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).i18n,i=(b()?n.useContext(y):{}).i18n,o=r||i||E();e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),t&&!o.initializedLanguageOnce&&(o.changeLanguage(t),o.initializedLanguageOnce=!0)}e.Trans=function(e){let r=e.children,a=e.count,s=e.parent,c=e.i18nKey,l=e.tOptions,u=e.values,p=e.defaults,f=e.components,d=e.ns,g=e.i18n,h=e.t,m=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]);const v=(b()?n.useContext(y):{}).i18n,j=g||v||E();if(!j)return k("You will need pass in an i18next instance by using i18nextReactModule"),r;const w=h||j.t.bind(j),S=i({},O(),j.options&&j.options.react),$=void 0!==s?s:S.defaultTransParent,x=p||function e(n,r,o,a){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);const s=a.transKeepBasicHtmlNodesFor||[];return r.forEach((r,o)=>{const c=`${o}`;if("string"==typeof r)n=`${n}${r}`;else if(A(r)){const t=s.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:c;n=r.props&&r.props.i18nIsDynamicList?`${n}<${t}></${t}>`:`${n}<${t}>${e("",C(r),o+1,a)}</${t}>`}else if(t.isValidElement(r))n=s.indexOf(r.type)>-1&&0===Object.keys(r.props).length?`${n}<${r.type}/>`:`${n}<${c}></${c}>`;else if("object"==typeof r){const e=i({},r),t=e.format;delete e.format;const o=Object.keys(e);t&&1===o.length?n=`${n}{{${o[0]}, ${t}}}`:1===o.length?n=`${n}{{${o[0]}}}`:N("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else N("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),n}("",r,0,S)||S.transEmptyNodeValue,I=S.hashTransKey,P=c||(I?I(x):x),R=i({},l,u,u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:x,count:a,ns:d}),z=P?w(P,R):x;return $?t.createElement($,m,T(f||r,z,j,S,R)):T(f||r,z,j,S,R)},e.useTranslation=z,e.withTranslation=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function o(o,s){const c=a(z(e,o),3),l=i({},o,{t:c[0],i18n:c[1],tReady:c[2]});return n.withRef&&s&&(l.ref=s),t.createElement(r,l)}return o.displayName=`withI18nextTranslation(${R(r)})`,o.WrappedComponent=r,n.withRef?t.forwardRef(o):o}},e.Translation=function(e){const n=e.ns,t=e.children,r=a(z(n,o(e,["ns","children"])),3),i=r[0],s=r[1],c=r[2];return t(i,{i18n:s,lng:s.language},c)},e.I18nextProvider=function(e){let n=e.i18n,r=e.children;return h=!0,t.createElement(y.Provider,{value:{i18n:n}},r)},e.withSSR=function(){return function(e){function n(n){let r=n.initialI18nStore,a=n.initialLanguage,s=o(n,["initialI18nStore","initialLanguage"]);return L(r,a),t.createElement(e,i({},s))}return n.getInitialProps=$(e),n.displayName=`withI18nextSSR(${R(e)})`,n.WrappedComponent=e,n}},e.useSSR=L,e.I18nContext=y,e.initReactI18next=S,e.setDefaults=v,e.getDefaults=O,e.setI18n=w,e.getI18n=E,e.composeInitialProps=$,e.getInitialProps=x,Object.defineProperty(e,"__esModule",{value:!0})});
+define(["exports","react"],function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var s={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},c=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,t,n,r,i){var o=t.indexOf("<",r),a=t.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(f,"")+"</"+t.name+">"}}var d={parse:function(e,t){t||(t={}),t.components||(t.components=u);var n,r=[],i=-1,o=[],a={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+n.name+">")return;f=!1}var d,g="/"!==l.charAt(1),h=0===l.indexOf("\x3c!--"),m=u+l.length,y=e.charAt(m);g&&!h&&(i++,"tag"===(n=function(e){var t,n=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(c,function(o){if("="===o)return r=!0,void n++;r?0===n?((s[o]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=o):(i.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(i.attrs[t]=t),t=o),n++,r=!1}),i}(l)).type&&t.components[n.name]&&(n.type="component",f=!0),n.voidElement||f||!y||"<"===y||p(n.children,e,i,m,t.ignoreWhitespace),a[n.tagName]=n,0===i&&r.push(n),(d=o[i-1])&&d.children.push(n),o[i]=n),(h||!g||n.voidElement)&&(h||i--,!f&&"<"!==y&&y&&p(d=-1===i?r:o[i].children,e,i,m,t.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,t.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,t){return e+f("",t)},"")}};let g,h,m={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0};const y=n.createContext();function b(){return h}function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m=i({},m,e)}function O(){return m}class S{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function j(e){g=e}function w(){return g}const N={type:"3rdParty",init(e){v(e.options.react),j(e)}};function E(e){return t=>new Promise(n=>{const r=$();e.getInitialProps?e.getInitialProps(t).then(e=>{n(i({},e,r))}):n(r)})}function $(){const e=w(),t=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],n={},r={};return e.languages.forEach(n=>{r[n]={},t.forEach(t=>{r[n][t]=e.getResourceBundle(n,t)||{}})}),n.initialI18nStore=r,n.initialLanguage=e.language,n}function x(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const I={};function k(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&I[t[0]]||("string"==typeof t[0]&&(I[t[0]]=new Date),x(...t))}function P(e,t,n){e.loadNamespaces(t,()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout(()=>{e.off("initialized",t)},0),n()};e.on("initialized",t)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function C(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function T(e,t,r,o,a){if(""===t)return[];const s=o.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(s.join("|")).test(t);if(!e&&!c)return[t];const l={};!function e(t){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(t=>{"string"!=typeof t&&(A(t)?e(C(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))})}(e),t=r.services.interpolator.interpolate(t,i({},l,a),r.language);const u=function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,a,s)=>{const l=a.children&&a.children[0]&&a.children[0].content;if("tag"===a.type){const u=t[parseInt(a.name,10)]||{},p=n.isValidElement(u);if("string"==typeof u)r.push(u);else if(A(u)){const t=C(u),o=e(t,a.children),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>n.isValidElement(e))}(t)&&0===o.length?t:o;u.dummy&&(u.children=c),r.push(n.cloneElement(u,i({},u.props,{key:s}),c))}else if(c&&"object"==typeof u&&u.dummy&&!p){const o=e(t,a.children);r.push(n.cloneElement(u,i({},u.props,{key:s}),o))}else if(isNaN(a.name)&&o.transSupportBasicHtmlNodes)if(a.voidElement)r.push(n.createElement(a.name,{key:`${a.name}-${s}`}));else{const i=e(t,a.children);r.push(n.createElement(a.name,{key:`${a.name}-${s}`},i))}else if("object"!=typeof u||p)1===a.children.length&&l?r.push(n.cloneElement(u,i({},u.props,{key:s}),l)):r.push(u);else{const e=a.children[0]?l:null;e&&r.push(e)}}else"text"===a.type&&r.push(a.content);return r},[])}([{dummy:!0,children:e}],d.parse(`<0>${t}</0>`));return C(u[0])}function z(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n.i18n,o=b()?t.useContext(y):{},s=o.i18n,c=o.defaultNS,l=r||s||w();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new S),!l){k("You will need pass in an i18next instance by using initReactI18next");const e=[e=>e,{},!0];return e.t=(e=>e),e.i18n={},e.ready=!0,e}const u=i({},O(),l.options.react),p=n.useSuspense,f=void 0===p?u.useSuspense:p;let d=e||c||l.options&&l.options.defaultNS;d="string"==typeof d?[d]:d||["translation"],l.reportNamespaces.addUsedNamespaces&&l.reportNamespaces.addUsedNamespaces(d);const g=(l.isInitialized||l.initializedStoreOnce)&&d.every(e=>(function(e,t){if(!t.languages||!t.languages.length)return k("i18n.languages were undefined or empty",t.languages),!0;const n=t.languages[0],r=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===n.toLowerCase())return!0;const o=(e,n)=>{const r=t.services.backendConnector.state[`${e}|${n}`];return-1===r||2===r};return!!t.hasResourceBundle(n,e)||!t.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e))})(e,l));function h(){return{t:l.getFixedT(null,"fallback"===u.nsMode?d:d[0])}}const m=a(t.useState(h()),2),v=m[0],j=m[1];t.useEffect(()=>{let e=!0;const t=u.bindI18n,n=u.bindI18nStore;function r(){e&&j(h())}return g||f||P(l,d,()=>{e&&j(h())}),t&&l&&l.on(t,r),n&&l&&l.store.on(n,r),()=>{e=!1,t&&l&&t.split(" ").forEach(e=>l.off(e,r)),n&&l&&n.split(" ").forEach(e=>l.store.off(e,r))}},[]);const N=[v.t,l,g];if(N.t=v.t,N.i18n=l,N.ready=g,g)return N;if(!g&&!f)return N;throw new Promise(e=>{P(l,d,()=>{j(h()),e()})})}function L(e,n){const r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).i18n,i=(b()?t.useContext(y):{}).i18n,o=r||i||w();e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),n&&!o.initializedLanguageOnce&&(o.changeLanguage(n),o.initializedLanguageOnce=!0)}e.Trans=function(e){let r=e.children,a=e.count,s=e.parent,c=e.i18nKey,l=e.tOptions,u=e.values,p=e.defaults,f=e.components,d=e.ns,g=e.i18n,h=e.t,m=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]);const v=b()?t.useContext(y):{},S=v.i18n,j=v.defaultNS,N=g||S||w();if(!N)return k("You will need pass in an i18next instance by using i18nextReactModule"),r;const E=h||N.t.bind(N),$=i({},O(),N.options&&N.options.react),I=void 0!==s?s:$.defaultTransParent;let P=d||j||N.options&&N.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];const R=p||function e(t,r,o,a){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);const s=a.transKeepBasicHtmlNodesFor||[];return r.forEach((r,o)=>{const c=`${o}`;if("string"==typeof r)t=`${t}${r}`;else if(A(r)){const n=s.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:c;t=r.props&&r.props.i18nIsDynamicList?`${t}<${n}></${n}>`:`${t}<${n}>${e("",C(r),o+1,a)}</${n}>`}else if(n.isValidElement(r))t=s.indexOf(r.type)>-1&&0===Object.keys(r.props).length?`${t}<${r.type}/>`:`${t}<${c}></${c}>`;else if("object"==typeof r){const e=i({},r),n=e.format;delete e.format;const o=Object.keys(e);n&&1===o.length?t=`${t}{{${o[0]}, ${n}}}`:1===o.length?t=`${t}{{${o[0]}}}`:x("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else x("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),t}("",r,0,$)||$.transEmptyNodeValue,z=$.hashTransKey,L=c||(z?z(R):R),B=i({},l,u,u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:R,count:a,ns:P}),V=L?E(L,B):R;return I?n.createElement(I,m,T(f||r,V,N,$,B)):T(f||r,V,N,$,B)},e.useTranslation=z,e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function o(o,s){const c=a(z(e,o),3),l=i({},o,{t:c[0],i18n:c[1],tReady:c[2]});return t.withRef&&s&&(l.ref=s),n.createElement(r,l)}return o.displayName=`withI18nextTranslation(${R(r)})`,o.WrappedComponent=r,t.withRef?n.forwardRef(o):o}},e.Translation=function(e){const t=e.ns,n=e.children,r=a(z(t,o(e,["ns","children"])),3),i=r[0],s=r[1],c=r[2];return n(i,{i18n:s,lng:s.language},c)},e.I18nextProvider=function(e){let t=e.i18n,r=e.defaultNS,i=e.children;return h=!0,n.createElement(y.Provider,{value:{i18n:t,defaultNS:r}},i)},e.withSSR=function(){return function(e){function t(t){let r=t.initialI18nStore,a=t.initialLanguage,s=o(t,["initialI18nStore","initialLanguage"]);return L(r,a),n.createElement(e,i({},s))}return t.getInitialProps=E(e),t.displayName=`withI18nextSSR(${R(e)})`,t.WrappedComponent=e,t}},e.useSSR=L,e.I18nContext=y,e.initReactI18next=N,e.setDefaults=v,e.getDefaults=O,e.setI18n=j,e.getI18n=w,e.composeInitialProps=E,e.getInitialProps=$,Object.defineProperty(e,"__esModule",{value:!0})});

dist/commonjs/I18nextProvider.js

@@ -13,11 +13,13 @@
function I18nextProvider(_ref) {
var i18n = _ref.i18n,
+ defaultNS = _ref.defaultNS,
children = _ref.children;
(0, _context.usedI18nextProvider)(true);
return _react.default.createElement(_context.I18nContext.Provider, {
value: {
- i18n: i18n
+ i18n: i18n,
+ defaultNS: defaultNS
}
}, children);
}
\ No newline at end of file

dist/commonjs/Trans.js

@@ -209,7 +209,8 @@
additionalProps = (0, _objectWithoutProperties2.default)(_ref, ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"]);
var _ref2 = (0, _context.getHasUsedI18nextProvider)() ? (0, _react.useContext)(_context.I18nContext) : {},
- i18nFromContext = _ref2.i18n;
+ i18nFromContext = _ref2.i18n,
+ defaultNSFromContext = _ref2.defaultNS;
var i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
@@ -220,7 +221,10 @@
var t = tFromProps || i18n.t.bind(i18n);
var reactI18nextOptions = (0, _objectSpread2.default)({}, (0, _context.getDefaults)(), i18n.options && i18n.options.react);
- var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
+ var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; // prepare having a namespace
+
+ var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
var defaultValue = defaults || nodesToString('', children, 0, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue;
var hashTransKey = reactI18nextOptions.hashTransKey;
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
@@ -233,7 +237,7 @@
var combinedTOpts = (0, _objectSpread2.default)({}, tOptions, values, interpolationOverride, {
defaultValue: defaultValue,
count: count,
- ns: ns
+ ns: namespaces
});
var translation = key ? t(key, combinedTOpts) : defaultValue;
if (!useAsParent) return renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts);

dist/commonjs/useTranslation.js

@@ -23,7 +23,8 @@
var i18nFromProps = props.i18n;
var _ref = (0, _context.getHasUsedI18nextProvider)() ? (0, _react.useContext)(_context.I18nContext) : {},
- i18nFromContext = _ref.i18n;
+ i18nFromContext = _ref.i18n,
+ defaultNSFromContext = _ref.defaultNS;
var i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new _context.ReportNamespaces();
@@ -47,7 +48,7 @@
var _props$useSuspense = props.useSuspense,
useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace
- var namespaces = ns || i18n.options && i18n.options.defaultNS;
+ var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)

dist/es/I18nextProvider.js

@@ -2,11 +2,13 @@
import { I18nContext, usedI18nextProvider } from './context';
export function I18nextProvider(_ref) {
var i18n = _ref.i18n,
+ defaultNS = _ref.defaultNS,
children = _ref.children;
usedI18nextProvider(true);
return React.createElement(I18nContext.Provider, {
value: {
- i18n: i18n
+ i18n: i18n,
+ defaultNS: defaultNS
}
}, children);
}
\ No newline at end of file

dist/es/Trans.js

@@ -191,7 +191,8 @@
additionalProps = _objectWithoutProperties(_ref, ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"]);
var _ref2 = getHasUsedI18nextProvider() ? useContext(I18nContext) : {},
- i18nFromContext = _ref2.i18n;
+ i18nFromContext = _ref2.i18n,
+ defaultNSFromContext = _ref2.defaultNS;
var i18n = i18nFromProps || i18nFromContext || getI18n();
@@ -204,7 +205,10 @@
var reactI18nextOptions = _objectSpread({}, getDefaults(), i18n.options && i18n.options.react);
- var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
+ var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; // prepare having a namespace
+
+ var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
var defaultValue = defaults || nodesToString('', children, 0, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue;
var hashTransKey = reactI18nextOptions.hashTransKey;
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
@@ -218,7 +222,7 @@
var combinedTOpts = _objectSpread({}, tOptions, values, interpolationOverride, {
defaultValue: defaultValue,
count: count,
- ns: ns
+ ns: namespaces
});
var translation = key ? t(key, combinedTOpts) : defaultValue;

dist/es/useTranslation.js

@@ -9,7 +9,8 @@
var i18nFromProps = props.i18n;
var _ref = getHasUsedI18nextProvider() ? useContext(I18nContext) : {},
- i18nFromContext = _ref.i18n;
+ i18nFromContext = _ref.i18n,
+ defaultNSFromContext = _ref.defaultNS;
var i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
@@ -34,7 +35,7 @@
var _props$useSuspense = props.useSuspense,
useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace
- var namespaces = ns || i18n.options && i18n.options.defaultNS;
+ var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)

dist/umd/react-i18next.js

@@ -682,7 +682,8 @@
additionalProps = _objectWithoutProperties(_ref, ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"]);
const _ref2 = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
- i18nFromContext = _ref2.i18n;
+ i18nFromContext = _ref2.i18n,
+ defaultNSFromContext = _ref2.defaultNS;
const i18n = i18nFromProps || i18nFromContext || getI18n();
@@ -695,7 +696,10 @@
const reactI18nextOptions = _objectSpread({}, getDefaults(), i18n.options && i18n.options.react);
- const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
+ const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; // prepare having a namespace
+
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
const defaultValue = defaults || nodesToString('', children, 0, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue;
const hashTransKey = reactI18nextOptions.hashTransKey;
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
@@ -709,7 +713,7 @@
const combinedTOpts = _objectSpread({}, tOptions, values, interpolationOverride, {
defaultValue,
count,
- ns
+ ns: namespaces
});
const translation = key ? t(key, combinedTOpts) : defaultValue;
@@ -723,7 +727,8 @@
const i18nFromProps = props.i18n;
const _ref = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
- i18nFromContext = _ref.i18n;
+ i18nFromContext = _ref.i18n,
+ defaultNSFromContext = _ref.defaultNS;
const i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
@@ -744,7 +749,7 @@
const _props$useSuspense = props.useSuspense,
useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace
- let namespaces = ns || i18n.options && i18n.options.defaultNS;
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
@@ -855,11 +860,13 @@
function I18nextProvider(_ref) {
let i18n = _ref.i18n,
+ defaultNS = _ref.defaultNS,
children = _ref.children;
usedI18nextProvider(true);
return React__default.createElement(I18nContext.Provider, {
value: {
- i18n
+ i18n,
+ defaultNS
}
}, children);
}

dist/umd/react-i18next.min.js

@@ -1 +1 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactI18next={},e.React)}(this,function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var s={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},c=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,t,n,r,i){var o=t.indexOf("<",r),a=t.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(f,"")+"</"+t.name+">"}}var d={parse:function(e,t){t||(t={}),t.components||(t.components=u);var n,r=[],i=-1,o=[],a={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+n.name+">")return;f=!1}var d,g="/"!==l.charAt(1),h=0===l.indexOf("\x3c!--"),m=u+l.length,y=e.charAt(m);g&&!h&&(i++,"tag"===(n=function(e){var t,n=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(c,function(o){if("="===o)return r=!0,void n++;r?0===n?((s[o]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=o):(i.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(i.attrs[t]=t),t=o),n++,r=!1}),i}(l)).type&&t.components[n.name]&&(n.type="component",f=!0),n.voidElement||f||!y||"<"===y||p(n.children,e,i,m,t.ignoreWhitespace),a[n.tagName]=n,0===i&&r.push(n),(d=o[i-1])&&d.children.push(n),o[i]=n),(h||!g||n.voidElement)&&(h||i--,!f&&"<"!==y&&y&&p(d=-1===i?r:o[i].children,e,i,m,t.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,t.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,t){return e+f("",t)},"")}};let g,h,m={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0};const y=n.createContext();function b(){return h}function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m=i({},m,e)}function O(){return m}class j{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function w(e){g=e}function x(){return g}const E={type:"3rdParty",init(e){v(e.options.react),w(e)}};function S(e){return t=>new Promise(n=>{const r=$();e.getInitialProps?e.getInitialProps(t).then(e=>{n(i({},e,r))}):n(r)})}function $(){const e=x(),t=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],n={},r={};return e.languages.forEach(n=>{r[n]={},t.forEach(t=>{r[n][t]=e.getResourceBundle(n,t)||{}})}),n.initialI18nStore=r,n.initialLanguage=e.language,n}function N(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const I={};function k(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&I[t[0]]||("string"==typeof t[0]&&(I[t[0]]=new Date),N(...t))}function P(e,t,n){e.loadNamespaces(t,()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout(()=>{e.off("initialized",t)},0),n()};e.on("initialized",t)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function C(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function T(e,t,r,o,a){if(""===t)return[];const s=o.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(s.join("|")).test(t);if(!e&&!c)return[t];const l={};!function e(t){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(t=>{"string"!=typeof t&&(A(t)?e(C(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))})}(e),t=r.services.interpolator.interpolate(t,i({},l,a),r.language);const u=function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,a,s)=>{const l=a.children&&a.children[0]&&a.children[0].content;if("tag"===a.type){const u=t[parseInt(a.name,10)]||{},p=n.isValidElement(u);if("string"==typeof u)r.push(u);else if(A(u)){const t=C(u),o=e(t,a.children),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>n.isValidElement(e))}(t)&&0===o.length?t:o;u.dummy&&(u.children=c),r.push(n.cloneElement(u,i({},u.props,{key:s}),c))}else if(c&&"object"==typeof u&&u.dummy&&!p){const o=e(t,a.children);r.push(n.cloneElement(u,i({},u.props,{key:s}),o))}else if(isNaN(a.name)&&o.transSupportBasicHtmlNodes)if(a.voidElement)r.push(n.createElement(a.name,{key:`${a.name}-${s}`}));else{const i=e(t,a.children);r.push(n.createElement(a.name,{key:`${a.name}-${s}`},i))}else if("object"!=typeof u||p)1===a.children.length&&l?r.push(n.cloneElement(u,i({},u.props,{key:s}),l)):r.push(u);else{const e=a.children[0]?l:null;e&&r.push(e)}}else"text"===a.type&&r.push(a.content);return r},[])}([{dummy:!0,children:e}],d.parse(`<0>${t}</0>`));return C(u[0])}function z(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n.i18n,o=(b()?t.useContext(y):{}).i18n,s=r||o||x();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new j),!s){k("You will need pass in an i18next instance by using initReactI18next");const e=[e=>e,{},!0];return e.t=(e=>e),e.i18n={},e.ready=!0,e}const c=i({},O(),s.options.react),l=n.useSuspense,u=void 0===l?c.useSuspense:l;let p=e||s.options&&s.options.defaultNS;p="string"==typeof p?[p]:p||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(p);const f=(s.isInitialized||s.initializedStoreOnce)&&p.every(e=>(function(e,t){if(!t.languages||!t.languages.length)return k("i18n.languages were undefined or empty",t.languages),!0;const n=t.languages[0],r=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===n.toLowerCase())return!0;const o=(e,n)=>{const r=t.services.backendConnector.state[`${e}|${n}`];return-1===r||2===r};return!!t.hasResourceBundle(n,e)||!t.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e))})(e,s));function d(){return{t:s.getFixedT(null,"fallback"===c.nsMode?p:p[0])}}const g=a(t.useState(d()),2),h=g[0],m=g[1];t.useEffect(()=>{let e=!0;const t=c.bindI18n,n=c.bindI18nStore;function r(){e&&m(d())}return f||u||P(s,p,()=>{e&&m(d())}),t&&s&&s.on(t,r),n&&s&&s.store.on(n,r),()=>{e=!1,t&&s&&t.split(" ").forEach(e=>s.off(e,r)),n&&s&&n.split(" ").forEach(e=>s.store.off(e,r))}},[]);const v=[h.t,s,f];if(v.t=h.t,v.i18n=s,v.ready=f,f)return v;if(!f&&!u)return v;throw new Promise(e=>{P(s,p,()=>{m(d()),e()})})}function L(e,n){const r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).i18n,i=(b()?t.useContext(y):{}).i18n,o=r||i||x();e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),n&&!o.initializedLanguageOnce&&(o.changeLanguage(n),o.initializedLanguageOnce=!0)}e.Trans=function(e){let r=e.children,a=e.count,s=e.parent,c=e.i18nKey,l=e.tOptions,u=e.values,p=e.defaults,f=e.components,d=e.ns,g=e.i18n,h=e.t,m=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]);const v=(b()?t.useContext(y):{}).i18n,j=g||v||x();if(!j)return k("You will need pass in an i18next instance by using i18nextReactModule"),r;const w=h||j.t.bind(j),E=i({},O(),j.options&&j.options.react),S=void 0!==s?s:E.defaultTransParent,$=p||function e(t,r,o,a){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);const s=a.transKeepBasicHtmlNodesFor||[];return r.forEach((r,o)=>{const c=`${o}`;if("string"==typeof r)t=`${t}${r}`;else if(A(r)){const n=s.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:c;t=r.props&&r.props.i18nIsDynamicList?`${t}<${n}></${n}>`:`${t}<${n}>${e("",C(r),o+1,a)}</${n}>`}else if(n.isValidElement(r))t=s.indexOf(r.type)>-1&&0===Object.keys(r.props).length?`${t}<${r.type}/>`:`${t}<${c}></${c}>`;else if("object"==typeof r){const e=i({},r),n=e.format;delete e.format;const o=Object.keys(e);n&&1===o.length?t=`${t}{{${o[0]}, ${n}}}`:1===o.length?t=`${t}{{${o[0]}}}`:N("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else N("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),t}("",r,0,E)||E.transEmptyNodeValue,I=E.hashTransKey,P=c||(I?I($):$),R=i({},l,u,u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:$,count:a,ns:d}),z=P?w(P,R):$;return S?n.createElement(S,m,T(f||r,z,j,E,R)):T(f||r,z,j,E,R)},e.useTranslation=z,e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function o(o,s){const c=a(z(e,o),3),l=i({},o,{t:c[0],i18n:c[1],tReady:c[2]});return t.withRef&&s&&(l.ref=s),n.createElement(r,l)}return o.displayName=`withI18nextTranslation(${R(r)})`,o.WrappedComponent=r,t.withRef?n.forwardRef(o):o}},e.Translation=function(e){const t=e.ns,n=e.children,r=a(z(t,o(e,["ns","children"])),3),i=r[0],s=r[1],c=r[2];return n(i,{i18n:s,lng:s.language},c)},e.I18nextProvider=function(e){let t=e.i18n,r=e.children;return h=!0,n.createElement(y.Provider,{value:{i18n:t}},r)},e.withSSR=function(){return function(e){function t(t){let r=t.initialI18nStore,a=t.initialLanguage,s=o(t,["initialI18nStore","initialLanguage"]);return L(r,a),n.createElement(e,i({},s))}return t.getInitialProps=S(e),t.displayName=`withI18nextSSR(${R(e)})`,t.WrappedComponent=e,t}},e.useSSR=L,e.I18nContext=y,e.initReactI18next=E,e.setDefaults=v,e.getDefaults=O,e.setI18n=w,e.getI18n=x,e.composeInitialProps=S,e.getInitialProps=$,Object.defineProperty(e,"__esModule",{value:!0})});
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactI18next={},e.React)}(this,function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var s={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},c=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,t,n,r,i){var o=t.indexOf("<",r),a=t.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(f,"")+"</"+t.name+">"}}var d={parse:function(e,t){t||(t={}),t.components||(t.components=u);var n,r=[],i=-1,o=[],a={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+n.name+">")return;f=!1}var d,g="/"!==l.charAt(1),h=0===l.indexOf("\x3c!--"),m=u+l.length,y=e.charAt(m);g&&!h&&(i++,"tag"===(n=function(e){var t,n=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(c,function(o){if("="===o)return r=!0,void n++;r?0===n?((s[o]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=o):(i.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(i.attrs[t]=t),t=o),n++,r=!1}),i}(l)).type&&t.components[n.name]&&(n.type="component",f=!0),n.voidElement||f||!y||"<"===y||p(n.children,e,i,m,t.ignoreWhitespace),a[n.tagName]=n,0===i&&r.push(n),(d=o[i-1])&&d.children.push(n),o[i]=n),(h||!g||n.voidElement)&&(h||i--,!f&&"<"!==y&&y&&p(d=-1===i?r:o[i].children,e,i,m,t.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,t.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,t){return e+f("",t)},"")}};let g,h,m={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0};const y=n.createContext();function b(){return h}function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m=i({},m,e)}function O(){return m}class S{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function j(e){g=e}function w(){return g}const N={type:"3rdParty",init(e){v(e.options.react),j(e)}};function x(e){return t=>new Promise(n=>{const r=E();e.getInitialProps?e.getInitialProps(t).then(e=>{n(i({},e,r))}):n(r)})}function E(){const e=w(),t=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],n={},r={};return e.languages.forEach(n=>{r[n]={},t.forEach(t=>{r[n][t]=e.getResourceBundle(n,t)||{}})}),n.initialI18nStore=r,n.initialLanguage=e.language,n}function $(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const I={};function k(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&I[t[0]]||("string"==typeof t[0]&&(I[t[0]]=new Date),$(...t))}function P(e,t,n){e.loadNamespaces(t,()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout(()=>{e.off("initialized",t)},0),n()};e.on("initialized",t)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function C(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function T(e,t,r,o,a){if(""===t)return[];const s=o.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(s.join("|")).test(t);if(!e&&!c)return[t];const l={};!function e(t){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(t=>{"string"!=typeof t&&(A(t)?e(C(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))})}(e),t=r.services.interpolator.interpolate(t,i({},l,a),r.language);const u=function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,a,s)=>{const l=a.children&&a.children[0]&&a.children[0].content;if("tag"===a.type){const u=t[parseInt(a.name,10)]||{},p=n.isValidElement(u);if("string"==typeof u)r.push(u);else if(A(u)){const t=C(u),o=e(t,a.children),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>n.isValidElement(e))}(t)&&0===o.length?t:o;u.dummy&&(u.children=c),r.push(n.cloneElement(u,i({},u.props,{key:s}),c))}else if(c&&"object"==typeof u&&u.dummy&&!p){const o=e(t,a.children);r.push(n.cloneElement(u,i({},u.props,{key:s}),o))}else if(isNaN(a.name)&&o.transSupportBasicHtmlNodes)if(a.voidElement)r.push(n.createElement(a.name,{key:`${a.name}-${s}`}));else{const i=e(t,a.children);r.push(n.createElement(a.name,{key:`${a.name}-${s}`},i))}else if("object"!=typeof u||p)1===a.children.length&&l?r.push(n.cloneElement(u,i({},u.props,{key:s}),l)):r.push(u);else{const e=a.children[0]?l:null;e&&r.push(e)}}else"text"===a.type&&r.push(a.content);return r},[])}([{dummy:!0,children:e}],d.parse(`<0>${t}</0>`));return C(u[0])}function z(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n.i18n,o=b()?t.useContext(y):{},s=o.i18n,c=o.defaultNS,l=r||s||w();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new S),!l){k("You will need pass in an i18next instance by using initReactI18next");const e=[e=>e,{},!0];return e.t=(e=>e),e.i18n={},e.ready=!0,e}const u=i({},O(),l.options.react),p=n.useSuspense,f=void 0===p?u.useSuspense:p;let d=e||c||l.options&&l.options.defaultNS;d="string"==typeof d?[d]:d||["translation"],l.reportNamespaces.addUsedNamespaces&&l.reportNamespaces.addUsedNamespaces(d);const g=(l.isInitialized||l.initializedStoreOnce)&&d.every(e=>(function(e,t){if(!t.languages||!t.languages.length)return k("i18n.languages were undefined or empty",t.languages),!0;const n=t.languages[0],r=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===n.toLowerCase())return!0;const o=(e,n)=>{const r=t.services.backendConnector.state[`${e}|${n}`];return-1===r||2===r};return!!t.hasResourceBundle(n,e)||!t.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e))})(e,l));function h(){return{t:l.getFixedT(null,"fallback"===u.nsMode?d:d[0])}}const m=a(t.useState(h()),2),v=m[0],j=m[1];t.useEffect(()=>{let e=!0;const t=u.bindI18n,n=u.bindI18nStore;function r(){e&&j(h())}return g||f||P(l,d,()=>{e&&j(h())}),t&&l&&l.on(t,r),n&&l&&l.store.on(n,r),()=>{e=!1,t&&l&&t.split(" ").forEach(e=>l.off(e,r)),n&&l&&n.split(" ").forEach(e=>l.store.off(e,r))}},[]);const N=[v.t,l,g];if(N.t=v.t,N.i18n=l,N.ready=g,g)return N;if(!g&&!f)return N;throw new Promise(e=>{P(l,d,()=>{j(h()),e()})})}function L(e,n){const r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).i18n,i=(b()?t.useContext(y):{}).i18n,o=r||i||w();e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),n&&!o.initializedLanguageOnce&&(o.changeLanguage(n),o.initializedLanguageOnce=!0)}e.Trans=function(e){let r=e.children,a=e.count,s=e.parent,c=e.i18nKey,l=e.tOptions,u=e.values,p=e.defaults,f=e.components,d=e.ns,g=e.i18n,h=e.t,m=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]);const v=b()?t.useContext(y):{},S=v.i18n,j=v.defaultNS,N=g||S||w();if(!N)return k("You will need pass in an i18next instance by using i18nextReactModule"),r;const x=h||N.t.bind(N),E=i({},O(),N.options&&N.options.react),I=void 0!==s?s:E.defaultTransParent;let P=d||j||N.options&&N.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];const R=p||function e(t,r,o,a){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);const s=a.transKeepBasicHtmlNodesFor||[];return r.forEach((r,o)=>{const c=`${o}`;if("string"==typeof r)t=`${t}${r}`;else if(A(r)){const n=s.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:c;t=r.props&&r.props.i18nIsDynamicList?`${t}<${n}></${n}>`:`${t}<${n}>${e("",C(r),o+1,a)}</${n}>`}else if(n.isValidElement(r))t=s.indexOf(r.type)>-1&&0===Object.keys(r.props).length?`${t}<${r.type}/>`:`${t}<${c}></${c}>`;else if("object"==typeof r){const e=i({},r),n=e.format;delete e.format;const o=Object.keys(e);n&&1===o.length?t=`${t}{{${o[0]}, ${n}}}`:1===o.length?t=`${t}{{${o[0]}}}`:$("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else $("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),t}("",r,0,E)||E.transEmptyNodeValue,z=E.hashTransKey,L=c||(z?z(R):R),B=i({},l,u,u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:R,count:a,ns:P}),V=L?x(L,B):R;return I?n.createElement(I,m,T(f||r,V,N,E,B)):T(f||r,V,N,E,B)},e.useTranslation=z,e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function o(o,s){const c=a(z(e,o),3),l=i({},o,{t:c[0],i18n:c[1],tReady:c[2]});return t.withRef&&s&&(l.ref=s),n.createElement(r,l)}return o.displayName=`withI18nextTranslation(${R(r)})`,o.WrappedComponent=r,t.withRef?n.forwardRef(o):o}},e.Translation=function(e){const t=e.ns,n=e.children,r=a(z(t,o(e,["ns","children"])),3),i=r[0],s=r[1],c=r[2];return n(i,{i18n:s,lng:s.language},c)},e.I18nextProvider=function(e){let t=e.i18n,r=e.defaultNS,i=e.children;return h=!0,n.createElement(y.Provider,{value:{i18n:t,defaultNS:r}},i)},e.withSSR=function(){return function(e){function t(t){let r=t.initialI18nStore,a=t.initialLanguage,s=o(t,["initialI18nStore","initialLanguage"]);return L(r,a),n.createElement(e,i({},s))}return t.getInitialProps=x(e),t.displayName=`withI18nextSSR(${R(e)})`,t.WrappedComponent=e,t}},e.useSSR=L,e.I18nContext=y,e.initReactI18next=N,e.setDefaults=v,e.getDefaults=O,e.setI18n=j,e.getI18n=w,e.composeInitialProps=x,e.getInitialProps=E,Object.defineProperty(e,"__esModule",{value:!0})});

package.json

@@ -1,6 +1,6 @@
{
"name": "react-i18next",
- "version": "10.10.0",
+ "version": "10.11.0",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "src/index.d.ts",

react-i18next.js

@@ -682,7 +682,8 @@
additionalProps = _objectWithoutProperties(_ref, ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"]);
const _ref2 = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
- i18nFromContext = _ref2.i18n;
+ i18nFromContext = _ref2.i18n,
+ defaultNSFromContext = _ref2.defaultNS;
const i18n = i18nFromProps || i18nFromContext || getI18n();
@@ -695,7 +696,10 @@
const reactI18nextOptions = _objectSpread({}, getDefaults(), i18n.options && i18n.options.react);
- const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
+ const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; // prepare having a namespace
+
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
const defaultValue = defaults || nodesToString('', children, 0, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue;
const hashTransKey = reactI18nextOptions.hashTransKey;
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
@@ -709,7 +713,7 @@
const combinedTOpts = _objectSpread({}, tOptions, values, interpolationOverride, {
defaultValue,
count,
- ns
+ ns: namespaces
});
const translation = key ? t(key, combinedTOpts) : defaultValue;
@@ -723,7 +727,8 @@
const i18nFromProps = props.i18n;
const _ref = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
- i18nFromContext = _ref.i18n;
+ i18nFromContext = _ref.i18n,
+ defaultNSFromContext = _ref.defaultNS;
const i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
@@ -744,7 +749,7 @@
const _props$useSuspense = props.useSuspense,
useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace
- let namespaces = ns || i18n.options && i18n.options.defaultNS;
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
@@ -855,11 +860,13 @@
function I18nextProvider(_ref) {
let i18n = _ref.i18n,
+ defaultNS = _ref.defaultNS,
children = _ref.children;
usedI18nextProvider(true);
return React__default.createElement(I18nContext.Provider, {
value: {
- i18n
+ i18n,
+ defaultNS
}
}, children);
}

react-i18next.min.js

@@ -1 +1 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactI18next={},e.React)}(this,function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var s={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},c=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,t,n,r,i){var o=t.indexOf("<",r),a=t.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(f,"")+"</"+t.name+">"}}var d={parse:function(e,t){t||(t={}),t.components||(t.components=u);var n,r=[],i=-1,o=[],a={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+n.name+">")return;f=!1}var d,g="/"!==l.charAt(1),h=0===l.indexOf("\x3c!--"),m=u+l.length,y=e.charAt(m);g&&!h&&(i++,"tag"===(n=function(e){var t,n=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(c,function(o){if("="===o)return r=!0,void n++;r?0===n?((s[o]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=o):(i.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(i.attrs[t]=t),t=o),n++,r=!1}),i}(l)).type&&t.components[n.name]&&(n.type="component",f=!0),n.voidElement||f||!y||"<"===y||p(n.children,e,i,m,t.ignoreWhitespace),a[n.tagName]=n,0===i&&r.push(n),(d=o[i-1])&&d.children.push(n),o[i]=n),(h||!g||n.voidElement)&&(h||i--,!f&&"<"!==y&&y&&p(d=-1===i?r:o[i].children,e,i,m,t.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,t.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,t){return e+f("",t)},"")}};let g,h,m={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0};const y=n.createContext();function b(){return h}function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m=i({},m,e)}function O(){return m}class j{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function w(e){g=e}function x(){return g}const E={type:"3rdParty",init(e){v(e.options.react),w(e)}};function S(e){return t=>new Promise(n=>{const r=$();e.getInitialProps?e.getInitialProps(t).then(e=>{n(i({},e,r))}):n(r)})}function $(){const e=x(),t=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],n={},r={};return e.languages.forEach(n=>{r[n]={},t.forEach(t=>{r[n][t]=e.getResourceBundle(n,t)||{}})}),n.initialI18nStore=r,n.initialLanguage=e.language,n}function N(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const I={};function k(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&I[t[0]]||("string"==typeof t[0]&&(I[t[0]]=new Date),N(...t))}function P(e,t,n){e.loadNamespaces(t,()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout(()=>{e.off("initialized",t)},0),n()};e.on("initialized",t)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function C(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function T(e,t,r,o,a){if(""===t)return[];const s=o.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(s.join("|")).test(t);if(!e&&!c)return[t];const l={};!function e(t){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(t=>{"string"!=typeof t&&(A(t)?e(C(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))})}(e),t=r.services.interpolator.interpolate(t,i({},l,a),r.language);const u=function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,a,s)=>{const l=a.children&&a.children[0]&&a.children[0].content;if("tag"===a.type){const u=t[parseInt(a.name,10)]||{},p=n.isValidElement(u);if("string"==typeof u)r.push(u);else if(A(u)){const t=C(u),o=e(t,a.children),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>n.isValidElement(e))}(t)&&0===o.length?t:o;u.dummy&&(u.children=c),r.push(n.cloneElement(u,i({},u.props,{key:s}),c))}else if(c&&"object"==typeof u&&u.dummy&&!p){const o=e(t,a.children);r.push(n.cloneElement(u,i({},u.props,{key:s}),o))}else if(isNaN(a.name)&&o.transSupportBasicHtmlNodes)if(a.voidElement)r.push(n.createElement(a.name,{key:`${a.name}-${s}`}));else{const i=e(t,a.children);r.push(n.createElement(a.name,{key:`${a.name}-${s}`},i))}else if("object"!=typeof u||p)1===a.children.length&&l?r.push(n.cloneElement(u,i({},u.props,{key:s}),l)):r.push(u);else{const e=a.children[0]?l:null;e&&r.push(e)}}else"text"===a.type&&r.push(a.content);return r},[])}([{dummy:!0,children:e}],d.parse(`<0>${t}</0>`));return C(u[0])}function z(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n.i18n,o=(b()?t.useContext(y):{}).i18n,s=r||o||x();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new j),!s){k("You will need pass in an i18next instance by using initReactI18next");const e=[e=>e,{},!0];return e.t=(e=>e),e.i18n={},e.ready=!0,e}const c=i({},O(),s.options.react),l=n.useSuspense,u=void 0===l?c.useSuspense:l;let p=e||s.options&&s.options.defaultNS;p="string"==typeof p?[p]:p||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(p);const f=(s.isInitialized||s.initializedStoreOnce)&&p.every(e=>(function(e,t){if(!t.languages||!t.languages.length)return k("i18n.languages were undefined or empty",t.languages),!0;const n=t.languages[0],r=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===n.toLowerCase())return!0;const o=(e,n)=>{const r=t.services.backendConnector.state[`${e}|${n}`];return-1===r||2===r};return!!t.hasResourceBundle(n,e)||!t.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e))})(e,s));function d(){return{t:s.getFixedT(null,"fallback"===c.nsMode?p:p[0])}}const g=a(t.useState(d()),2),h=g[0],m=g[1];t.useEffect(()=>{let e=!0;const t=c.bindI18n,n=c.bindI18nStore;function r(){e&&m(d())}return f||u||P(s,p,()=>{e&&m(d())}),t&&s&&s.on(t,r),n&&s&&s.store.on(n,r),()=>{e=!1,t&&s&&t.split(" ").forEach(e=>s.off(e,r)),n&&s&&n.split(" ").forEach(e=>s.store.off(e,r))}},[]);const v=[h.t,s,f];if(v.t=h.t,v.i18n=s,v.ready=f,f)return v;if(!f&&!u)return v;throw new Promise(e=>{P(s,p,()=>{m(d()),e()})})}function L(e,n){const r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).i18n,i=(b()?t.useContext(y):{}).i18n,o=r||i||x();e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),n&&!o.initializedLanguageOnce&&(o.changeLanguage(n),o.initializedLanguageOnce=!0)}e.Trans=function(e){let r=e.children,a=e.count,s=e.parent,c=e.i18nKey,l=e.tOptions,u=e.values,p=e.defaults,f=e.components,d=e.ns,g=e.i18n,h=e.t,m=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]);const v=(b()?t.useContext(y):{}).i18n,j=g||v||x();if(!j)return k("You will need pass in an i18next instance by using i18nextReactModule"),r;const w=h||j.t.bind(j),E=i({},O(),j.options&&j.options.react),S=void 0!==s?s:E.defaultTransParent,$=p||function e(t,r,o,a){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);const s=a.transKeepBasicHtmlNodesFor||[];return r.forEach((r,o)=>{const c=`${o}`;if("string"==typeof r)t=`${t}${r}`;else if(A(r)){const n=s.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:c;t=r.props&&r.props.i18nIsDynamicList?`${t}<${n}></${n}>`:`${t}<${n}>${e("",C(r),o+1,a)}</${n}>`}else if(n.isValidElement(r))t=s.indexOf(r.type)>-1&&0===Object.keys(r.props).length?`${t}<${r.type}/>`:`${t}<${c}></${c}>`;else if("object"==typeof r){const e=i({},r),n=e.format;delete e.format;const o=Object.keys(e);n&&1===o.length?t=`${t}{{${o[0]}, ${n}}}`:1===o.length?t=`${t}{{${o[0]}}}`:N("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else N("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),t}("",r,0,E)||E.transEmptyNodeValue,I=E.hashTransKey,P=c||(I?I($):$),R=i({},l,u,u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:$,count:a,ns:d}),z=P?w(P,R):$;return S?n.createElement(S,m,T(f||r,z,j,E,R)):T(f||r,z,j,E,R)},e.useTranslation=z,e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function o(o,s){const c=a(z(e,o),3),l=i({},o,{t:c[0],i18n:c[1],tReady:c[2]});return t.withRef&&s&&(l.ref=s),n.createElement(r,l)}return o.displayName=`withI18nextTranslation(${R(r)})`,o.WrappedComponent=r,t.withRef?n.forwardRef(o):o}},e.Translation=function(e){const t=e.ns,n=e.children,r=a(z(t,o(e,["ns","children"])),3),i=r[0],s=r[1],c=r[2];return n(i,{i18n:s,lng:s.language},c)},e.I18nextProvider=function(e){let t=e.i18n,r=e.children;return h=!0,n.createElement(y.Provider,{value:{i18n:t}},r)},e.withSSR=function(){return function(e){function t(t){let r=t.initialI18nStore,a=t.initialLanguage,s=o(t,["initialI18nStore","initialLanguage"]);return L(r,a),n.createElement(e,i({},s))}return t.getInitialProps=S(e),t.displayName=`withI18nextSSR(${R(e)})`,t.WrappedComponent=e,t}},e.useSSR=L,e.I18nContext=y,e.initReactI18next=E,e.setDefaults=v,e.getDefaults=O,e.setI18n=w,e.getI18n=x,e.composeInitialProps=S,e.getInitialProps=$,Object.defineProperty(e,"__esModule",{value:!0})});
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactI18next={},e.React)}(this,function(e,t){"use strict";var n="default"in t?t.default:t;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var s={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},c=/([\w-]+)|=|(['"])([.\s\S]*?)\2/g,l=/(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g,u=Object.create?Object.create(null):{};function p(e,t,n,r,i){var o=t.indexOf("<",r),a=t.slice(r,-1===o?void 0:o);/^\s*$/.test(a)&&(a=" "),(!i&&o>-1&&n+e.length>=0||" "!==a)&&e.push({type:"text",content:a})}function f(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(f,"")+"</"+t.name+">"}}var d={parse:function(e,t){t||(t={}),t.components||(t.components=u);var n,r=[],i=-1,o=[],a={},f=!1;return e.replace(l,function(l,u){if(f){if(l!=="</"+n.name+">")return;f=!1}var d,g="/"!==l.charAt(1),h=0===l.indexOf("\x3c!--"),m=u+l.length,y=e.charAt(m);g&&!h&&(i++,"tag"===(n=function(e){var t,n=0,r=!0,i={type:"tag",name:"",voidElement:!1,attrs:{},children:[]};return e.replace(c,function(o){if("="===o)return r=!0,void n++;r?0===n?((s[o]||"/"===e.charAt(e.length-2))&&(i.voidElement=!0),i.name=o):(i.attrs[t]=o.replace(/^['"]|['"]$/g,""),t=void 0):(t&&(i.attrs[t]=t),t=o),n++,r=!1}),i}(l)).type&&t.components[n.name]&&(n.type="component",f=!0),n.voidElement||f||!y||"<"===y||p(n.children,e,i,m,t.ignoreWhitespace),a[n.tagName]=n,0===i&&r.push(n),(d=o[i-1])&&d.children.push(n),o[i]=n),(h||!g||n.voidElement)&&(h||i--,!f&&"<"!==y&&y&&p(d=-1===i?r:o[i].children,e,i,m,t.ignoreWhitespace))}),!r.length&&e.length&&p(r,e,0,0,t.ignoreWhitespace),r},stringify:function(e){return e.reduce(function(e,t){return e+f("",t)},"")}};let g,h,m={bindI18n:"languageChanging languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0};const y=n.createContext();function b(){return h}function v(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m=i({},m,e)}function O(){return m}class S{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}function j(e){g=e}function w(){return g}const N={type:"3rdParty",init(e){v(e.options.react),j(e)}};function x(e){return t=>new Promise(n=>{const r=E();e.getInitialProps?e.getInitialProps(t).then(e=>{n(i({},e,r))}):n(r)})}function E(){const e=w(),t=e.reportNamespaces?e.reportNamespaces.getUsedNamespaces():[],n={},r={};return e.languages.forEach(n=>{r[n]={},t.forEach(t=>{r[n][t]=e.getResourceBundle(n,t)||{}})}),n.initialI18nStore=r,n.initialLanguage=e.language,n}function $(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const I={};function k(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];"string"==typeof t[0]&&I[t[0]]||("string"==typeof t[0]&&(I[t[0]]=new Date),$(...t))}function P(e,t,n){e.loadNamespaces(t,()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout(()=>{e.off("initialized",t)},0),n()};e.on("initialized",t)}})}function R(e){return e.displayName||e.name||("string"==typeof e&&e.length>0?e:"Unknown")}function A(e){return e&&(e.children||e.props&&e.props.children)}function C(e){return e?e&&e.children?e.children:e.props&&e.props.children:[]}function T(e,t,r,o,a){if(""===t)return[];const s=o.transKeepBasicHtmlNodesFor||[],c=t&&new RegExp(s.join("|")).test(t);if(!e&&!c)return[t];const l={};!function e(t){"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),t.forEach(t=>{"string"!=typeof t&&(A(t)?e(C(t)):"object"!=typeof t||n.isValidElement(t)||Object.assign(l,t))})}(e),t=r.services.interpolator.interpolate(t,i({},l,a),r.language);const u=function e(t,r){return"[object Array]"!==Object.prototype.toString.call(t)&&(t=[t]),"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]),r.reduce((r,a,s)=>{const l=a.children&&a.children[0]&&a.children[0].content;if("tag"===a.type){const u=t[parseInt(a.name,10)]||{},p=n.isValidElement(u);if("string"==typeof u)r.push(u);else if(A(u)){const t=C(u),o=e(t,a.children),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.every(e=>n.isValidElement(e))}(t)&&0===o.length?t:o;u.dummy&&(u.children=c),r.push(n.cloneElement(u,i({},u.props,{key:s}),c))}else if(c&&"object"==typeof u&&u.dummy&&!p){const o=e(t,a.children);r.push(n.cloneElement(u,i({},u.props,{key:s}),o))}else if(isNaN(a.name)&&o.transSupportBasicHtmlNodes)if(a.voidElement)r.push(n.createElement(a.name,{key:`${a.name}-${s}`}));else{const i=e(t,a.children);r.push(n.createElement(a.name,{key:`${a.name}-${s}`},i))}else if("object"!=typeof u||p)1===a.children.length&&l?r.push(n.cloneElement(u,i({},u.props,{key:s}),l)):r.push(u);else{const e=a.children[0]?l:null;e&&r.push(e)}}else"text"===a.type&&r.push(a.content);return r},[])}([{dummy:!0,children:e}],d.parse(`<0>${t}</0>`));return C(u[0])}function z(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n.i18n,o=b()?t.useContext(y):{},s=o.i18n,c=o.defaultNS,l=r||s||w();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new S),!l){k("You will need pass in an i18next instance by using initReactI18next");const e=[e=>e,{},!0];return e.t=(e=>e),e.i18n={},e.ready=!0,e}const u=i({},O(),l.options.react),p=n.useSuspense,f=void 0===p?u.useSuspense:p;let d=e||c||l.options&&l.options.defaultNS;d="string"==typeof d?[d]:d||["translation"],l.reportNamespaces.addUsedNamespaces&&l.reportNamespaces.addUsedNamespaces(d);const g=(l.isInitialized||l.initializedStoreOnce)&&d.every(e=>(function(e,t){if(!t.languages||!t.languages.length)return k("i18n.languages were undefined or empty",t.languages),!0;const n=t.languages[0],r=!!t.options&&t.options.fallbackLng,i=t.languages[t.languages.length-1];if("cimode"===n.toLowerCase())return!0;const o=(e,n)=>{const r=t.services.backendConnector.state[`${e}|${n}`];return-1===r||2===r};return!!t.hasResourceBundle(n,e)||!t.services.backendConnector.backend||!(!o(n,e)||r&&!o(i,e))})(e,l));function h(){return{t:l.getFixedT(null,"fallback"===u.nsMode?d:d[0])}}const m=a(t.useState(h()),2),v=m[0],j=m[1];t.useEffect(()=>{let e=!0;const t=u.bindI18n,n=u.bindI18nStore;function r(){e&&j(h())}return g||f||P(l,d,()=>{e&&j(h())}),t&&l&&l.on(t,r),n&&l&&l.store.on(n,r),()=>{e=!1,t&&l&&t.split(" ").forEach(e=>l.off(e,r)),n&&l&&n.split(" ").forEach(e=>l.store.off(e,r))}},[]);const N=[v.t,l,g];if(N.t=v.t,N.i18n=l,N.ready=g,g)return N;if(!g&&!f)return N;throw new Promise(e=>{P(l,d,()=>{j(h()),e()})})}function L(e,n){const r=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).i18n,i=(b()?t.useContext(y):{}).i18n,o=r||i||w();e&&!o.initializedStoreOnce&&(o.services.resourceStore.data=e,o.initializedStoreOnce=!0),n&&!o.initializedLanguageOnce&&(o.changeLanguage(n),o.initializedLanguageOnce=!0)}e.Trans=function(e){let r=e.children,a=e.count,s=e.parent,c=e.i18nKey,l=e.tOptions,u=e.values,p=e.defaults,f=e.components,d=e.ns,g=e.i18n,h=e.t,m=o(e,["children","count","parent","i18nKey","tOptions","values","defaults","components","ns","i18n","t"]);const v=b()?t.useContext(y):{},S=v.i18n,j=v.defaultNS,N=g||S||w();if(!N)return k("You will need pass in an i18next instance by using i18nextReactModule"),r;const x=h||N.t.bind(N),E=i({},O(),N.options&&N.options.react),I=void 0!==s?s:E.defaultTransParent;let P=d||j||N.options&&N.options.defaultNS;P="string"==typeof P?[P]:P||["translation"];const R=p||function e(t,r,o,a){if(!r)return"";"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);const s=a.transKeepBasicHtmlNodesFor||[];return r.forEach((r,o)=>{const c=`${o}`;if("string"==typeof r)t=`${t}${r}`;else if(A(r)){const n=s.indexOf(r.type)>-1&&1===Object.keys(r.props).length&&"string"==typeof A(r)?r.type:c;t=r.props&&r.props.i18nIsDynamicList?`${t}<${n}></${n}>`:`${t}<${n}>${e("",C(r),o+1,a)}</${n}>`}else if(n.isValidElement(r))t=s.indexOf(r.type)>-1&&0===Object.keys(r.props).length?`${t}<${r.type}/>`:`${t}<${c}></${c}>`;else if("object"==typeof r){const e=i({},r),n=e.format;delete e.format;const o=Object.keys(e);n&&1===o.length?t=`${t}{{${o[0]}, ${n}}}`:1===o.length?t=`${t}{{${o[0]}}}`:$("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.",r)}else $("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.",r)}),t}("",r,0,E)||E.transEmptyNodeValue,z=E.hashTransKey,L=c||(z?z(R):R),B=i({},l,u,u?{}:{interpolation:{prefix:"#$?",suffix:"?$#"}},{defaultValue:R,count:a,ns:P}),V=L?x(L,B):R;return I?n.createElement(I,m,T(f||r,V,N,E,B)):T(f||r,V,N,E,B)},e.useTranslation=z,e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function o(o,s){const c=a(z(e,o),3),l=i({},o,{t:c[0],i18n:c[1],tReady:c[2]});return t.withRef&&s&&(l.ref=s),n.createElement(r,l)}return o.displayName=`withI18nextTranslation(${R(r)})`,o.WrappedComponent=r,t.withRef?n.forwardRef(o):o}},e.Translation=function(e){const t=e.ns,n=e.children,r=a(z(t,o(e,["ns","children"])),3),i=r[0],s=r[1],c=r[2];return n(i,{i18n:s,lng:s.language},c)},e.I18nextProvider=function(e){let t=e.i18n,r=e.defaultNS,i=e.children;return h=!0,n.createElement(y.Provider,{value:{i18n:t,defaultNS:r}},i)},e.withSSR=function(){return function(e){function t(t){let r=t.initialI18nStore,a=t.initialLanguage,s=o(t,["initialI18nStore","initialLanguage"]);return L(r,a),n.createElement(e,i({},s))}return t.getInitialProps=x(e),t.displayName=`withI18nextSSR(${R(e)})`,t.WrappedComponent=e,t}},e.useSSR=L,e.I18nContext=y,e.initReactI18next=N,e.setDefaults=v,e.getDefaults=O,e.setI18n=j,e.getI18n=w,e.composeInitialProps=x,e.getInitialProps=E,Object.defineProperty(e,"__esModule",{value:!0})});

src/I18nextProvider.js

@@ -1,7 +1,7 @@
import React from 'react';
import { I18nContext, usedI18nextProvider } from './context';
-export function I18nextProvider({ i18n, children }) {
+export function I18nextProvider({ i18n, defaultNS, children }) {
usedI18nextProvider(true);
return React.createElement(
@@ -9,6 +9,7 @@
{
value: {
i18n,
+ defaultNS,
},
},
children,

src/Trans.js

@@ -199,7 +199,9 @@
t: tFromProps,
...additionalProps
}) {
- const { i18n: i18nFromContext } = getHasUsedI18nextProvider() ? useContext(I18nContext) : {};
+ const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = getHasUsedI18nextProvider()
+ ? useContext(I18nContext)
+ : {};
const i18n = i18nFromProps || i18nFromContext || getI18n();
if (!i18n) {
warnOnce('You will need pass in an i18next instance by using i18nextReactModule');
@@ -211,6 +213,10 @@
const reactI18nextOptions = { ...getDefaults(), ...(i18n.options && i18n.options.react) };
const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
+ // prepare having a namespace
+ let namespaces = ns || defaultNSFromContext || (i18n.options && i18n.options.defaultNS);
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
+
const defaultValue =
defaults ||
nodesToString('', children, 0, reactI18nextOptions) ||
@@ -224,7 +230,7 @@
...interpolationOverride,
defaultValue,
count,
- ns,
+ ns: namespaces,
};
const translation = key ? t(key, combinedTOpts) : defaultValue;

src/useTranslation.js

@@ -11,7 +11,9 @@
export function useTranslation(ns, props = {}) {
// assert we have the needed i18nInstance
const { i18n: i18nFromProps } = props;
- const { i18n: i18nFromContext } = getHasUsedI18nextProvider() ? useContext(I18nContext) : {};
+ const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = getHasUsedI18nextProvider()
+ ? useContext(I18nContext)
+ : {};
const i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
if (!i18n) {
@@ -26,7 +28,7 @@
const { useSuspense = i18nOptions.useSuspense } = props;
// prepare having a namespace
- let namespaces = ns || (i18n.options && i18n.options.defaultNS);
+ let namespaces = ns || defaultNSFromContext || (i18n.options && i18n.options.defaultNS);
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
// report namespaces as used