forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18next.d.ts
140 lines (111 loc) · 4.5 KB
/
i18next.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Type definitions for i18next v2.3.4
// Project: http://i18next.com
// Definitions by: Michael Ledin <https://github.com/mxl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Sources: https://github.com/i18next/i18next/
declare namespace I18next {
interface ResourceStore {
[language: string]: ResourceStoreLanguage;
}
interface ResourceStoreLanguage {
[namespace: string]: ResourceStoreKey;
}
interface ResourceStoreKey {
[key: string]: any;
}
interface InterpolationOptions {
escapeValue?: boolean;
prefix?: string;
suffix?: string;
prefixEscaped?: string;
suffixEscaped?: string;
unescapeSuffix?: string;
unescapePrefix?: string;
nestingPrefix?: string;
nestingSuffix?: string;
nestingPrefixEscaped?: string;
nestedSuffixEscaped?: string;
defaultVariables?: any;
}
interface TranslationOptions {
defaultValue?: string;
count?: number;
context?: any;
replace?: any;
lng?: string;
lngs?: string[];
fallbackLng?: string;
ns?: string | string[];
keySeparator?: string;
nsSeparator?: string;
returnObjects?: boolean;
joinArrays?: string;
postProcess?: string | any[];
interpolation?: InterpolationOptions;
}
interface Options {
debug?: boolean;
resources?: ResourceStore;
lng?: string;
fallbackLng?: string;
ns?: string | string[];
defaultNS?: string;
fallbackNS?: string | string[];
whitelist?: string[];
lowerCaseLng?: boolean;
load?: string
preload?: string[];
keySeparator?: string;
nsSeparator?: string;
pluralSeparator?: string;
contextSeparator?: string;
saveMissing?: boolean;
saveMissingTo?: string;
missingKeyHandler?: (lng: string, ns: string, key: string, fallbackValue: string) => void;
parseMissingKeyHandler?: (key: string) => void;
appendNamespaceToMissingKey?: boolean;
postProcess?: string | any[];
returnNull?: boolean;
returnEmptyString?: boolean;
returnObjects?: boolean;
returnedObjectHandler?: (key: string, value: string, options: any) => void;
joinArrays?: string;
overloadTranslationOptionHandler?: (args: any[]) => TranslationOptions;
interpolation?: InterpolationOptions;
detection?: any;
backend?: any;
cache?: any;
}
type TranslationFunction = (key: string, options?: TranslationOptions) => string;
class I18n {
constructor(options?: Options, callback?: (err: any, t: TranslationFunction) => void);
init(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n;
loadResources(callback?: (err: any) => void): void;
language: string;
languages: string[];
use(module: any): I18n;
changeLanguage(lng: string, callback?: (err: any, t: TranslationFunction) => void): void;
getFixedT(lng?: string, ns?: string | string[]): TranslationFunction;
t(key: string, options?: TranslationOptions): string | any | Array<any>;
exists(): boolean;
setDefaultNamespace(ns: string): void;
loadNamespaces(ns: string[], callback?: () => void): void;
loadLanguages(lngs: string[], callback?: () => void): void;
dir(lng?: string): string;
createInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n;
cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n;
on(event: string, listener: () => void): void;
on(initialized: 'initialized', listener: (options: I18next.Options) => void): void;
on(loaded: 'loaded', listener: (loaded: any) => void): void;
on(failedLoading: 'failedLoading', listener: (lng: string, ns: string, msg: string) => void): void;
on(missingKey: 'missingKey', listener: (lngs: any, namespace: string, key: string, res: any) => void): void;
on(added: 'added', listener: (lng: string, ns: string) => void): void;
on(removed: 'removed', listener: (lng: string, ns: string) => void): void;
on(languageChanged: 'languageChanged', listener: (lng: string) => void): void;
off(event: string, listener: () => void): void;
}
}
declare module 'i18next' {
var i18n: I18next.I18n;
export = i18n;
}