-
Notifications
You must be signed in to change notification settings - Fork 62
/
vuex-i18n.d.ts
102 lines (83 loc) · 2.92 KB
/
vuex-i18n.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
import _Vue, { PluginObject } from "vue";
declare module "vue/types/vue" {
interface Vue {
$i18n: Ii18n;
$t(key: string, options?: any, pluralization?: number): string | undefined;
$t(key: string, defaultValue: string, options?: any, pluralization?: number): string | undefined;
}
interface VueConstructor<V extends Vue = Vue> {
i18n: Ii18n;
}
}
export interface i18nState {
fallback: string | null;
locale: string | null;
translations: {
[key: string]: Translations;
};
}
export interface Translations {
[key: string]: string | Translations;
}
export interface Ii18n {
/** get the current locale */
locale(): string | null;
/** get all the registered locales */
locales(): string[];
/** set the current locale (i.e. 'de', 'en') */
set(locale: string): void;
/**
* add locale translation to the storage. this will extend existing information
* (i.e. 'de', {'message': 'Eine Nachricht'})
*/
add(locale: string, translations: Translations): void;
/**
* replace locale translations in the storage. this will remove all previous
* locale information for the specified locale
*/
replace(locale: string, translations: Translations): void;
/**
* remove the given locale from the store
*/
remove(locale: string): void;
/**
* set a fallback locale if translation for current locale does not exist
*/
fallback(locale: string): void;
/**
* get localized string from store. note that we pass the arguments passed
* to the function directly to the translateInLanguage function
*/
translate(key: string, options?: any, pluralization?: number): string | undefined;
/**
* get localized string from store. note that we pass the arguments passed
* to the function directly to the translateInLanguage function
*/
translate(key: string, defaultValue: string, options?: any, pluralization?: number): string | undefined;
/**
* get localized string from store in a given language if available.
*/
translateIn(locale: string, key: string, options?: any, pluralization?: number): string | undefined;
/**
* get localized string from store in a given language if available.
*/
translateIn(locale: string, key: string, defaultValue: string, options?: any, pluralization?: number): string | undefined;
/**
* check if the given locale translations are present in the store
*/
localeExists(locale: string): boolean;
/**
* check if the given key is available
* optional with a second parameter to limit the scope
* strict: only current locale (exact match)
* locale: current locale and parent language locale (i.e. en-us & en)
* fallback: current locale, parent language locale and fallback locale
* the default is fallback
*/
keyExists(key: string, scope?: string): boolean;
}
declare const _default: {
plugin: PluginObject<Ii18n>;
store: Object; // the store can be of any form of object
};
export default _default;