-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.d.ts
158 lines (151 loc) · 3.77 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import { BackendModule, ReadCallback, ResourceKey, Services } from "i18next";
type AllowedAddOrUpdateHostsFunction = (hostname: string) => boolean;
export interface LocizeBackendOptions {
/**
* your locize projectId
*/
projectId: string;
/**
* your locize apikey (only use this in development) to add / update translations
*/
apiKey?: string;
/**
* the reference (source) language of your project (default "en")
*/
referenceLng?: string;
/**
* the version of translations to load
*/
version?: string;
/**
* path where resources get loaded from
* the returned path will interpolate projectId, version, lng, ns if provided like giving a static path
*/
loadPath?: string;
/**
* use loading from private published files
*/
private?: boolean;
/**
* path where resources get loaded from if using private published translations
*/
privatePath?: string;
/**
* use loading from database
*/
pull?: boolean;
/**
* path where resources get loaded from if loading directly from database
*/
pullPath?: string;
/**
* path to post missing resources
*/
addPath?: string;
/**
* path to post updated resources
*/
updatePath?: string;
/**
* allow cross domain requests
*/
crossDomain?: boolean;
/**
* set JSON as content type
*/
setContentTypeJSON?: boolean;
/**
* can be used to reload resources in a specific
* interval (useful in server environments)
*/
reloadInterval?: false | number;
/**
* hostnames that are allowed to create & update keys
*/
allowedAddOrUpdateHosts?: string[] | AllowedAddOrUpdateHostsFunction;
/**
* threshold to accept languages from locize in to supportedLngs
*/
translatedPercentageThreshold?: number;
}
type LoadCallback = (error: any, result: any) => void;
export interface RequestResponse {
status: number;
data: ResourceKey;
}
export type RequestCallback = (error: any, response: RequestResponse) => void;
export interface CustomRequestOptions {
url: string,
method: 'GET' | 'POST'
body: ResourceKey | undefined,
headers: {
[name: string]: string;
}
}
declare class I18NextLocizeBackend
implements BackendModule<LocizeBackendOptions>
{
static type: "backend";
constructor(
options?: LocizeBackendOptions,
callback?: LoadCallback
);
constructor(
services?: Services,
options?: LocizeBackendOptions,
callback?: LoadCallback
);
init(
options?: LocizeBackendOptions,
callback?: LoadCallback
): void;
init(
services?: Services,
options?: LocizeBackendOptions,
callback?: LoadCallback
): void;
init(services?: any, options?: LocizeBackendOptions): void;
getLanguages(callback: LoadCallback): void;
getLanguages(): Promise<any>;
getOptions(callback: LoadCallback): void;
getOptions(): Promise<any>;
read(language: string, namespace: string, callback: ReadCallback): void;
loadUrl(options: any, url: string, callback: ReadCallback): void;
create(
languages: string | string[],
namespace: string,
key: string,
fallbackValue: string,
callback: LoadCallback,
options: any
): void;
create(
languages: string[],
namespace: string,
key: string,
fallbackValue: string
): void;
update(
languages: string | string[],
namespace: string,
key: string,
fallbackValue: string,
callback: LoadCallback,
options: any
): void;
write(language: string, namespace: string): void;
type: "backend";
options: LocizeBackendOptions;
/**
* define a custom request function
* can be used to support Angular http client
*/
request?(
info: CustomRequestOptions,
callback: RequestCallback
): void;
request?(
info: CustomRequestOptions,
): Promise<RequestResponse>;
}
export default I18NextLocizeBackend;