next-i18next 12.1.0 → 13.0.0

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.
@@ -0,0 +1,80 @@
1
+ // @ts-check
2
+
3
+ const fullEsmMaxSize = "5KB";
4
+ // Recent Nextjs version have some optimizations for commonjs that
5
+ // aren't available on bare-bone webpack. don't worry about threshold
6
+ // difference here for cjs. We can keep this till cjs is supported.
7
+ const fullCjsMaxSize = "29KB";
8
+
9
+ const getSimpleExamplePageLimits = () => {
10
+ const dir = './examples/simple/.next'
11
+ let manifest;
12
+ try {
13
+ manifest = require(`${dir}/build-manifest.json`);
14
+ } catch (e) {
15
+ throw new Error(
16
+ 'Cannot find a NextJs build folder, did you forget to run build:examples ?'
17
+ );
18
+ }
19
+ const limitCfg = {
20
+ defaultSize: '90kb',
21
+ pages: {
22
+ '/': '85kb',
23
+ '/404': '90kb',
24
+ '/_app': '100kb',
25
+ '/_error': '80Kb',
26
+ '/second-page': '85Kb'
27
+ },
28
+ };
29
+ let pageLimits = [];
30
+ for (const [uri, paths] of Object.entries(manifest.pages)) {
31
+ pageLimits.push({
32
+ name: `Example app: page '${uri}'`,
33
+ limit: limitCfg.pages?.[uri] ?? limitCfg.defaultSize,
34
+ webpack: false,
35
+ path: paths.map(p => `${dir}/${p}`)
36
+ });
37
+ }
38
+ return pageLimits;
39
+ }
40
+
41
+ const modifyWebpackConfig = config => {
42
+ config.resolve = {};
43
+ config.resolve.fallback = { "path": false, "fs": false };
44
+ }
45
+
46
+ /**
47
+ * Will ensure esm tree-shakeability and total size are within expectations.
48
+ *
49
+ * @link https://github.com/ai/size-limit/
50
+ * @type {{name: string, path: string[], limit: string, import?: string, webpack?: boolean, modifyWebpackConfig: any}[]}
51
+ */
52
+ module.exports = [
53
+ // ###################################################
54
+ // Dist ESM full bundle
55
+ // ###################################################
56
+ {
57
+ name: "ESM (import everything *)",
58
+ path: ["dist/esm/index.js"],
59
+ import: "*",
60
+ limit: fullEsmMaxSize,
61
+ modifyWebpackConfig,
62
+ },
63
+ // ###################################################
64
+ // Fist commonjs full bundle
65
+ // Tip: older versions of nextjs will not tree-shake
66
+ // cjs very well. This explains threshold differences
67
+ // ###################################################
68
+ {
69
+ name: "CJS (require everything *)",
70
+ path: ["dist/commonjs/index.js"],
71
+ import: "*",
72
+ webpack: true,
73
+ limit: fullCjsMaxSize,
74
+ modifyWebpackConfig,
75
+ },
76
+ // ###################################################
77
+ // Example apps
78
+ // ###################################################
79
+ ...getSimpleExamplePageLimits(),
80
+ ];
package/README.md CHANGED
@@ -41,8 +41,8 @@ Now our Next.js app is fully translatable!
41
41
 
42
42
  ### 1. Installation
43
43
 
44
- ```jsx
45
- yarn add next-i18next
44
+ ```bash
45
+ yarn add next-i18next react-i18next i18next
46
46
  ```
47
47
 
48
48
  You need to also have `react` and `next` installed.
@@ -155,7 +155,7 @@ export const Footer = () => {
155
155
 
156
156
  By default, `next-i18next` will send _all your namespaces_ down to the client on each initial request. This can be an appropriate approach for smaller apps with less content, but a lot of apps will benefit from splitting namespaces based on route.
157
157
 
158
- To do that, you can pass an array of required namespaces for each page into `serverSideTranslations`. You can see this approach in [examples/simple/pages/index.js](./examples/simple/pages/index.js). Passing in an empty array of required namespaces will send no namespaces.
158
+ To do that, you can pass an array of required namespaces for each page into `serverSideTranslations`. You can see this approach in [examples/simple/pages/index.tsx](./examples/simple/pages/index.tsx). Passing in an empty array of required namespaces will send no namespaces.
159
159
 
160
160
  Note: `useTranslation` provides namespaces to the component that you use it in. However, `serverSideTranslations` provides the total available namespaces to the entire React tree and belongs on the page level. Both are required.
161
161
 
@@ -215,20 +215,20 @@ Be aware that using `fallbackLng` and `nonExplicitSupportedLngs` can easily incr
215
215
  If you need to modify more advanced configuration options, you can pass them via `next-i18next.config.js`. For example:
216
216
 
217
217
  ```js
