react-i18next 11.18.6 → 12.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 12.0.0
2
+
3
+ - Update t function types to rely on types coming from i18next [1501](https://github.com/i18next/react-i18next/pull/1501)
4
+
1
5
  ### 11.18.6
2
6
 
3
7
  - types: nsMode [1554](https://github.com/i18next/react-i18next/issues/1554)
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { Namespace, DefaultNamespace, TFuncKey, Trans } from '.';
3
- import { i18n } from 'i18next';
2
+ import { Trans } from './';
3
+ import { Namespace, DefaultNamespace, TFuncKey, i18n } from 'i18next';
4
4
 
5
5
  export { Trans };
6
6
 
package/index.d.ts CHANGED
@@ -1,11 +1,18 @@
1
- import i18next, { ReactOptions, i18n, ThirdPartyModule, WithT, TFunction, Resource } from 'i18next';
1
+ import i18next, {
2
+ ReactOptions,
3
+ i18n,
4
+ ThirdPartyModule,
5
+ Resource,
6
+ TFuncKey,
7
+ Namespace,
8
+ TypeOptions,
9
+ TFunction,
10
+ KeyPrefix,
11
+ } from 'i18next';
2
12
  import * as React from 'react';
3
13
 
4
- type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
5
14
  type Subtract<T extends K, K> = Omit<T, keyof K>;
6
15
 
7
- export type Namespace = string | string[];
8
-
9
16
  export function setDefaults(options: ReactOptions): void;
10
17
  export function getDefaults(): ReactOptions;
11
18
  export function setI18n(instance: i18n): void;
@@ -20,7 +27,7 @@ export function getInitialProps(): {
20
27
  };
21
28
 
22
29
  export interface ReportNamespaces {
23
- addUsedNamespaces(namespaces: Namespace[]): void;
30
+ addUsedNamespaces(namespaces: Namespace): void;
24
31
  getUsedNamespaces(): string[];
25
32
  }
26
33
 
@@ -30,44 +37,76 @@ declare module 'i18next' {
30
37
  }
31
38
  }
32
39
 
33
- export interface TransProps<E extends Element = HTMLDivElement>
34
- extends React.HTMLProps<E>,
35
- Partial<WithT> {
36
- children?: React.ReactNode;
40
+ type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true
41
+ ? Record<string, unknown>
42
+ : never;
43
+ type ReactI18NextChild = React.ReactNode | ObjectOrNever;
44
+
45
+ declare module 'react' {
46
+ interface HTMLAttributes<T> {
47
+ children?: ReactI18NextChild | Iterable<ReactI18NextChild>;
48
+ }
49
+ }
50
+
51
+ type DefaultNamespace = TypeOptions['defaultNS'];
52
+
53
+ type TransChild = React.ReactNode | Record<string, unknown>;
54
+ export type TransProps<
55
+ K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
56
+ N extends Namespace = DefaultNamespace,
57
+ TKPrefix = undefined,
58
+ E = React.HTMLProps<HTMLDivElement>
59
+ > = E & {
60
+ children?: TransChild | TransChild[];
37
61
  components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement };
38
62
  count?: number;
39
63
  context?: string;
40
64
  defaults?: string;
41
65
  i18n?: i18n;
42
- i18nKey?: string;
43
- ns?: Namespace;
66
+ i18nKey?: K | K[];
67
+ ns?: N;
44
68
  parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null
45
69
  tOptions?: {};
46
70
  values?: {};
47
71
  shouldUnescape?: boolean;
48
- t?: TFunction;
49
- }
50
- export function Trans<E extends Element = HTMLDivElement>(props: TransProps<E>): React.ReactElement;
72
+ t?: TFunction<N, TKPrefix>;
73
+ };
74
+
75
+ export function Trans<
76
+ K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
77
+ N extends Namespace = DefaultNamespace,
78
+ TKPrefix extends KeyPrefix<N> = undefined,
79
+ E = React.HTMLProps<HTMLDivElement>
80
+ >(props: TransProps<K, N, TKPrefix, E>): React.ReactElement;
51
81
 
52
82
  export function useSSR(initialI18nStore: Resource, initialLanguage: string): void;
53
83
 
