next-i18next 8.10.0 → 9.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.
@@ -86,17 +86,20 @@ var appWithTranslation = function appWithTranslation(WrappedComponent) {
86
86
  var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
87
87
 
88
88
  var AppWithTranslation = function AppWithTranslation(props) {
89
- var _nextI18Next = props.pageProps._nextI18Next;
90
- var locale = props.router.locale; // Memoize the instance and only re-initialize when either:
89
+ var _ref = props.pageProps,
90
+ _nextI18Next = _ref._nextI18Next;
91
+ var locale = null; // Memoize the instance and only re-initialize when either:
91
92
  // 1. The route changes (non-shallowly)
92
93
  // 2. Router locale changes
93
94
 
94
95
  var i18n = (0, _react.useMemo)(function () {
95
96
  var _userConfig;
96
97
 
97
- if (!locale || !_nextI18Next) return null;
98
+ if (!_nextI18Next) return null;
98
99
  var userConfig = _nextI18Next.userConfig;
99
- var initialI18nStore = _nextI18Next.initialI18nStore;
100
+ var initialI18nStore = _nextI18Next.initialI18nStore,
101
+ initialLocale = _nextI18Next.initialLocale;
102
+ locale = initialLocale;
100
103
 
101
104
  if (userConfig === null && configOverride === null) {
102
105
  throw new Error('appWithTranslation was called without a next-i18next config');
@@ -243,6 +243,7 @@ var serverSideTranslations = /*#__PURE__*/function () {
243
243
  return _context.abrupt("return", {
244
244
  _nextI18Next: {
245
245
  initialI18nStore: initialI18nStore,
246
+ initialLocale: initialLocale,
246
247
  userConfig: config.serializeConfig ? userConfig : null
247
248
  }
248
249
  });
@@ -12,22 +12,22 @@ export const appWithTranslation = (WrappedComponent, configOverride = null) => {
12
12
  const {
13
13
  _nextI18Next
14
14
  } = props.pageProps;
15
- const {
16
- locale
17
- } = props.router; // Memoize the instance and only re-initialize when either:
15
+ let locale = null; // Memoize the instance and only re-initialize when either:
18
16
  // 1. The route changes (non-shallowly)
19
17
  // 2. Router locale changes
20
18
 
21
19
  const i18n = useMemo(() => {
22
20
  var _userConfig;
23
21
 
24
- if (!locale || !_nextI18Next) return null;
22
+ if (!_nextI18Next) return null;
25
23
  let {
26
24
  userConfig
27
25
  } = _nextI18Next;
28
26
  const {
29
- initialI18nStore
27
+ initialI18nStore,
28
+ initialLocale
30
29
  } = _nextI18Next;
30
+ locale = initialLocale;
31
31
 
32
32
  if (userConfig === null && configOverride === null) {
33
33
  throw new Error('appWithTranslation was called without a next-i18next config');
@@ -89,6 +89,7 @@ export const serverSideTranslations = async (initialLocale, namespacesRequired =
89
89
  return {
90
90
  _nextI18Next: {
91
91
  initialI18nStore,
92
+ initialLocale,
92
93
  userConfig: config.serializeConfig ? userConfig : null
93
94
  }
94
95
  };
@@ -17,17 +17,20 @@ export var appWithTranslation = function appWithTranslation(WrappedComponent) {
17
17
  var configOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
18
18
 
19
19
  var AppWithTranslation = function AppWithTranslation(props) {
20
- var _nextI18Next = props.pageProps._nextI18Next;
21
- var locale = props.router.locale; // Memoize the instance and only re-initialize when either:
20
+ var _ref = props.pageProps,
21
+ _nextI18Next = _ref._nextI18Next;
22
+ var locale = null; // Memoize the instance and only re-initialize when either:
22
23
  // 1. The route changes (non-shallowly)
23
24
  // 2. Router locale changes
24
25
 
25
26
  var i18n = useMemo(function () {
26
27
  var _userConfig;
27
28
 
28
- if (!locale || !_nextI18Next) return null;
29
+ if (!_nextI18Next) return null;
29
30
  var userConfig = _nextI18Next.userConfig;
30
- var initialI18nStore = _nextI18Next.initialI18nStore;
31
+ var initialI18nStore = _nextI18Next.initialI18nStore,
32
+ initialLocale = _nextI18Next.initialLocale;
33
+ locale = initialLocale;
31
34
 
32
35
  if (userConfig === null && configOverride === null) {
33
36
  throw new Error('appWithTranslation was called without a next-i18next config');
@@ -161,6 +161,7 @@ export var serverSideTranslations = /*#__PURE__*/function () {
161
161
  return _context.abrupt("return", {
162
162
  _nextI18Next: {
163
163
  initialI18nStore: initialI18nStore,
164
+ initialLocale: initialLocale,
164
165
  userConfig: config.serializeConfig ? userConfig : null
165
166
  }
166
167
  });
@@ -8,4 +8,4 @@ declare type AppProps = NextJsAppProps & {
8
8
  pageProps: SSRConfig;
9
9
  };
10
10
  export declare let globalI18n: I18NextClient | null;
11
- export declare const appWithTranslation: (WrappedComponent: React.ComponentType<AppProps> | React.ElementType<AppProps>, configOverride?: UserConfig | null) => ((props: AppProps) => JSX.Element) & hoistNonReactStatics.NonReactStatics<React.ComponentClass<AppProps, any> | React.FunctionComponent<AppProps>, {}>;
11
+ export declare const appWithTranslation: <Props extends AppProps = AppProps>(WrappedComponent: React.ComponentType<Props>, configOverride?: UserConfig | null) => ((props: Props) => JSX.Element) & hoistNonReactStatics.NonReactStatics<React.ComponentType<Props>, {}>;
@@ -36,6 +36,7 @@ export declare type CreateClientReturn = {
36
36
  export declare type SSRConfig = {
37
37
  _nextI18Next: {
38
38
  initialI18nStore: any;
39
+ initialLocale: string;
39
40
  userConfig: UserConfig | null;
40
41
  };
41
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-i18next",
3
- "version": "8.10.0",
3
+ "version": "9.0.0",
4
4
  "repository": "git@github.com:isaachinman/next-i18next.git",
5
5
  "author": "Isaac Hinman <isaac@isaachinman.com>",
6
6
  "funding": {
@@ -12,7 +12,7 @@
12
12
  "types": "dist/types/types.d.ts",
13
13
  "license": "MIT",
14
14
  "engines": {
15
- "node": ">=10"
15
+ "node": ">=12"
16
16
  },
17
17
  "description": "The easiest way to translate your NextJs apps.",
18
18
  "keywords": [
@@ -107,7 +107,7 @@
107
107
  "@types/hoist-non-react-statics": "^3.3.1",
108
108
  "core-js": "^3",
109
109
  "hoist-non-react-statics": "^3.2.0",
110
- "i18next": "^20.1.0",
110
+ "i18next": "^21.4.1",
111
111
  "i18next-fs-backend": "^1.0.7",
112
112
  "react-i18next": "^11.8.13"
113
113
  },