218
- const path = require('path');
219
-
220
218
  module.exports = {
221
219
  i18n: {
222
220
  defaultLocale: 'en',
223
221
  locales: ['en', 'de'],
224
222
  },
225
- localePath: path.resolve('./my/custom/path'),
223
+ localePath: typeof window === 'undefined' ?
224
+ require('path').resolve('./my-custom/path'):
225
+ '/public/my-custom/path',
226
226
  };
227
227
  ```
228
228
 
229
- #### Unserialisable configs
229
+ #### Unserializable configs
230
230
 
231
- Some `i18next` plugins (which you can pass into `config.use`) are unserialisable, as they contain functions and other JavaScript primitives.
231
+ Some `i18next` plugins (which you can pass into `config.use`) are unserializable, as they contain functions and other JavaScript primitives.
232
232
 
233
233
  You may run into this if your use case is more advanced. You'll see Next.js throw an error like:
234
234
 
@@ -367,19 +367,27 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
367
367
  <!-- prettier-ignore-start -->
368
368
  <!-- markdownlint-disable -->
369
369
  <table>
370
- <tr>
371
- <td align="center"><a href="https://locize.com/"><img src="https://avatars.githubusercontent.com/u/1086194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Adriano Raiano</b></sub></a><br /><a href="#question-adrai" title="Answering Questions">💬</a> <a href="#blog-adrai" title="Blogposts">📝</a> <a href="https://github.com/i18next/next-i18next/issues?q=author%3Aadrai" title="Bug reports">🐛</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Documentation">📖</a> <a href="#example-adrai" title="Examples">💡</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aadrai" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Tests">⚠️</a> <a href="#tutorial-adrai" title="Tutorials">✅</a></td>
372
- <td align="center"><a href="https://isaachinman.com/"><img src="https://avatars.githubusercontent.com/u/10575782?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Isaac Hinman</b></sub></a><br /><a href="#question-isaachinman" title="Answering Questions">💬</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Code">💻</a> <a href="#content-isaachinman" title="Content">🖋</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Documentation">📖</a> <a href="#example-isaachinman" title="Examples">💡</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aisaachinman" title="Reviewed Pull Requests">👀</a></td>
373
- <td align="center"><a href="https://github.com/capellini"><img src="https://avatars3.githubusercontent.com/u/75311?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rob Capellini</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Tests">⚠️</a></td>
374
- <td align="center"><a href="https://en.kachkaev.ru"><img src="https://avatars3.githubusercontent.com/u/608862?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alexander Kachkaev</b></sub></a><br /><a href="#talk-kachkaev" title="Talks">📢</a> <a href="#question-kachkaev" title="Answering Questions">💬</a> <a href="#ideas-kachkaev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Tests">⚠️</a></td>
375
- <td align="center"><a href="https://github.com/felixmosh"><img src="https://avatars.githubusercontent.com/u/9304194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Felix Mosheev</b></sub></a><br /><a href="#question-felixmosh" title="Answering Questions">💬</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Code">💻</a> <a href="#talk-felixmosh" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Tests">⚠️</a></td>
376
- <td align="center"><a href="https://kandelborg.dk"><img src="https://avatars1.githubusercontent.com/u/33042011?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mathias Wøbbe</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Code">💻</a> <a href="#ideas-MathiasKandelborg" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Tests">⚠️</a></td>
377
- <td align="center"><a href="http://lucasfeliciano.com"><img src="https://avatars3.githubusercontent.com/u/968014?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lucas Feliciano</b></sub></a><br /><a href="#ideas-lucasfeliciano" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Alucasfeliciano" title="Reviewed Pull Requests">👀</a></td>
378
- </tr>
370
+ <tbody>
371
+ <tr>
372
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/capellini"><img src="https://avatars3.githubusercontent.com/u/75311?v=4?s=100" width="100px;" alt="Rob Capellini"/><br /><sub><b>Rob Capellini</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=capellini" title="Tests">⚠️</a></td>
373
+ <td align="center" valign="top" width="14.28%"><a href="https://en.kachkaev.ru"><img src="https://avatars3.githubusercontent.com/u/608862?v=4?s=100" width="100px;" alt="Alexander Kachkaev"/><br /><sub><b>Alexander Kachkaev</b></sub></a><br /><a href="#talk-kachkaev" title="Talks">📢</a> <a href="#question-kachkaev" title="Answering Questions">💬</a> <a href="#ideas-kachkaev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=kachkaev" title="Tests">⚠️</a></td>
374
+ <td align="center" valign="top" width="14.28%"><a href="https://kandelborg.dk"><img src="https://avatars1.githubusercontent.com/u/33042011?v=4?s=100" width="100px;" alt="Mathias Wøbbe"/><br /><sub><b>Mathias Wøbbe</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Code">💻</a> <a href="#ideas-MathiasKandelborg" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/commits?author=MathiasKandelborg" title="Tests">⚠️</a></td>
375
+ <td align="center" valign="top" width="14.28%"><a href="http://lucasfeliciano.com"><img src="https://avatars3.githubusercontent.com/u/968014?v=4?s=100" width="100px;" alt="Lucas Feliciano"/><br /><sub><b>Lucas Feliciano</b></sub></a><br /><a href="#ideas-lucasfeliciano" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Alucasfeliciano" title="Reviewed Pull Requests">👀</a></td>
376
+ <td align="center" valign="top" width="14.28%"><a href="http://www.fifteenprospects.com"><img src="https://avatars2.githubusercontent.com/u/6932550?v=4?s=100" width="100px;" alt="Ryan Leung"/><br /><sub><b>Ryan Leung</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=minocys" title="Code">💻</a></td>
377
+ <td align="center" valign="top" width="14.28%"><a href="http://nathanfriemel.com"><img src="https://avatars3.githubusercontent.com/u/1325835?v=4?s=100" width="100px;" alt="Nathan Friemel"/><br /><sub><b>Nathan Friemel</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=nathanfriemel" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=nathanfriemel" title="Documentation">📖</a> <a href="#example-nathanfriemel" title="Examples">💡</a> <a href="#ideas-nathanfriemel" title="Ideas, Planning, & Feedback">🤔</a></td>
378
+ <td align="center" valign="top" width="14.28%"><a href="https://isaachinman.com/"><img src="https://avatars.githubusercontent.com/u/10575782?v=4?s=100" width="100px;" alt="Isaac Hinman"/><br /><sub><b>Isaac Hinman</b></sub></a><br /><a href="#a11y-isaachinman" title="Accessibility">️️️️♿️</a> <a href="#question-isaachinman" title="Answering Questions">💬</a> <a href="#audio-isaachinman" title="Audio">🔊</a> <a href="#blog-isaachinman" title="Blogposts">📝</a> <a href="https://github.com/i18next/next-i18next/issues?q=author%3Aisaachinman" title="Bug reports">🐛</a> <a href="#business-isaachinman" title="Business development">💼</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Code">💻</a> <a href="#content-isaachinman" title="Content">🖋</a> <a href="#data-isaachinman" title="Data">🔣</a> <a href="#design-isaachinman" title="Design">🎨</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Documentation">📖</a> <a href="#eventOrganizing-isaachinman" title="Event Organizing">📋</a> <a href="#example-isaachinman" title="Examples">💡</a> <a href="#financial-isaachinman" title="Financial">💵</a> <a href="#fundingFinding-isaachinman" title="Funding Finding">🔍</a> <a href="#ideas-isaachinman" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-isaachinman" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-isaachinman" title="Maintenance">🚧</a> <a href="#mentoring-isaachinman" title="Mentoring">🧑‍🏫</a> <a href="#platform-isaachinman" title="Packaging/porting to new platform">📦</a> <a href="#plugin-isaachinman" title="Plugin/utility libraries">🔌</a> <a href="#projectManagement-isaachinman" title="Project Management">📆</a> <a href="#research-isaachinman" title="Research">🔬</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aisaachinman" title="Reviewed Pull Requests">👀</a> <a href="#security-isaachinman" title="Security">🛡️</a> <a href="#talk-isaachinman" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=isaachinman" title="Tests">⚠️</a> <a href="#tool-isaachinman" title="Tools">🔧</a> <a href="#translation-isaachinman" title="Translation">🌍</a> <a href="#tutorial-isaachinman" title="Tutorials">✅</a> <a href="#userTesting-isaachinman" title="User Testing">📓</a> <a href="#video-isaachinman" title="Videos">📹</a></td>
379
+ </tr>
380
+ <tr>
381
+ <td align="center" valign="top" width="14.28%"><a href="https://locize.com/"><img src="https://avatars.githubusercontent.com/u/1086194?v=4?s=100" width="100px;" alt="Adriano Raiano"/><br /><sub><b>Adriano Raiano</b></sub></a><br /><a href="#a11y-adrai" title="Accessibility">️️️️♿️</a> <a href="#question-adrai" title="Answering Questions">💬</a> <a href="#audio-adrai" title="Audio">🔊</a> <a href="#blog-adrai" title="Blogposts">📝</a> <a href="https://github.com/i18next/next-i18next/issues?q=author%3Aadrai" title="Bug reports">🐛</a> <a href="#business-adrai" title="Business development">💼</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Code">💻</a> <a href="#content-adrai" title="Content">🖋</a> <a href="#data-adrai" title="Data">🔣</a> <a href="#design-adrai" title="Design">🎨</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Documentation">📖</a> <a href="#eventOrganizing-adrai" title="Event Organizing">📋</a> <a href="#example-adrai" title="Examples">💡</a> <a href="#financial-adrai" title="Financial">💵</a> <a href="#fundingFinding-adrai" title="Funding Finding">🔍</a> <a href="#ideas-adrai" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-adrai" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-adrai" title="Maintenance">🚧</a> <a href="#mentoring-adrai" title="Mentoring">🧑‍🏫</a> <a href="#platform-adrai" title="Packaging/porting to new platform">📦</a> <a href="#plugin-adrai" title="Plugin/utility libraries">🔌</a> <a href="#projectManagement-adrai" title="Project Management">📆</a> <a href="#research-adrai" title="Research">🔬</a> <a href="https://github.com/i18next/next-i18next/pulls?q=is%3Apr+reviewed-by%3Aadrai" title="Reviewed Pull Requests">👀</a> <a href="#security-adrai" title="Security">🛡️</a> <a href="#talk-adrai" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=adrai" title="Tests">⚠️</a> <a href="#tool-adrai" title="Tools">🔧</a> <a href="#translation-adrai" title="Translation">🌍</a> <a href="#tutorial-adrai" title="Tutorials">✅</a> <a href="#userTesting-adrai" title="User Testing">📓</a> <a href="#video-adrai" title="Videos">📹</a></td>
382
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/felixmosh"><img src="https://avatars.githubusercontent.com/u/9304194?v=4?s=100" width="100px;" alt="Felix Mosheev"/><br /><sub><b>Felix Mosheev</b></sub></a><br /><a href="#question-felixmosh" title="Answering Questions">💬</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Code">💻</a> <a href="#talk-felixmosh" title="Talks">📢</a> <a href="https://github.com/i18next/next-i18next/commits?author=felixmosh" title="Tests">⚠️</a></td>
383
+ <td align="center" valign="top" width="14.28%"><a href="https://soluble.io/pro"><img src="https://avatars.githubusercontent.com/u/259798?v=4?s=100" width="100px;" alt="Sébastien Vanvelthem"/><br /><sub><b>Sébastien Vanvelthem</b></sub></a><br /><a href="https://github.com/i18next/next-i18next/commits?author=belgattitude" title="Code">💻</a> <a href="https://github.com/i18next/next-i18next/commits?author=belgattitude" title="Documentation">📖</a> <a href="#example-belgattitude" title="Examples">💡</a> <a href="#maintenance-belgattitude" title="Maintenance">🚧</a> <a href="#userTesting-belgattitude" title="User Testing">📓</a></td>
384
+ </tr>
385
+ </tbody>
379
386
  </table>
380
387
 
381
388
  <!-- markdownlint-restore -->
382
389
  <!-- prettier-ignore-end -->
390
+
383
391
  <!-- ALL-CONTRIBUTORS-LIST:END -->
384
392
 
385
393
  This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
@@ -1,37 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.object.keys.js");
4
-
5
4
  require("core-js/modules/es.symbol.js");
6
-
7
5
  require("core-js/modules/es.array.filter.js");
8
-
9
6
  require("core-js/modules/es.object.to-string.js");
10
-
11
7
  require("core-js/modules/es.object.get-own-property-descriptor.js");
12
-
13
8
  require("core-js/modules/es.array.for-each.js");
14
-
15
9
  require("core-js/modules/web.dom-collections.for-each.js");
16
-
17
10
  require("core-js/modules/es.object.get-own-property-descriptors.js");
18
-
19
11
  require("core-js/modules/es.object.define-properties.js");
20
-
21
12
  require("core-js/modules/es.object.define-property.js");
22
-
23
13
  require("core-js/modules/es.array.iterator.js");
24
-
25
14
  require("core-js/modules/es.string.iterator.js");
26
-
27
15
  require("core-js/modules/es.weak-map.js");
28
-
29
16
  require("core-js/modules/web.dom-collections.iterator.js");
30
-
31
17
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
32
-
33
18
  var _typeof = require("@babel/runtime/helpers/typeof");
34
-
35
19
  Object.defineProperty(exports, "__esModule", {
36
20
  value: true
37
21
  });
@@ -54,73 +38,47 @@ Object.defineProperty(exports, "withTranslation", {
54
38
  return _reactI18next.withTranslation;
55
39
  }
56
40
  });
57
-
58
41
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
59
-
60
42
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
61
-
62
43
  var _react = _interopRequireWildcard(require("react"));
63
-
64
44
  var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
65
-
66
45
  var _reactI18next = require("react-i18next");
67
-
68
46
  var _createConfig = require("./config/createConfig");
69
-
70
47
  var _createClient = _interopRequireDefault(require("./createClient"));
71
-
72
48
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
73
-
74
49
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
75
-
76
50
  var __jsx = _react["default"].createElement;
77
-
78
51
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
79
-
80
52
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
81
-
82
53
  var globalI18n = null;
83
54
  exports.globalI18n = globalI18n;
84
-
85
55
  var appWithTranslation = function appWithTranslation(WrappedComponent) {
86
56
  var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
87
-
88
57
  var AppWithTranslation = function AppWithTranslation(props) {
89
58
  var _nextI18Next$initialL, _props$router;
90
-
91
- var _ref = props.pageProps,
92
- _nextI18Next = _ref._nextI18Next;
59
+ var _nextI18Next = props.pageProps._nextI18Next;
93
60
  var locale = (_nextI18Next$initialL = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.initialLocale) !== null && _nextI18Next$initialL !== void 0 ? _nextI18Next$initialL : props === null || props === void 0 ? void 0 : (_props$router = props.router) === null || _props$router === void 0 ? void 0 : _props$router.locale;
94
- var ns = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.ns; // Memoize the instance and only re-initialize when either:
61
+ var ns = _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.ns;
62
+
63
+ // Memoize the instance and only re-initialize when either:
95
64
  // 1. The route changes (non-shallowly)
96
65
  // 2. Router locale changes
97
66
  // 3. UserConfig override changes
98
-
99
67
  var i18n = (0, _react.useMemo)(function () {
100
- var _userConfig, _userConfig2, _userConfig2$i18n;
101
-
68
+ var _userConfig$i18n;
102
69
  if (!_nextI18Next && !configOverride) return null;
103
70
  var userConfig = configOverride !== null && configOverride !== void 0 ? configOverride : _nextI18Next === null || _nextI18Next === void 0 ? void 0 : _nextI18Next.userConfig;
104
-
105
- if (!userConfig && configOverride === null) {
71
+ if (!userConfig) {
106
72
  throw new Error('appWithTranslation was called without a next-i18next config');
107
73
  }
108
-
109
- if (configOverride !== null) {
110
- userConfig = configOverride;
111
- }
112
-
113
- if (!((_userConfig = userConfig) !== null && _userConfig !== void 0 && _userConfig.i18n)) {
74
+ if (!(userConfig !== null && userConfig !== void 0 && userConfig.i18n)) {
114
75
  throw new Error('appWithTranslation was called without config.i18n');
115
76
  }
116
-
117
- if (!((_userConfig2 = userConfig) !== null && _userConfig2 !== void 0 && (_userConfig2$i18n = _userConfig2.i18n) !== null && _userConfig2$i18n !== void 0 && _userConfig2$i18n.defaultLocale)) {
77
+ if (!(userConfig !== null && userConfig !== void 0 && (_userConfig$i18n = userConfig.i18n) !== null && _userConfig$i18n !== void 0 && _userConfig$i18n.defaultLocale)) {
118
78
  throw new Error('config.i18n does not include a defaultLocale property');
119
79
  }
120
-
121
- var _ref2 = _nextI18Next || {},
122
- initialI18nStore = _ref2.initialI18nStore;
123
-
80
+ var _ref = _nextI18Next || {},
81
+ initialI18nStore = _ref.initialI18nStore;
124
82
  var resources = configOverride !== null && configOverride !== void 0 && configOverride.resources ? configOverride.resources : initialI18nStore;
125
83
  if (!locale) locale = userConfig.i18n.defaultLocale;
126
84
  var instance = (0, _createClient["default"])(_objectSpread(_objectSpread({}, (0, _createConfig.createConfig)(_objectSpread(_objectSpread({}, userConfig), {}, {
@@ -139,8 +97,6 @@ var appWithTranslation = function appWithTranslation(WrappedComponent) {
139
97
  key: locale
140
98
  }, props));
141
99
  };
142
-
143
100
  return (0, _hoistNonReactStatics["default"])(AppWithTranslation, WrappedComponent);
144
101
  };
145
-
146
102
  exports.appWithTranslation = appWithTranslation;