-
-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TranslateStore): added a store to share translations between ins…
…tances of the service
- Loading branch information
Showing
4 changed files
with
230 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {EventEmitter} from "@angular/core"; | ||
import {DefaultLangChangeEvent, LangChangeEvent, TranslationChangeEvent} from "./translate.service"; | ||
|
||
export class TranslateStore { | ||
/** | ||
* The default lang to fallback when translations are missing on the current lang | ||
*/ | ||
public defaultLang: string; | ||
|
||
/** | ||
* The lang currently used | ||
* @type {string} | ||
*/ | ||
public currentLang: string = this.defaultLang; | ||
|
||
/** | ||
* a list of translations per lang | ||
* @type {{}} | ||
*/ | ||
public translations: any = {}; | ||
|
||
/** | ||
* an array of langs | ||
* @type {Array} | ||
*/ | ||
public langs: Array<string> = []; | ||
|
||
/** | ||
* An EventEmitter to listen to translation change events | ||
* onTranslationChange.subscribe((params: TranslationChangeEvent) => { | ||
* // do something | ||
* }); | ||
* @type {EventEmitter<TranslationChangeEvent>} | ||
*/ | ||
public onTranslationChange: EventEmitter<TranslationChangeEvent> = new EventEmitter<TranslationChangeEvent>(); | ||
|
||
/** | ||
* An EventEmitter to listen to lang change events | ||
* onLangChange.subscribe((params: LangChangeEvent) => { | ||
* // do something | ||
* }); | ||
* @type {EventEmitter<LangChangeEvent>} | ||
*/ | ||
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>(); | ||
|
||
/** | ||
* An EventEmitter to listen to default lang change events | ||
* onDefaultLangChange.subscribe((params: DefaultLangChangeEvent) => { | ||
* // do something | ||
* }); | ||
* @type {EventEmitter<DefaultLangChangeEvent>} | ||
*/ | ||
public onDefaultLangChange: EventEmitter<DefaultLangChangeEvent> = new EventEmitter<DefaultLangChangeEvent>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters