react-i18next 12.3.1 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/TransWithoutContext.d.ts +18 -16
  3. package/dist/amd/react-i18next.js +827 -1130
  4. package/dist/amd/react-i18next.min.js +1 -1
  5. package/dist/commonjs/I18nextProvider.js +10 -13
  6. package/dist/commonjs/Trans.js +37 -52
  7. package/dist/commonjs/TransWithoutContext.js +130 -168
  8. package/dist/commonjs/Translation.js +8 -22
  9. package/dist/commonjs/context.js +45 -76
  10. package/dist/commonjs/defaults.js +7 -16
  11. package/dist/commonjs/i18nInstance.js +2 -4
  12. package/dist/commonjs/index.js +52 -86
  13. package/dist/commonjs/initReactI18next.js +2 -5
  14. package/dist/commonjs/unescape.js +4 -11
  15. package/dist/commonjs/useSSR.js +10 -14
  16. package/dist/commonjs/useTranslation.js +47 -82
  17. package/dist/commonjs/utils.js +29 -52
  18. package/dist/commonjs/withSSR.js +9 -23
  19. package/dist/commonjs/withTranslation.js +18 -45
  20. package/dist/es/I18nextProvider.js +10 -10
  21. package/dist/es/Trans.js +36 -43
  22. package/dist/es/TransWithoutContext.js +129 -159
  23. package/dist/es/Translation.js +7 -14
  24. package/dist/es/context.js +30 -50
  25. package/dist/es/defaults.js +7 -10
  26. package/dist/es/i18nInstance.js +1 -1
  27. package/dist/es/index.js +6 -18
  28. package/dist/es/initReactI18next.js +2 -2
  29. package/dist/es/package.json +1 -1
  30. package/dist/es/unescape.js +4 -10
  31. package/dist/es/useSSR.js +10 -11
  32. package/dist/es/useTranslation.js +47 -75
  33. package/dist/es/utils.js +25 -43
  34. package/dist/es/withSSR.js +9 -15
  35. package/dist/es/withTranslation.js +17 -35
  36. package/dist/umd/react-i18next.js +828 -1131
  37. package/dist/umd/react-i18next.min.js +1 -1
  38. package/helpers.d.ts +3 -0
  39. package/icu.macro.d.ts +37 -39
  40. package/index.d.ts +44 -37
  41. package/initReactI18next.d.ts +1 -1
  42. package/package.json +36 -36
  43. package/react-i18next.js +828 -1131
  44. package/react-i18next.min.js +1 -1
package/dist/es/useSSR.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { useContext } from 'react';
2
2
  import { getI18n, I18nContext } from './context.js';
