-
Notifications
You must be signed in to change notification settings - Fork 995
/
y18n.d.ts
59 lines (51 loc) · 1.44 KB
/
y18n.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
// TODO: either update @types/y18n with this or convert y18n to typescript
// Forked from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a9cb5fa/types/y18n/index.d.ts
interface Config {
/**
* The locale directory, default ./locales.
*/
directory: string;
/**
* Should newly observed strings be updated in file, default true.
*/
updateFiles: boolean;
/**
* What locale should be used.
*/
locale: string;
/**
* Should fallback to a language-only file (e.g. en.json) be allowed
* if a file matching the locale does not exist (e.g. en_US.json), default true.
*/
fallbackToLanguage: boolean;
}
declare class Y18N {
/**
* Create an instance of y18n with the config provided
*/
constructor(config?: Config);
/**
* Print a localized string, %s will be replaced with args.
*/
__(str: string, arg1?: string, arg2?: string, arg3?: string): string;
/**
* Print a localized string with appropriate pluralization.
* If %d is provided in the string, the quantity will replace this placeholder.
*/
__n(singular: string, plural: string, quantity: number, ...param: any[]): string;
/**
* Set the current locale being used.
*/
setLocale(str: string): void;
/**
* What locale is currently being used?
*/
getLocale(): string;
/**
* Update the current locale with the key value pairs in obj.
*/
updateLocale(obj: object): void;
}
declare module 'y18n' {
export = Y18N;
}