react-i18next 12.0.0 → 12.1.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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/TransWithoutContext.d.ts +33 -0
  4. package/dist/amd/react-i18next.js +178 -133
  5. package/dist/amd/react-i18next.min.js +1 -1
  6. package/dist/commonjs/I18nextProvider.js +1 -1
  7. package/dist/commonjs/Trans.js +27 -244
  8. package/dist/commonjs/TransWithoutContext.js +288 -0
  9. package/dist/commonjs/Translation.js +1 -1
  10. package/dist/commonjs/context.js +39 -46
  11. package/dist/commonjs/defaults.js +37 -0
  12. package/dist/commonjs/i18nInstance.js +16 -0
  13. package/dist/commonjs/index.js +16 -8
  14. package/dist/commonjs/initReactI18next.js +19 -0
  15. package/dist/commonjs/useSSR.js +1 -1
  16. package/dist/commonjs/useTranslation.js +2 -2
  17. package/dist/commonjs/withSSR.js +3 -3
  18. package/dist/commonjs/withTranslation.js +2 -2
  19. package/dist/es/I18nextProvider.js +1 -1
  20. package/dist/es/Trans.js +22 -242
  21. package/dist/es/TransWithoutContext.js +272 -0
  22. package/dist/es/Translation.js +1 -1
  23. package/dist/es/context.js +5 -33
  24. package/dist/es/defaults.js +24 -0
  25. package/dist/es/i18nInstance.js +7 -0
  26. package/dist/es/index.js +9 -8
  27. package/dist/es/initReactI18next.js +9 -0
  28. package/dist/es/package.json +1 -0
  29. package/dist/es/useSSR.js +1 -1
  30. package/dist/es/useTranslation.js +2 -2
  31. package/dist/es/withSSR.js +3 -3
  32. package/dist/es/withTranslation.js +2 -2
  33. package/dist/umd/react-i18next.js +178 -133
  34. package/dist/umd/react-i18next.min.js +1 -1
  35. package/index.d.ts +2 -32
  36. package/initReactI18next.d.ts +3 -0
  37. package/package.json +25 -6
  38. package/react-i18next.js +178 -133
  39. package/react-i18next.min.js +1 -1
  40. package/src/I18nextProvider.js +1 -1
  41. package/src/Trans.js +18 -316
  42. package/src/TransWithoutContext.js +343 -0
  43. package/src/Translation.js +1 -1
  44. package/src/context.js +4 -40
  45. package/src/defaults.js +22 -0
  46. package/src/i18nInstance.js +9 -0
  47. package/src/index.js +9 -8
  48. package/src/initReactI18next.js +11 -0
  49. package/src/useSSR.js +2 -2
  50. package/src/useTranslation.js +2 -2
  51. package/src/withSSR.js +3 -3
  52. package/src/withTranslation.js +2 -2
  53. package/tslint.json +2 -1
