UNPKG

1.45 kBPlain TextView Raw
1import {EventEmitter} from "@angular/core";
2import {DefaultLangChangeEvent, LangChangeEvent, TranslationChangeEvent} from "./translate.service";
3
4export class TranslateStore {
5 /**
6 * The default lang to fallback when translations are missing on the current lang
7 */
8 public defaultLang!: string;
9
10 /**
11 * The lang currently used
12 */
13 public currentLang: string = this.defaultLang;
14
15 /**
16 * a list of translations per lang
17 */
18 public translations: any = {};
19
20 /**
21 * an array of langs
22 */
23 public langs: Array<string> = [];
24
25 /**
26 * An EventEmitter to listen to translation change events
27 * onTranslationChange.subscribe((params: TranslationChangeEvent) => {
28 * // do something
29 * });
30 */
31 public onTranslationChange: EventEmitter<TranslationChangeEvent> = new EventEmitter<TranslationChangeEvent>();
32
33 /**
34 * An EventEmitter to listen to lang change events
35 * onLangChange.subscribe((params: LangChangeEvent) => {
36 * // do something
37 * });
38 */
39 public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
40
41 /**
42 * An EventEmitter to listen to default lang change events
43 * onDefaultLangChange.subscribe((params: DefaultLangChangeEvent) => {
44 * // do something
45 * });
46 */
47 public onDefaultLangChange: EventEmitter<DefaultLangChangeEvent> = new EventEmitter<DefaultLangChangeEvent>();
48}