54
- export interface UseTranslationOptions {
84
+ export interface UseTranslationOptions<TKPrefix = undefined> {
55
85
  i18n?: i18n;
56
86
  useSuspense?: boolean;
57
- keyPrefix?: string;
87
+ keyPrefix?: TKPrefix;
58
88
  bindI18n?: string | false;
59
89
  nsMode?: 'fallback' | 'default';
60
90
  // other of these options might also work: https://github.com/i18next/i18next/blob/master/index.d.ts#L127
61
91
  }
62
- export type UseTranslationResponse = [TFunction, i18n, boolean] & {
63
- t: TFunction;
92
+
93
+ export type UseTranslationResponse<N extends Namespace, TKPrefix = undefined> = [
94
+ TFunction<N, TKPrefix>,
95
+ i18n,
96
+ boolean,
97
+ ] & {
98
+ t: TFunction<N, TKPrefix>;
64
99
  i18n: i18n;
65
100
  ready: boolean;
66
101
  };
67
- export function useTranslation(
68
- ns?: Namespace,
69
- options?: UseTranslationOptions,
70
- ): UseTranslationResponse;
102
+
103
+ export function useTranslation<
104
+ N extends Namespace = DefaultNamespace,
105
+ TKPrefix extends KeyPrefix<N> = undefined
106
+ >(
107
+ ns?: N | Readonly<N>,
108
+ options?: UseTranslationOptions<TKPrefix>,
109
+ ): UseTranslationResponse<N, TKPrefix>;
71
110
 
72
111
  // Need to see usage to improve this
73
112
  export function withSSR(): <Props>(
@@ -84,7 +123,11 @@ export function withSSR(): <Props>(
84
123
  getInitialProps: (ctx: unknown) => Promise<any>;
85
124
  };
86
125
 
87
- export interface WithTranslation extends WithT {
126
+ export interface WithTranslation<
127
+ N extends Namespace = DefaultNamespace,
128
+ TKPrefix extends KeyPrefix<N> = undefined
129
+ > {
130
+ t: TFunction<N, TKPrefix>;
88
131
  i18n: i18n;
89
132
  tReady: boolean;
90
133
  }
@@ -94,20 +137,24 @@ export interface WithTranslationProps {
94
137
  useSuspense?: boolean;
95
138
  }
96
139
 
97
- export function withTranslation(
98
- ns?: Namespace,
140
+ export function withTranslation<
141
+ N extends Namespace = DefaultNamespace,
142
+ TKPrefix extends KeyPrefix<N> = undefined
143
+ >(
144
+ ns?: N,
99
145
  options?: {
100
146
  withRef?: boolean;
147
+ keyPrefix?: TKPrefix;
101
148
  },
102
149
  ): <
103
- C extends React.ComponentType<React.ComponentProps<C> & WithTranslationProps>,
150
+ C extends React.ComponentType<React.ComponentProps<any> & WithTranslationProps>,
104
151
  ResolvedProps = JSX.LibraryManagedAttributes<
105
152
  C,
106
153
  Subtract<React.ComponentProps<C>, WithTranslationProps>
107
154
  >
108
155
  >(
109
156
  component: C,
110
- ) => React.ComponentType<Omit<ResolvedProps, keyof WithTranslation> & WithTranslationProps>;
157
+ ) => React.ComponentType<Omit<ResolvedProps, keyof WithTranslation<N>> & WithTranslationProps>;
111
158
 
112
159
  export interface I18nextProviderProps {
113
160
  children?: React.ReactNode;
@@ -118,19 +165,26 @@ export interface I18nextProviderProps {
118
165
  export const I18nextProvider: React.FunctionComponent<I18nextProviderProps>;
119
166
  export const I18nContext: React.Context<{ i18n: i18n }>;
120
167
 
121
- export interface TranslationProps {
168
+ export interface TranslationProps<
169
+ N extends Namespace = DefaultNamespace,
170
+ TKPrefix extends KeyPrefix<N> = undefined
171
+ > {
122
172
  children: (
123
- t: TFunction,
173
+ t: TFunction<N, TKPrefix>,
124
174
  options: {
125
175
  i18n: i18n;
126
176
  lng: string;
127
177
  },
128
178
  ready: boolean,
129
179
  ) => React.ReactNode;
130
- ns?: Namespace;
180
+ ns?: N;
131
181
  i18n?: i18n;
132
182
  useSuspense?: boolean;
183
+ keyPrefix?: TKPrefix;
133
184
  nsMode?: 'fallback' | 'default';
134
185
  }
135
186
 
136
- export function Translation(props: TranslationProps): any;
187
+ export function Translation<
188
+ N extends Namespace = DefaultNamespace,
189
+ TKPrefix extends KeyPrefix<N> = undefined
190
+ >(props: TranslationProps<N, TKPrefix>): any;
package/package.json CHANGED
@@ -1,16 +1,9 @@
1
1
  {
2
2
  "name": "react-i18next",
3
- "version": "11.18.6",
3
+ "version": "12.0.0",
4
4
  "description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "types": "./index.d.ts",
7
- "typesVersions": {
8
- ">=4.1": {
9
- "*": [
10
- "ts4.1/*"
11
- ]
12
- }
13
- },
14
7
  "jsnext:main": "dist/es/index.js",
15
8
  "module": "dist/es/index.js",
16
9
  "keywords": [
@@ -67,7 +60,7 @@
67
60
  "eslint-plugin-react": "^7.16.0",
68
61
  "eslint-plugin-testing-library": "^3.10.1",
69
62
  "husky": "^3.0.3",
70
- "i18next": "^21.0.0",
63
+ "i18next": "^22.0.1",
71
64
  "jest": "^24.8.0",
72
65
  "jest-cli": "^24.8.4",
73
66
  "lint-staged": "^8.1.3",
@@ -28,6 +28,7 @@ export function withTranslation(ns, options = {}) {
28
28
  I18nextWithTranslation.WrappedComponent = WrappedComponent;
29
29
 
30
30
  const forwardRef = (props, ref) =>
31
+ // eslint-disable-next-line prefer-object-spread
31
32
  createElement(I18nextWithTranslation, Object.assign({}, props, { forwardedRef: ref }));
32
33
 
33
34
  return options.withRef ? forwardRefReact(forwardRef) : I18nextWithTranslation;
package/ts4.1/index.d.ts DELETED
@@ -1,398 +0,0 @@
1
- import i18next, {
2
- ReactOptions,
3
- i18n,
4
- ThirdPartyModule,
5
- Resource,
6
- TOptions,
7
- StringMap,
8
- TFunctionResult,
9
- } from 'i18next';
10
- import * as React from 'react';
11
-
12
- type Subtract<T extends K, K> = Omit<T, keyof K>;
13
-
14
- /**
15
- * Due to a limitation/bug on typescript 4.1 (https://github.com/microsoft/TypeScript/issues/41406), we added
16
- * "extends infer A ? A : never" in a few places to suppress the error "Type instantiation is excessively deep and possibly infinite."
17
- * on cases where users have more than 22 namespaces. Once the issue is fixed, we can remove all instances of the workaround used.
18
- *
19
- * Reference of the bug reported: https://github.com/i18next/react-i18next/issues/1222
20
- */
21
-
22
- /**
23
- * This interface can be augmented by users to add types to `react-i18next` default resources.
24
- *
25
- * @deprecated use the `resources` key of `CustomTypeOptions` instead
26
- */
27
- export interface Resources {}
28
- /**
29
- * This interface can be augmented by users to add types to `react-i18next`. It accepts a `defaultNS`, `resources`, `returnNull` and `returnEmptyString` properties.
30
- *
31
- * Usage:
32
- * ```ts
33
- * // react-i18next.d.ts
34
- * import 'react-i18next';
35
- * declare module 'react-i18next' {
36
- * interface CustomTypeOptions {
37
- * defaultNS: 'custom';
38
- * returnNull: false;
39
- * returnEmptyString: false;
40
- * nsSeparator: ':';
41
- * keySeparator: '.';
42
- * jsonFormat: 'v4';
43
- * allowObjectInHTMLChildren: false;
44
- * resources: {
45
- * custom: {
46
- * foo: 'foo';
47
- * };
48
- * };
49
- * }
50
- * }
51
- * ```
52
- */
53
- export interface CustomTypeOptions {}
54
-
55
- type MergeBy<T, K> = Omit<T, keyof K> & K;
56
-
57
- type TypeOptions = MergeBy<
58
- {
59
- returnNull: true;
60
- returnEmptyString: true;
61
- keySeparator: '.';
62
- nsSeparator: ':';
63
- defaultNS: 'translation';
64
- jsonFormat: 'v4';
65
- resources: Resources;
66
- allowObjectInHTMLChildren: false;
67
- },
68
- CustomTypeOptions
69
- >;
70
-
71
- type DefaultResources = TypeOptions['resources'];
72
- type DefaultNamespace<T = TypeOptions['defaultNS']> = T extends Fallback<string> ? T : string;
73
-
74
- type Fallback<F, T = keyof DefaultResources> = [T] extends [never] ? F : T;
75
-
76
- export type Namespace<F = Fallback<string>> = F | F[];
77
-
78
- export function setDefaults(options: ReactOptions): void;
79
- export function getDefaults(): ReactOptions;
80
- export function setI18n(instance: i18n): void;
81
- export function getI18n(): i18n;
82
- export const initReactI18next: ThirdPartyModule;
83
- export function composeInitialProps(ForComponent: any): (ctx: unknown) => Promise<any>;
84
- export function getInitialProps(): {
85
- initialI18nStore: {
86
- [ns: string]: {};
87
- };
88
- initialLanguage: string;
89
- };
90
-
91
- export interface ReportNamespaces {
92
- addUsedNamespaces(namespaces: Namespace[]): void;
93
- getUsedNamespaces(): string[];
94
- }
95
-
96
- declare module 'i18next' {
97
- interface i18n {
98
- reportNamespaces: ReportNamespaces;
99
- }
100
- }
101
-
102
- type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true
103
- ? Record<string, unknown>
104
- : never;
105
-
106
- type ReactI18NextChild = React.ReactNode | ObjectOrNever;
107
-
108
- declare module 'react' {
109
- interface HTMLAttributes<T> {
110
- children?: ReactI18NextChild | Iterable<ReactI18NextChild>;
111
- }
112
- }
113
-
114
- type PluralSuffix = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
115
-
116
- type WithOrWithoutPlural<K> = TypeOptions['jsonFormat'] extends 'v4'
117
- ? K extends `${infer B}_${PluralSuffix}`
118
- ? B | K
119
- : K
120
- : K;
121
-
122
- // Normalize single namespace
123
- export type KeysWithSeparator<K1, K2, S extends string = TypeOptions['keySeparator']> = `${K1 &
124
- string}${S}${K2 & string}`;
125
- type KeysWithSeparator2<K1, K2> = KeysWithSeparator<K1, Exclude<K2, keyof any[]>>;
126
- type Normalize2<T, K = keyof T> = K extends keyof T
127
- ? T[K] extends Record<string, any>
128
- ? T[K] extends readonly any[]
129
- ?
130
- | KeysWithSeparator2<K, WithOrWithoutPlural<keyof T[K]>>
131
- | KeysWithSeparator2<K, Normalize2<T[K]>>
132
- :
133
- | KeysWithSeparator<K, WithOrWithoutPlural<keyof T[K]>>
134
- | KeysWithSeparator<K, Normalize2<T[K]>>
135
- : never
136
- : never;
137
- type Normalize<T> = WithOrWithoutPlural<keyof T> | Normalize2<T>;
138
-
139
- // Normalize multiple namespaces
140
- type KeyWithNSSeparator<N, K, S extends string = TypeOptions['nsSeparator']> = `${N &
141
- string}${S}${K & string}`;
142
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void
143
- ? I
144
- : never;
145
- type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R
146
- ? R
147
- : never;
148
- type NormalizeMulti<T, U extends keyof T, L = LastOf<U>> = L extends U
149
- ? KeyWithNSSeparator<L, Normalize<T[L]>> | NormalizeMulti<T, Exclude<U, L>>
150
- : never;
151
-
152
- interface CustomTypeParameters {
153
- returnNull?: boolean;
154
- returnEmptyString?: boolean;
155
- }
156
-
157
- type TypeOptionsFallback<TranslationValue, Option, MatchingValue> = Option extends false
158
- ? TranslationValue extends MatchingValue
159
- ? string
160
- : TranslationValue
161
- : TranslationValue;
162
-
163
- /**
164
- * Checks if user has enabled `returnEmptyString` and `returnNull` options to retrieve correct values.
165
- */
166
- export type NormalizeByTypeOptions<
167
- TranslationValue,
168
- Options extends CustomTypeParameters = TypeOptions,
169
- R = TypeOptionsFallback<TranslationValue, Options['returnEmptyString'], ''>
170
- > = TypeOptionsFallback<R, Options['returnNull'], null>;
171
-
172
- type StringIfPlural<T> = TypeOptions['jsonFormat'] extends 'v4'
173
- ? T extends `${string}_${PluralSuffix}`
174
- ? string
175
- : never
176
- : never;
177
-
178
- type NormalizeReturn<
179
- T,
180
- V,
181
- S extends string | false = TypeOptions['keySeparator']
182
- > = V extends keyof T
183
- ? NormalizeByTypeOptions<T[V]>
184
- : S extends false
185
- ? V
186
- : V extends `${infer K}${S}${infer R}`
187
- ? K extends keyof T
188
- ? NormalizeReturn<T[K], R>
189
- : never
190
- : StringIfPlural<keyof T>;
191
-
192
- type NormalizeMultiReturn<T, V> = V extends `${infer N}:${infer R}`
193
- ? N extends keyof T
194
- ? NormalizeReturn<T[N], R>
195
- : never
196
- : never;
197
-
198
- type NormalizeWithKeyPrefix<
199
- T,
200
- K,
201
- S extends string = TypeOptions['keySeparator']
202
- > = K extends `${infer K1}${S}${infer K2}`
203
- ? K1 extends keyof T
204
- ? NormalizeWithKeyPrefix<T[K1], K2>
205
- : never
206
- : K extends keyof T
207
- ? T[K] extends string
208
- ? never
209
- : Normalize<T[K]>
210
- : never;
211
-
212
- type KeyPrefix<N extends Namespace> =
213
- | (N extends keyof DefaultResources ? Normalize<DefaultResources[N]> : string)
214
- | undefined;
215
-
216
- export type TFuncKey<
217
- N extends Namespace = DefaultNamespace,
218
- TKPrefix = undefined,
219
- T = DefaultResources
220
- > = N extends (keyof T)[] | Readonly<(keyof T)[]>
221
- ? NormalizeMulti<T, N[number]>
222
- : N extends keyof T
223
- ? TKPrefix extends undefined
224
- ? Normalize<T[N]>
225
- : NormalizeWithKeyPrefix<T[N], TKPrefix>
226
- : string;
227
-
228
- export type TFuncReturn<
229
- N,
230
- TKeys,
231
- TDefaultResult,
232
- TKPrefix = undefined,
233
- T = DefaultResources
234
- > = N extends (keyof T)[]
235
- ? NormalizeMultiReturn<T, TKeys>
236
- : N extends keyof T
237
- ? TKPrefix extends undefined
238
- ? NormalizeReturn<T[N], TKeys>
239
- : NormalizeReturn<T[N], KeysWithSeparator<TKPrefix, TKeys>>
240
- : Fallback<TDefaultResult>;
241
-
242
- export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = undefined> {
243
- <
244
- TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
245
- TDefaultResult extends TFunctionResult | React.ReactNode = string,
246
- TInterpolationMap extends object = StringMap
247
- >(
248
- key: TKeys | TKeys[],
249
- options?: TOptions<TInterpolationMap> | string,
250
- ): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
251
- <
252
- TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,
253
- TDefaultResult extends TFunctionResult | React.ReactNode = string,
254
- TInterpolationMap extends object = StringMap
255
- >(
256
- key: TKeys | TKeys[],
257
- defaultValue?: string,
258
- options?: TOptions<TInterpolationMap> | string,
259
- ): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
260
- }
261
-
262
- type TransChild = React.ReactNode | Record<string, unknown>;
263
- export type TransProps<
264
- K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
265
- N extends Namespace = DefaultNamespace,
266
- TKPrefix = undefined,
267
- E = React.HTMLProps<HTMLDivElement>
268
- > = E & {
269
- children?: TransChild | TransChild[];
270
- components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement };
271
- count?: number;
272
- context?: string;
273
- defaults?: string;
274
- i18n?: i18n;
275
- i18nKey?: K | K[];
276
- ns?: N;
277
- parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null
278
- tOptions?: {};
279
- values?: {};
280
- shouldUnescape?: boolean;
281
- t?: TFunction<N, TKPrefix>;
282
- };
283
-
284
- export function Trans<
285
- K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
286
- N extends Namespace = DefaultNamespace,
287
- TKPrefix extends KeyPrefix<N> = undefined,
288
- E = React.HTMLProps<HTMLDivElement>
289
- >(props: TransProps<K, N, TKPrefix, E>): React.ReactElement;
290
-
291
- export function useSSR(initialI18nStore: Resource, initialLanguage: string): void;
292
-
293
- export interface UseTranslationOptions<TKPrefix = undefined> {
294
- i18n?: i18n;
295
- useSuspense?: boolean;
296
- keyPrefix?: TKPrefix;
297
- bindI18n?: string | false;
298
- nsMode?: 'fallback' | 'default';
299
- }
300
-
301
- export type UseTranslationResponse<N extends Namespace, TKPrefix = undefined> = [
302
- TFunction<N, TKPrefix>,
303
- i18n,
304
- boolean,
305
- ] & {
306
- t: TFunction<N, TKPrefix>;
307
- i18n: i18n;
308
- ready: boolean;
309
- };
310
-
311
- export function useTranslation<
312
- N extends Namespace = DefaultNamespace,
313
- TKPrefix extends KeyPrefix<N> = undefined
314
- >(
315
- ns?: N | Readonly<N>,
316
- options?: UseTranslationOptions<TKPrefix>,
317
- ): UseTranslationResponse<N, TKPrefix>;
318
-
319
- // Need to see usage to improve this
320
- export function withSSR(): <Props>(
321
- WrappedComponent: React.ComponentType<Props>,
322
- ) => {
323
- ({
324
- initialI18nStore,
325
- initialLanguage,
326
- ...rest
327
- }: {
328
- initialI18nStore: Resource;
329
- initialLanguage: string;
330
- } & Props): React.FunctionComponentElement<Props>;
331
- getInitialProps: (ctx: unknown) => Promise<any>;
332
- };
333
-
334
- export interface WithTranslation<
335
- N extends Namespace = DefaultNamespace,
336
- TKPrefix extends KeyPrefix<N> = undefined
337
- > {
338
- t: TFunction<N, TKPrefix>;
339
- i18n: i18n;
340
- tReady: boolean;
341
- }
342
-
343
- export interface WithTranslationProps {
344
- i18n?: i18n;
345
- useSuspense?: boolean;
346
- }
347
-
348
- export function withTranslation<
349
- N extends Namespace = DefaultNamespace,
350
- TKPrefix extends KeyPrefix<N> = undefined
351
- >(
352
- ns?: N,
353
- options?: {
354
- withRef?: boolean;
355
- keyPrefix?: TKPrefix;
356
- },
357
- ): <
358
- C extends React.ComponentType<React.ComponentProps<any> & WithTranslationProps>,
359
- ResolvedProps = JSX.LibraryManagedAttributes<
360
- C,
361
- Subtract<React.ComponentProps<C>, WithTranslationProps>
362
- >
363
- >(
364
- component: C,
365
- ) => React.ComponentType<Omit<ResolvedProps, keyof WithTranslation<N>> & WithTranslationProps>;
366
-
367
- export interface I18nextProviderProps {
368
- children?: React.ReactNode;
369
- i18n: i18n;
370
- defaultNS?: string;
371
- }
372
-
373
- export const I18nextProvider: React.FunctionComponent<I18nextProviderProps>;
374
- export const I18nContext: React.Context<{ i18n: i18n }>;
375
-
376
- export interface TranslationProps<
377
- N extends Namespace = DefaultNamespace,
378
- TKPrefix extends KeyPrefix<N> = undefined
379
- > {
380
- children: (
381
- t: TFunction<N, TKPrefix>,
382
- options: {
383
- i18n: i18n;
384
- lng: string;
385
- },
386
- ready: boolean,
387
- ) => React.ReactNode;
388
- ns?: N;
389
- i18n?: i18n;
390
- useSuspense?: boolean;
391
- keyPrefix?: TKPrefix;
392
- nsMode?: 'fallback' | 'default';
393
- }
394
-
395
- export function Translation<
396
- N extends Namespace = DefaultNamespace,
397
- TKPrefix extends KeyPrefix<N> = undefined
398
- >(props: TranslationProps<N, TKPrefix>): any;