-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.d.ts
45 lines (32 loc) · 1.07 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
import { Context, ComponentType, Consumer, PropsWithChildren } from 'react';
interface Translations {
[key: string]: string | number | Translations;
}
type TemplateValues = Record<string, string | number>;
type Translate = (
key: string,
values?: TemplateValues,
defaultMessage?: string
) => string;
interface LocalizationContextValue {
locale: string;
translate: Translate;
translations: Translations;
}
interface LocalizationProviderProps {
locale?: string;
disableCache?: boolean;
translations: Translations;
}
interface MessageComponentProps {
descriptor: string;
values?: TemplateValues;
defaultMessage?: string;
}
type UseLocalizeHook = () => LocalizationContextValue;
type MessageComponent = ComponentType<MessageComponentProps>;
export const useLocalize: UseLocalizeHook;
export const Message: MessageComponent;
export const LocalizationContext: Context<LocalizationContextValue>;
export const LocalizationProvider: ComponentType<PropsWithChildren<LocalizationProviderProps>>;
export const LocalizationConsumer: Consumer<LocalizationContextValue>;