3
3
  export function useSSR(initialI18nStore, initialLanguage) {
4
- var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5
- var i18nFromProps = props.i18n;
6
-
7
- var _ref = useContext(I18nContext) || {},
8
- i18nFromContext = _ref.i18n;
9
-
10
- var i18n = i18nFromProps || i18nFromContext || getI18n();
4
+ let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5
+ const {
6
+ i18n: i18nFromProps
7
+ } = props;
8
+ const {
9
+ i18n: i18nFromContext
10
+ } = useContext(I18nContext) || {};
11
+ const i18n = i18nFromProps || i18nFromContext || getI18n();
11
12
  if (i18n.options && i18n.options.isClone) return;
12
-
13
13
  if (initialI18nStore && !i18n.initializedStoreOnce) {
14
14
  i18n.services.resourceStore.data = initialI18nStore;
15
- i18n.options.ns = Object.values(initialI18nStore).reduce(function (mem, lngResources) {
16
- Object.keys(lngResources).forEach(function (ns) {
15
+ i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
16
+ Object.keys(lngResources).forEach(ns => {
17
17
  if (mem.indexOf(ns) < 0) mem.push(ns);
18
18
  });
19
19
  return mem;
@@ -21,7 +21,6 @@ export function useSSR(initialI18nStore, initialLanguage) {
21
21
  i18n.initializedStoreOnce = true;
22
22
  i18n.isInitialized = true;
23
23
  }
24
-
25
24
  if (initialLanguage && !i18n.initializedLanguageOnce) {
26
25
  i18n.changeLanguage(initialLanguage);
27
26
  i18n.initializedLanguageOnce = true;
@@ -1,136 +1,108 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _typeof from "@babel/runtime/helpers/typeof";
4
-
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6
-
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
-
9
1
  import { useState, useEffect, useContext, useRef } from 'react';
10
2
  import { getI18n, getDefaults, ReportNamespaces, I18nContext } from './context.js';
11
3
  import { warnOnce, loadNamespaces, loadLanguages, hasLoadedNamespace } from './utils.js';
12
-
13
- var usePrevious = function usePrevious(value, ignore) {
14
- var ref = useRef();
15
- useEffect(function () {
4
+ const usePrevious = (value, ignore) => {
5
+ const ref = useRef();
6
+ useEffect(() => {
16
7
  ref.current = ignore ? ref.current : value;
17
8
  }, [value, ignore]);
18
9
  return ref.current;
19
10
  };
20
-
21
11
  export function useTranslation(ns) {
22
- var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23
- var i18nFromProps = props.i18n;
24
-
25
- var _ref = useContext(I18nContext) || {},
26
- i18nFromContext = _ref.i18n,
27
- defaultNSFromContext = _ref.defaultNS;
28
-
29
- var i18n = i18nFromProps || i18nFromContext || getI18n();
12
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
+ const {
14
+ i18n: i18nFromProps
15
+ } = props;
16
+ const {
17
+ i18n: i18nFromContext,
18
+ defaultNS: defaultNSFromContext
19
+ } = useContext(I18nContext) || {};
20
+ const i18n = i18nFromProps || i18nFromContext || getI18n();
30
21
  if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
31
-
32
22
  if (!i18n) {
33
23
  warnOnce('You will need to pass in an i18next instance by using initReactI18next');
34
-
35
- var notReadyT = function notReadyT(k, optsOrDefaultValue) {
24
+ const notReadyT = (k, optsOrDefaultValue) => {
36
25
  if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
37
- if (optsOrDefaultValue && _typeof(optsOrDefaultValue) === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
26
+ if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
38
27
  return Array.isArray(k) ? k[k.length - 1] : k;
39
28
  };
40
-
41
- var retNotReady = [notReadyT, {}, false];
29
+ const retNotReady = [notReadyT, {}, false];
42
30
  retNotReady.t = notReadyT;
43
31
  retNotReady.i18n = {};
44
32
  retNotReady.ready = false;
45
33
  return retNotReady;
46
34
  }
47
-
48
35
  if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
49
-
50
- var i18nOptions = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), i18n.options.react), props);
51
-
52
- var useSuspense = i18nOptions.useSuspense,
53
- keyPrefix = i18nOptions.keyPrefix;
54
- var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
36
+ const i18nOptions = {
37
+ ...getDefaults(),
38
+ ...i18n.options.react,
39
+ ...props
40
+ };
41
+ const {
42
+ useSuspense,
43
+ keyPrefix
44
+ } = i18nOptions;
45
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
55
46
  namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
56
47
  if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
57
- var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function (n) {
58
- return hasLoadedNamespace(n, i18n, i18nOptions);
59
- });
60
-
48
+ const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
61
49
  function getT() {
62
50
  return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
63
51
  }
64
-
65
- var _useState = useState(getT),
66
- _useState2 = _slicedToArray(_useState, 2),
67
- t = _useState2[0],
68
- setT = _useState2[1];
69
-
70
- var joinedNS = namespaces.join();
71
- if (props.lng) joinedNS = "".concat(props.lng).concat(joinedNS);
72
- var previousJoinedNS = usePrevious(joinedNS);
73
- var isMounted = useRef(true);
74
- useEffect(function () {
75
- var bindI18n = i18nOptions.bindI18n,
76
- bindI18nStore = i18nOptions.bindI18nStore;
52
+ const [t, setT] = useState(getT);
53
+ let joinedNS = namespaces.join();
54
+ if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
55
+ const previousJoinedNS = usePrevious(joinedNS);
56
+ const isMounted = useRef(true);
57
+ useEffect(() => {
58
+ const {
59
+ bindI18n,
60
+ bindI18nStore
61
+ } = i18nOptions;
77
62
  isMounted.current = true;
78
-
79
63
  if (!ready && !useSuspense) {
80
64
  if (props.lng) {
81
- loadLanguages(i18n, props.lng, namespaces, function () {
65
+ loadLanguages(i18n, props.lng, namespaces, () => {
82
66
  if (isMounted.current) setT(getT);
83
67
  });
84
68
  } else {
85
- loadNamespaces(i18n, namespaces, function () {
69
+ loadNamespaces(i18n, namespaces, () => {
86
70
  if (isMounted.current) setT(getT);
87
71
  });
88
72
  }
89
73
  }
90
-
91
74
  if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
92
75
  setT(getT);
93
76
  }
94
-
95
77
  function boundReset() {
96
78
  if (isMounted.current) setT(getT);
97
79
  }
98
-
99
80
  if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
100
81
  if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
101
- return function () {
82
+ return () => {
102
83
  isMounted.current = false;
103
- if (bindI18n && i18n) bindI18n.split(' ').forEach(function (e) {
104
- return i18n.off(e, boundReset);
105
- });
106
- if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(function (e) {
107
- return i18n.store.off(e, boundReset);
108
- });
84
+ if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
85
+ if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
109
86
  };
110
87
  }, [i18n, joinedNS]);
111
- var isInitial = useRef(true);
112
- useEffect(function () {
88
+ const isInitial = useRef(true);
89
+ useEffect(() => {
113
90
  if (isMounted.current && !isInitial.current) {
114
91
  setT(getT);
115
92
  }
116
-
117
93
  isInitial.current = false;
118
94
  }, [i18n, keyPrefix]);
119
- var ret = [t, i18n, ready];
95
+ const ret = [t, i18n, ready];
120
96
  ret.t = t;
121
97
  ret.i18n = i18n;
122
98
  ret.ready = ready;
123
99
  if (ready) return ret;
124
100
  if (!ready && !useSuspense) return ret;
125
- throw new Promise(function (resolve) {
101
+ throw new Promise(resolve => {
126
102
  if (props.lng) {
127
- loadLanguages(i18n, props.lng, namespaces, function () {
128
- return resolve();
129
- });
103
+ loadLanguages(i18n, props.lng, namespaces, () => resolve());
130
104
  } else {
131
- loadNamespaces(i18n, namespaces, function () {
132
- return resolve();
133
- });
105
+ loadNamespaces(i18n, namespaces, () => resolve());
134
106
  }
135
107
  });
136
108
  }
package/dist/es/utils.js CHANGED
@@ -1,91 +1,73 @@
1
1
  export function warn() {
2
2
  if (console && console.warn) {
3
- var _console;
4
-
5
3
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6
4
  args[_key] = arguments[_key];
7
5
  }
8
-
9
- if (typeof args[0] === 'string') args[0] = "react-i18next:: ".concat(args[0]);
10
-
11
- (_console = console).warn.apply(_console, args);
6
+ if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`;
7
+ console.warn(...args);
12
8
  }
13
9
  }
14
- var alreadyWarned = {};
10
+ const alreadyWarned = {};
15
11
  export function warnOnce() {
16
12
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
17
13
  args[_key2] = arguments[_key2];
18
14
  }
19
-
20
15
  if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
21
16
  if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
22
- warn.apply(void 0, args);
17
+ warn(...args);
23
18
  }
24
-
25
- var loadedClb = function loadedClb(i18n, cb) {
26
- return function () {
27
- if (i18n.isInitialized) {
19
+ const loadedClb = (i18n, cb) => () => {
20
+ if (i18n.isInitialized) {
21
+ cb();
22
+ } else {
23
+ const initialized = () => {
24
+ setTimeout(() => {
25
+ i18n.off('initialized', initialized);
26
+ }, 0);
28
27
  cb();
29
- } else {
30
- var initialized = function initialized() {
31
- setTimeout(function () {
32
- i18n.off('initialized', initialized);
33
- }, 0);
34
- cb();
35
- };
36
-
37
- i18n.on('initialized', initialized);
38
- }
39
- };
28
+ };
29
+ i18n.on('initialized', initialized);
30
+ }
40
31
  };
41
-
42
32
  export function loadNamespaces(i18n, ns, cb) {
43
33
  i18n.loadNamespaces(ns, loadedClb(i18n, cb));
44
34
  }
45
35
  export function loadLanguages(i18n, lng, ns, cb) {
46
36
  if (typeof ns === 'string') ns = [ns];
47
- ns.forEach(function (n) {
37
+ ns.forEach(n => {
48
38
  if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
49
39
  });
50
40
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
51
41
  }
52
-
53
42
  function oldI18nextHasLoadedNamespace(ns, i18n) {
54
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
55
- var lng = i18n.languages[0];
56
- var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
57
- var lastLng = i18n.languages[i18n.languages.length - 1];
43
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
44
+ const lng = i18n.languages[0];
45
+ const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
46
+ const lastLng = i18n.languages[i18n.languages.length - 1];
58
47
  if (lng.toLowerCase() === 'cimode') return true;
59
-
60
- var loadNotPending = function loadNotPending(l, n) {
61
- var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
48
+ const loadNotPending = (l, n) => {
49
+ const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
62
50
  return loadState === -1 || loadState === 2;
63
51
  };
64
-
65
52
  if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
66
53
  if (i18n.hasResourceBundle(lng, ns)) return true;
67
54
  if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
68
55
  if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
69
56
  return false;
70
57
  }
71
-
72
58
  export function hasLoadedNamespace(ns, i18n) {
73
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
74
-
59
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
75
60
  if (!i18n.languages || !i18n.languages.length) {
76
61
  warnOnce('i18n.languages were undefined or empty', i18n.languages);
77
62
  return true;
78
63
  }
79
-
80
- var isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
81
-
64
+ const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
82
65
  if (!isNewerI18next) {
83
66
  return oldI18nextHasLoadedNamespace(ns, i18n, options);
84
67
  }
85
-
86
68
  return i18n.hasLoadedNamespace(ns, {
87
69
  lng: options.lng,
88
- precheck: function precheck(i18nInstance, loadNotPending) {
70
+ precheck: (i18nInstance, loadNotPending) => {
89
71
  if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
90
72
  }
91
73
  });
@@ -1,11 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["initialI18nStore", "initialLanguage"];
4
-
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
6
-
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
-
9
1
  import { createElement } from 'react';
10
2
  import { useSSR } from './useSSR.js';
11
3
  import { composeInitialProps } from './context.js';
@@ -13,16 +5,18 @@ import { getDisplayName } from './utils.js';
13
5
  export function withSSR() {
14
6
  return function Extend(WrappedComponent) {
15
7
  function I18nextWithSSR(_ref) {
16
- var initialI18nStore = _ref.initialI18nStore,
17
- initialLanguage = _ref.initialLanguage,
18
- rest = _objectWithoutProperties(_ref, _excluded);
19
-
8
+ let {
9
+ initialI18nStore,
10
+ initialLanguage,
11
+ ...rest
12
+ } = _ref;
20
13
  useSSR(initialI18nStore, initialLanguage);
21
- return createElement(WrappedComponent, _objectSpread({}, rest));
14
+ return createElement(WrappedComponent, {
15
+ ...rest
16
+ });
22
17
  }
23
-
24
18
  I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent);
25
- I18nextWithSSR.displayName = "withI18nextSSR(".concat(getDisplayName(WrappedComponent), ")");
19
+ I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`;
26
20
  I18nextWithSSR.WrappedComponent = WrappedComponent;
27
21
  return I18nextWithSSR;
28
22
  };
@@ -1,54 +1,36 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["forwardedRef"];
5
-
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
-
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
-
10
1
  import { createElement, forwardRef as forwardRefReact } from 'react';
11
2
  import { useTranslation } from './useTranslation.js';
12
3
  import { getDisplayName } from './utils.js';
13
4
  export function withTranslation(ns) {
14
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
6
  return function Extend(WrappedComponent) {
16
7
  function I18nextWithTranslation(_ref) {
17
- var forwardedRef = _ref.forwardedRef,
18
- rest = _objectWithoutProperties(_ref, _excluded);
19
-
20
- var _useTranslation = useTranslation(ns, _objectSpread(_objectSpread({}, rest), {}, {
8
+ let {
9
+ forwardedRef,
10
+ ...rest
11
+ } = _ref;
12
+ const [t, i18n, ready] = useTranslation(ns, {
13
+ ...rest,
21
14
  keyPrefix: options.keyPrefix
22
- })),
23
- _useTranslation2 = _slicedToArray(_useTranslation, 3),
24
- t = _useTranslation2[0],
25
- i18n = _useTranslation2[1],
26
- ready = _useTranslation2[2];
27
-
28
- var passDownProps = _objectSpread(_objectSpread({}, rest), {}, {
29
- t: t,
30
- i18n: i18n,
31
- tReady: ready
32
15
  });
33
-
16
+ const passDownProps = {
17
+ ...rest,
18
+ t,
19
+ i18n,
20
+ tReady: ready
21
+ };
34
22
  if (options.withRef && forwardedRef) {
35
23
  passDownProps.ref = forwardedRef;
36
24
  } else if (!options.withRef && forwardedRef) {
37
25
  passDownProps.forwardedRef = forwardedRef;
38
26
  }
39
-
40
27
  return createElement(WrappedComponent, passDownProps);
41
28
  }
42
-
43
- I18nextWithTranslation.displayName = "withI18nextTranslation(".concat(getDisplayName(WrappedComponent), ")");
29
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
44
30
  I18nextWithTranslation.WrappedComponent = WrappedComponent;
45
-
46
- var forwardRef = function forwardRef(props, ref) {
47
- return createElement(I18nextWithTranslation, Object.assign({}, props, {
48
- forwardedRef: ref
49
- }));
50
- };
51
-
31
+ const forwardRef = (props, ref) => createElement(I18nextWithTranslation, Object.assign({}, props, {
32
+ forwardedRef: ref
33
+ }));
52
34
  return options.withRef ? forwardRefReact(forwardRef) : I18nextWithTranslation;
53
35
  };
54
36
  }