react-i18next 11.16.7 → 11.16.10
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 +12 -0
- package/README.md +6 -4
- package/package.json +1 -1
- package/ts4.1/index.d.ts +30 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
### 11.16.10
|
|
2
|
+
|
|
3
|
+
- types: translation component types [1509](https://github.com/i18next/react-i18next/pull/1509)
|
|
4
|
+
|
|
5
|
+
### 11.16.9
|
|
6
|
+
|
|
7
|
+
- types: fix missing generic type for HTMLAttributes [1499](https://github.com/i18next/react-i18next/pull/1499)
|
|
8
|
+
|
|
9
|
+
### 11.16.8
|
|
10
|
+
|
|
11
|
+
- types: fix Trans component to support react 18 types, by introducing allowObjectInHTMLChildren TS option [1492](https://github.com/i18next/react-i18next/pull/1492)
|
|
12
|
+
|
|
1
13
|
### 11.16.7
|
|
2
14
|
|
|
3
15
|
- types: Added objects explicitly to Trans children [1486](https://github.com/i18next/react-i18next/pull/1486)
|
package/README.md
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
[](https://circleci.com/gh/i18next/react-i18next)
|
|
4
4
|
[](https://codeclimate.com/github/i18next/react-i18next)
|
|
5
5
|
[](https://coveralls.io/github/i18next/react-i18next)
|
|
6
|
-
[![Quality][quality-badge]
|
|
6
|
+
[![Quality][quality-badge]][quality-url]
|
|
7
|
+
[![npm][npm-dl-badge]][npm-url]
|
|
7
8
|
|
|
8
9
|
[npm-icon]: https://nodei.co/npm/react-i18next.png?downloads=true
|
|
9
10
|
[npm-url]: https://npmjs.org/package/react-i18next
|
|
10
|
-
[quality-badge]:
|
|
11
|
-
[quality-url]:
|
|
11
|
+
[quality-badge]: https://npm.packagequality.com/shield/react-i18next.svg
|
|
12
|
+
[quality-url]: https://packagequality.com/#?package=react-i18next
|
|
13
|
+
[npm-dl-badge]: https://img.shields.io/npm/dw/react-i18next
|
|
12
14
|
|
|
13
15
|
### IMPORTANT:
|
|
14
16
|
|
|
@@ -75,7 +77,7 @@ Head over to the **interactive playground** at [codesandbox](https://codesandbox
|
|
|
75
77
|
### Why i18next?
|
|
76
78
|
|
|
77
79
|
- **Simplicity:** no need to change your webpack configuration or add additional babel transpilers, just use create-react-app and go.
|
|
78
|
-
- **Production ready** we know there are more needs for production than just doing i18n on the clientside, so we offer wider support on [serverside](https://www.i18next.com/supported-frameworks
|
|
80
|
+
- **Production ready** we know there are more needs for production than just doing i18n on the clientside, so we offer wider support on [serverside](https://www.i18next.com/overview/supported-frameworks) too (nodejs, php, ruby, .net, ...). **Learn once - translate everywhere**.
|
|
79
81
|
- **Beyond i18n** comes with [locize](https://locize.com) bridging the gap between developement and translations - covering the whole translation process.
|
|
80
82
|
|
|
81
83
|

|
package/package.json
CHANGED
package/ts4.1/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface Resources {}
|
|
|
40
40
|
* nsSeparator: ':';
|
|
41
41
|
* keySeparator: '.';
|
|
42
42
|
* jsonFormat: 'v4';
|
|
43
|
+
* allowObjectInHTMLChildren: false;
|
|
43
44
|
* resources: {
|
|
44
45
|
* custom: {
|
|
45
46
|
* foo: 'foo';
|
|
@@ -62,6 +63,7 @@ type TypeOptions = MergeBy<
|
|
|
62
63
|
defaultNS: 'translation';
|
|
63
64
|
jsonFormat: 'v4';
|
|
64
65
|
resources: Resources;
|
|
66
|
+
allowObjectInHTMLChildren: false;
|
|
65
67
|
},
|
|
66
68
|
CustomTypeOptions
|
|
67
69
|
>;
|
|
@@ -97,6 +99,15 @@ declare module 'i18next' {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true
|
|
103
|
+
? Record<string, unknown>
|
|
104
|
+
: never;
|
|
105
|
+
declare module 'react' {
|
|
106
|
+
interface HTMLAttributes<T> {
|
|
107
|
+
children?: ReactNode | ObjectOrNever;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
100
111
|
type PluralSuffix = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
|
|
101
112
|
|
|
102
113
|
type WithOrWithoutPlural<K> = TypeOptions['jsonFormat'] extends 'v4'
|
|
@@ -245,13 +256,14 @@ export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = un
|
|
|
245
256
|
): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
|
|
246
257
|
}
|
|
247
258
|
|
|
259
|
+
type TransChild = React.ReactNode | Record<string, unknown>;
|
|
248
260
|
export type TransProps<
|
|
249
261
|
K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
|
|
250
262
|
N extends Namespace = DefaultNamespace,
|
|
251
263
|
TKPrefix = undefined,
|
|
252
264
|
E = React.HTMLProps<HTMLDivElement>
|
|
253
265
|
> = E & {
|
|
254
|
-
children?:
|
|
266
|
+
children?: TransChild | TransChild[];
|
|
255
267
|
components?: readonly React.ReactNode[] | { readonly [tagName: string]: React.ReactNode };
|
|
256
268
|
count?: number;
|
|
257
269
|
context?: string;
|
|
@@ -314,8 +326,11 @@ export function withSSR(): <Props>(
|
|
|
314
326
|
getInitialProps: (ctx: unknown) => Promise<any>;
|
|
315
327
|
};
|
|
316
328
|
|
|
317
|
-
export interface WithTranslation<
|
|
318
|
-
|
|
329
|
+
export interface WithTranslation<
|
|
330
|
+
N extends Namespace = DefaultNamespace,
|
|
331
|
+
TKPrefix extends KeyPrefix<N> = undefined
|
|
332
|
+
> {
|
|
333
|
+
t: TFunction<N, TKPrefix>;
|
|
319
334
|
i18n: i18n;
|
|
320
335
|
tReady: boolean;
|
|
321
336
|
}
|
|
@@ -325,10 +340,14 @@ export interface WithTranslationProps {
|
|
|
325
340
|
useSuspense?: boolean;
|
|
326
341
|
}
|
|
327
342
|
|
|
328
|
-
export function withTranslation<
|
|
343
|
+
export function withTranslation<
|
|
344
|
+
N extends Namespace = DefaultNamespace,
|
|
345
|
+
TKPrefix extends KeyPrefix<N> = undefined
|
|
346
|
+
>(
|
|
329
347
|
ns?: N,
|
|
330
348
|
options?: {
|
|
331
349
|
withRef?: boolean;
|
|
350
|
+
keyPrefix?: TKPrefix;
|
|
332
351
|
},
|
|
333
352
|
): <
|
|
334
353
|
C extends React.ComponentType<React.ComponentProps<any> & WithTranslationProps>,
|
|
@@ -349,9 +368,9 @@ export interface I18nextProviderProps {
|
|
|
349
368
|
export const I18nextProvider: React.FunctionComponent<I18nextProviderProps>;
|
|
350
369
|
export const I18nContext: React.Context<{ i18n: i18n }>;
|
|
351
370
|
|
|
352
|
-
export interface TranslationProps<N extends Namespace = DefaultNamespace> {
|
|
371
|
+
export interface TranslationProps<N extends Namespace = DefaultNamespace, TKPrefix> {
|
|
353
372
|
children: (
|
|
354
|
-
t: TFunction<N>,
|
|
373
|
+
t: TFunction<N, TKPrefix>,
|
|
355
374
|
options: {
|
|
356
375
|
i18n: i18n;
|
|
357
376
|
lng: string;
|
|
@@ -361,8 +380,10 @@ export interface TranslationProps<N extends Namespace = DefaultNamespace> {
|
|
|
361
380
|
ns?: N;
|
|
362
381
|
i18n?: i18n;
|
|
363
382
|
useSuspense?: boolean;
|
|
383
|
+
keyPrefix?: TKPrefix;
|
|
364
384
|
}
|
|
365
385
|
|
|
366
|
-
export function Translation<
|
|
367
|
-
|
|
368
|
-
|
|
386
|
+
export function Translation<
|
|
387
|
+
N extends Namespace = DefaultNamespace,
|
|
388
|
+
TKPrefix extends KeyPrefix<N> = undefined
|
|
389
|
+
>(props: TranslationProps<N, TKPrefix>): any;
|