forked from i18next/react-i18next
/
index.d.ts
114 lines (91 loc) · 2.69 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import * as React from 'react';
import {
i18n,
TranslationFunction,
ReactOptions as I18nOptions,
} from 'i18next';
import { Context as ReactContext } from 'create-react-context';
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Subtract<T, K> = Omit<T, keyof K>;
export interface ReactI18NextOptions extends I18nOptions {
usePureComponent?: boolean;
omitBoundRerender?: boolean;
}
interface ReactI18nextModule {
type: string;
init: (instance: i18n) => void;
}
export const reactI18nextModule: ReactI18nextModule;
export function setDefaults(options: ReactI18NextOptions): void;
export function getDefaults(): ReactI18NextOptions;
export function setI18n(instance: i18n): void;
export function getI18n(): i18n;
export interface I18nContextValues {
i18n: i18n;
t: TranslationFunction;
defaultNS?: string;
reportNS?: string;
lng?: string;
}
export const I18nContext: ReactContext<I18nContextValues>;
export interface WithI18n extends I18nContextValues {
i18nOptions?: ReactI18NextOptions;
}
export function withI18n(): <P extends object>(
Wrapper: React.ComponentType<P>,
) => React.ComponentType<Subtract<P, WithI18n>>;
export interface WithNamespaces extends WithI18n {
tReady: boolean;
initialI18nStore?: {};
initialLanguage?: string;
}
export interface WithNamespacesOptions extends ReactI18NextOptions {
wait: boolean;
i18n?: i18n;
innerRef?:
| ((instance: any) => void)
| React.RefObject<HTMLElement | SVGElement | React.Component>;
}
type Namespace = string | string[];
interface NamespaceExtractor {
(props: any & { namespace: Namespace }): Namespace;
}
export function withNamespaces(
namespace?: Namespace | NamespaceExtractor,
options?: WithNamespacesOptions,
): <P extends WithNamespaces>(
component: React.ComponentType<P>,
) => React.ComponentType<Subtract<P, WithNamespaces>>;
export const translate: typeof withNamespaces;
export interface NamespacesConsumerProps extends ReactI18NextOptions {
ns: Namespace;
initialI18nStore?: {};
initialLanguage?: string;
children(
t: TranslationFunction,
options: {
i18n: i18n;
lng: string;
ready: boolean;
},
): React.ReactNode;
}
export const NamespacesConsumer: React.ComponentClass<NamespacesConsumerProps>;
export interface I18nextProviderProps {
i18n: i18n;
defaultNS?: string;
initialI18nStore?: {};
initialLanguage?: string;
}
export const I18nextProvider: React.ComponentClass<I18nextProviderProps>;
export interface TransProps {
i18nKey?: string;
count?: number;
parent?: React.ReactNode;
i18n?: i18n;
t?: TranslationFunction;
defaults?: string;
values?: {};
components?: React.ReactNode[];
}
export const Trans: React.ComponentClass<TransProps>;