@@ -0,0 +1,272 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ var _excluded = ["format"],
5
+ _excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ import { isValidElement, cloneElement, createElement } from 'react';
12
+ import HTML from 'html-parse-stringify';
13
+ import { warn, warnOnce } from './utils.js';
14
+ import { getDefaults } from './defaults.js';
15
+ import { getI18n } from './i18nInstance.js';
16
+
17
+ function hasChildren(node, checkLength) {
18
+ if (!node) return false;
19
+ var base = node.props ? node.props.children : node.children;
20
+ if (checkLength) return base.length > 0;
21
+ return !!base;
22
+ }
23
+
24
+ function getChildren(node) {
25
+ if (!node) return [];
26
+ return node.props ? node.props.children : node.children;
27
+ }
28
+
29
+ function hasValidReactChildren(children) {
30
+ if (Object.prototype.toString.call(children) !== '[object Array]') return false;
31
+ return children.every(function (child) {
32
+ return isValidElement(child);
33
+ });
34
+ }
35
+
36
+ function getAsArray(data) {
37
+ return Array.isArray(data) ? data : [data];
38
+ }
39
+
40
+ function mergeProps(source, target) {
41
+ var newTarget = _objectSpread({}, target);
42
+
43
+ newTarget.props = Object.assign(source.props, target.props);
44
+ return newTarget;
45
+ }
46
+
47
+ export function nodesToString(children, i18nOptions) {
48
+ if (!children) return '';
49
+ var stringNode = '';
50
+ var childrenArray = getAsArray(children);
51
+ var keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
52
+ childrenArray.forEach(function (child, childIndex) {
53
+ if (typeof child === 'string') {
54
+ stringNode += "".concat(child);
55
+ } else if (isValidElement(child)) {
56
+ var childPropsCount = Object.keys(child.props).length;
57
+ var shouldKeepChild = keepArray.indexOf(child.type) > -1;
58
+ var childChildren = child.props.children;
59
+
60
+ if (!childChildren && shouldKeepChild && childPropsCount === 0) {
61
+ stringNode += "<".concat(child.type, "/>");
62
+ } else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
63
+ stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
64
+ } else if (child.props.i18nIsDynamicList) {
65
+ stringNode += "<".concat(childIndex, "></").concat(childIndex, ">");
66
+ } else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') {
67
+ stringNode += "<".concat(child.type, ">").concat(childChildren, "</").concat(child.type, ">");
68
+ } else {
69
+ var content = nodesToString(childChildren, i18nOptions);
70
+ stringNode += "<".concat(childIndex, ">").concat(content, "</").concat(childIndex, ">");
71
+ }
72
+ } else if (child === null) {
73
+ warn("Trans: the passed in value is invalid - seems you passed in a null child.");
74
+ } else if (_typeof(child) === 'object') {
75
+ var format = child.format,
76
+ clone = _objectWithoutProperties(child, _excluded);
77
+
78
+ var keys = Object.keys(clone);
79
+
80
+ if (keys.length === 1) {
81
+ var value = format ? "".concat(keys[0], ", ").concat(format) : keys[0];
82
+ stringNode += "{{".concat(value, "}}");
83
+ } else {
84
+ warn("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", child);
85
+ }
86
+ } else {
87
+ warn("Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.", child);
88
+ }
89
+ });
90
+ return stringNode;
91
+ }
92
+
93
+ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
94
+ if (targetString === '') return [];
95
+ var keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
96
+ var emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.join('|')).test(targetString);
97
+ if (!children && !emptyChildrenButNeedsHandling) return [targetString];
98
+ var data = {};
99
+
100
+ function getData(childs) {
101
+ var childrenArray = getAsArray(childs);
102
+ childrenArray.forEach(function (child) {
103
+ if (typeof child === 'string') return;
104
+ if (hasChildren(child)) getData(getChildren(child));else if (_typeof(child) === 'object' && !isValidElement(child)) Object.assign(data, child);
105
+ });
106
+ }
107
+
108
+ getData(children);
109
+ var ast = HTML.parse("<0>".concat(targetString, "</0>"));
110
+
111
+ var opts = _objectSpread(_objectSpread({}, data), combinedTOpts);
112
+
113
+ function renderInner(child, node, rootReactNode) {
114
+ var childs = getChildren(child);
115
+ var mappedChildren = mapAST(childs, node.children, rootReactNode);
116
+ return hasValidReactChildren(childs) && mappedChildren.length === 0 ? childs : mappedChildren;
117
+ }
118
+
119
+ function pushTranslatedJSX(child, inner, mem, i, isVoid) {
120
+ if (child.dummy) child.children = inner;
121
+ mem.push(cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
122
+ key: i
123
+ }), isVoid ? undefined : inner));
124
+ }
125
+
126
+ function mapAST(reactNode, astNode, rootReactNode) {
127
+ var reactNodes = getAsArray(reactNode);
128
+ var astNodes = getAsArray(astNode);
129
+ return astNodes.reduce(function (mem, node, i) {
130
+ var translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
131
+
132
+ if (node.type === 'tag') {
133
+ var tmp = reactNodes[parseInt(node.name, 10)];
134
+ if (!tmp && rootReactNode.length === 1 && rootReactNode[0][node.name]) tmp = rootReactNode[0][node.name];
135
+ if (!tmp) tmp = {};
136
+ var child = Object.keys(node.attrs).length !== 0 ? mergeProps({
137
+ props: node.attrs
138
+ }, tmp) : tmp;
139
+ var isElement = isValidElement(child);
140
+ var isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
141
+ var isEmptyTransWithHTML = emptyChildrenButNeedsHandling && _typeof(child) === 'object' && child.dummy && !isElement;
142
+ var isKnownComponent = _typeof(children) === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);
143
+
144
+ if (typeof child === 'string') {
145
+ var value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
146
+ mem.push(value);
147
+ } else if (hasChildren(child) || isValidTranslationWithChildren) {
148
+ var inner = renderInner(child, node, rootReactNode);
149
+ pushTranslatedJSX(child, inner, mem, i);
150
+ } else if (isEmptyTransWithHTML) {
151
+ var _inner = mapAST(reactNodes, node.children, rootReactNode);
152
+
153
+ mem.push(cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
154
+ key: i
155
+ }), _inner));
156
+ } else if (Number.isNaN(parseFloat(node.name))) {
157
+ if (isKnownComponent) {
158
+ var _inner2 = renderInner(child, node, rootReactNode);
159
+
160
+ pushTranslatedJSX(child, _inner2, mem, i, node.voidElement);
161
+ } else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
162
+ if (node.voidElement) {
163
+ mem.push(createElement(node.name, {
164
+ key: "".concat(node.name, "-").concat(i)
165
+ }));
166
+ } else {
167
+ var _inner3 = mapAST(reactNodes, node.children, rootReactNode);
168
+
169
+ mem.push(createElement(node.name, {
170
+ key: "".concat(node.name, "-").concat(i)
171
+ }, _inner3));
172
+ }
173
+ } else if (node.voidElement) {
174
+ mem.push("<".concat(node.name, " />"));
175
+ } else {
176
+ var _inner4 = mapAST(reactNodes, node.children, rootReactNode);
177
+
178
+ mem.push("<".concat(node.name, ">").concat(_inner4, "</").concat(node.name, ">"));
179
+ }
180
+ } else if (_typeof(child) === 'object' && !isElement) {
181
+ var content = node.children[0] ? translationContent : null;
182
+ if (content) mem.push(content);
183
+ } else if (node.children.length === 1 && translationContent) {
184
+ mem.push(cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
185
+ key: i
186
+ }), translationContent));
187
+ } else {
188
+ mem.push(cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
189
+ key: i
190
+ })));
191
+ }
192
+ } else if (node.type === 'text') {
193
+ var wrapTextNodes = i18nOptions.transWrapTextNodes;
194
+
195
+ var _content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
196
+
197
+ if (wrapTextNodes) {
198
+ mem.push(createElement(wrapTextNodes, {
199
+ key: "".concat(node.name, "-").concat(i)
200
+ }, _content));
201
+ } else {
202
+ mem.push(_content);
203
+ }
204
+ }
205
+
206
+ return mem;
207
+ }, []);
208
+ }
209
+
210
+ var result = mapAST([{
211
+ dummy: true,
212
+ children: children || []
213
+ }], ast, getAsArray(children || []));
214
+ return getChildren(result[0]);
215
+ }
216
+
217
+ export function Trans(_ref) {
218
+ var children = _ref.children,
219
+ count = _ref.count,
220
+ parent = _ref.parent,
221
+ i18nKey = _ref.i18nKey,
222
+ context = _ref.context,
223
+ _ref$tOptions = _ref.tOptions,
224
+ tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
225
+ values = _ref.values,
226
+ defaults = _ref.defaults,
227
+ components = _ref.components,
228
+ ns = _ref.ns,
229
+ i18nFromProps = _ref.i18n,
230
+ tFromProps = _ref.t,
231
+ shouldUnescape = _ref.shouldUnescape,
232
+ additionalProps = _objectWithoutProperties(_ref, _excluded2);
233
+
234
+ var i18n = i18nFromProps || getI18n();
235
+
236
+ if (!i18n) {
237
+ warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
238
+ return children;
239
+ }
240
+
241
+ var t = tFromProps || i18n.t.bind(i18n) || function (k) {
242
+ return k;
243
+ };
244
+
245
+ if (context) tOptions.context = context;
246
+
247
+ var reactI18nextOptions = _objectSpread(_objectSpread({}, getDefaults()), i18n.options && i18n.options.react);
248
+
249
+ var namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
250
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
251
+ var defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
252
+ var hashTransKey = reactI18nextOptions.hashTransKey;
253
+ var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
254
+ var interpolationOverride = values ? tOptions.interpolation : {
255
+ interpolation: _objectSpread(_objectSpread({}, tOptions.interpolation), {}, {
256
+ prefix: '#$?',
257
+ suffix: '?$#'
258
+ })
259
+ };
260
+
261
+ var combinedTOpts = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, tOptions), {}, {
262
+ count: count
263
+ }, values), interpolationOverride), {}, {
264
+ defaultValue: defaultValue,
265
+ ns: namespaces
266
+ });
267
+
268
+ var translation = key ? t(key, combinedTOpts) : defaultValue;
269
+ var content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
270
+ var useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
271
+ return useAsParent ? createElement(useAsParent, additionalProps, content) : content;
272
+ }
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["ns", "children"];
4
- import { useTranslation } from './useTranslation';
4
+ import { useTranslation } from './useTranslation.js';
5
5
  export function Translation(props) {
6
6
  var ns = props.ns,
7
7
  children = props.children,
@@ -1,32 +1,17 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
 
5
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
6
 
7
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
8
 
9
9
  import { createContext } from 'react';
10
- import { unescape } from './unescape';
11
- var defaultOptions = {
12
- bindI18n: 'languageChanged',
13
- bindI18nStore: '',
14
- transEmptyNodeValue: '',
15
- transSupportBasicHtmlNodes: true,
16
- transWrapTextNodes: '',
17
- transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
18
- useSuspense: true,
19
- unescape: unescape
20
- };
21
- var i18nInstance;
10
+ import { getDefaults, setDefaults } from './defaults.js';
11
+ import { getI18n, setI18n } from './i18nInstance.js';
12
+ import { initReactI18next } from './initReactI18next.js';
13
+ export { getDefaults, setDefaults, getI18n, setI18n, initReactI18next };
22
14
  export var I18nContext = createContext();
23
- export function setDefaults() {
24
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
- defaultOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
26
- }
27
- export function getDefaults() {
28
- return defaultOptions;
29
- }
30
15
  export var ReportNamespaces = function () {
31
16
  function ReportNamespaces() {
32
17
  _classCallCheck(this, ReportNamespaces);
@@ -52,19 +37,6 @@ export var ReportNamespaces = function () {
52
37
 
53
38
  return ReportNamespaces;
54
39
  }();
55
- export function setI18n(instance) {
56
- i18nInstance = instance;
57
- }
58
- export function getI18n() {
59
- return i18nInstance;
60
- }
61
- export var initReactI18next = {
62
- type: '3rdParty',
63
- init: function init(instance) {
64
- setDefaults(instance.options.react);
65
- setI18n(instance);
66
- }
67
- };
68
40
  export function composeInitialProps(ForComponent) {
69
41
  return function (ctx) {
70
42
  return new Promise(function (resolve) {
@@ -0,0 +1,24 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ import { unescape } from './unescape.js';
8
+ var defaultOptions = {
9
+ bindI18n: 'languageChanged',
10
+ bindI18nStore: '',
11
+ transEmptyNodeValue: '',
12
+ transSupportBasicHtmlNodes: true,
13
+ transWrapTextNodes: '',
14
+ transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
15
+ useSuspense: true,
16
+ unescape: unescape
17
+ };
18
+ export function setDefaults() {
19
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20
+ defaultOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
21
+ }
22
+ export function getDefaults() {
23
+ return defaultOptions;
24
+ }
@@ -0,0 +1,7 @@
1
+ var i18nInstance;
2
+ export function setI18n(instance) {
3
+ i18nInstance = instance;
4
+ }
5
+ export function getI18n() {
6
+ return i18nInstance;
7
+ }
package/dist/es/index.js CHANGED
@@ -1,11 +1,12 @@
1
- export { Trans } from './Trans';
2
- export { useTranslation } from './useTranslation';
3
- export { withTranslation } from './withTranslation';
4
- export { Translation } from './Translation';
5
- export { I18nextProvider } from './I18nextProvider';
6
- export { withSSR } from './withSSR';
7
- export { useSSR } from './useSSR';
8
- export { I18nContext, initReactI18next, setDefaults, getDefaults, setI18n, getI18n, composeInitialProps, getInitialProps } from './context';
1
+ export { Trans } from './Trans.js';
2
+ export { Trans as TransWithoutContext } from './TransWithoutContext.js';
3
+ export { useTranslation } from './useTranslation.js';
4
+ export { withTranslation } from './withTranslation.js';
5
+ export { Translation } from './Translation.js';
6
+ export { I18nextProvider } from './I18nextProvider.js';
7
+ export { withSSR } from './withSSR.js';
8
+ export { useSSR } from './useSSR.js';
9
+ export { I18nContext, initReactI18next, setDefaults, getDefaults, setI18n, getI18n, composeInitialProps, getInitialProps } from './context.js';
9
10
  export var date = function date() {
10
11
  return '';
11
12
  };
@@ -0,0 +1,9 @@
1
+ import { setDefaults } from './defaults.js';
2
+ import { setI18n } from './i18nInstance.js';
3
+ export var initReactI18next = {
4
+ type: '3rdParty',
5
+ init: function init(instance) {
6
+ setDefaults(instance.options.react);
7
+ setI18n(instance);
8
+ }
9
+ };
@@ -0,0 +1 @@
1
+ {"type":"module","version":"12.1.1"}
package/dist/es/useSSR.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useContext } from 'react';
2
- import { getI18n, I18nContext } from './context';
2
+ import { getI18n, I18nContext } from './context.js';
3
3
  export function useSSR(initialI18nStore, initialLanguage) {
4
4
  var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5
5
  var i18nFromProps = props.i18n;
@@ -6,8 +6,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  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; }
7
7
 
8
8
  import { useState, useEffect, useContext, useRef } from 'react';
9
- import { getI18n, getDefaults, ReportNamespaces, I18nContext } from './context';
10
- import { warnOnce, loadNamespaces, hasLoadedNamespace } from './utils';
9
+ import { getI18n, getDefaults, ReportNamespaces, I18nContext } from './context.js';
10
+ import { warnOnce, loadNamespaces, hasLoadedNamespace } from './utils.js';
11
11
 
12
12
  var usePrevious = function usePrevious(value, ignore) {
13
13
  var ref = useRef();
@@ -7,9 +7,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
7
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
8
 
9
9
  import { createElement } from 'react';
10
- import { useSSR } from './useSSR';
11
- import { composeInitialProps } from './context';
12
- import { getDisplayName } from './utils';
10
+ import { useSSR } from './useSSR.js';
11
+ import { composeInitialProps } from './context.js';
12
+ import { getDisplayName } from './utils.js';
13
13
  export function withSSR() {
14
14
  return function Extend(WrappedComponent) {
15
15
  function I18nextWithSSR(_ref) {
@@ -8,8 +8,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
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
9
 
10
10
  import { createElement, forwardRef as forwardRefReact } from 'react';
11
- import { useTranslation } from './useTranslation';
12
- import { getDisplayName } from './utils';
11
+ import { useTranslation } from './useTranslation.js';
12
+ import { getDisplayName } from './utils.js';
13
13
  export function withTranslation(ns) {
14
14
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
15
  return function Extend(WrappedComponent) {