Change language indicator
This commit is contained in:
parent
fcc5c008a1
commit
cbb9185c2a
@ -97,8 +97,9 @@
|
|||||||
<button mat-icon-button (click)='sideNav.toggle()'>
|
<button mat-icon-button (click)='sideNav.toggle()'>
|
||||||
<fa-icon icon='ellipsis-v'></fa-icon>
|
<fa-icon icon='ellipsis-v'></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button [matMenuTriggerFor]="languageMenu">
|
<button mat-button [matMenuTriggerFor]="languageMenu">
|
||||||
<fa-icon icon='language'></fa-icon>
|
<fa-icon icon='globe-americas'></fa-icon>
|
||||||
|
<span> {{getLangName(this.translate.currentLang)}} </span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- TODO: Could use translate.getLangs() to fetch available languages-->
|
<!-- TODO: Could use translate.getLangs() to fetch available languages-->
|
||||||
|
@ -29,6 +29,7 @@ export class SiteComponent extends BaseComponent implements OnInit {
|
|||||||
* True if Viewport equals mobile or small resolution. Set by breakpointObserver.
|
* True if Viewport equals mobile or small resolution. Set by breakpointObserver.
|
||||||
*/
|
*/
|
||||||
isMobile = false;
|
isMobile = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -46,7 +47,7 @@ export class SiteComponent extends BaseComponent implements OnInit {
|
|||||||
private operator: OperatorService,
|
private operator: OperatorService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private breakpointObserver: BreakpointObserver,
|
private breakpointObserver: BreakpointObserver,
|
||||||
protected translate: TranslateService,
|
public translate: TranslateService,
|
||||||
public dialog: MatDialog
|
public dialog: MatDialog
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
@ -87,13 +88,21 @@ export class SiteComponent extends BaseComponent implements OnInit {
|
|||||||
* Let the user change the language
|
* Let the user change the language
|
||||||
* @param lang the desired language (en, de, fr, ...)
|
* @param lang the desired language (en, de, fr, ...)
|
||||||
*/
|
*/
|
||||||
selectLang(lang: string): void {
|
selectLang(selection: string): void {
|
||||||
console.log('selected langauge: ', lang);
|
this.translate.use(selection).subscribe();
|
||||||
console.log('get Langs : ', this.translate.getLangs());
|
}
|
||||||
|
|
||||||
this.translate.use(lang).subscribe(res => {
|
/**
|
||||||
console.log('language changed : ', res);
|
* Get the name of a Language by abbreviation.
|
||||||
});
|
*/
|
||||||
|
getLangName(abbreviation: string): string {
|
||||||
|
if (abbreviation === 'en') {
|
||||||
|
return this.translate.instant('English');
|
||||||
|
} else if (abbreviation === 'de') {
|
||||||
|
return this.translate.instant('German');
|
||||||
|
} else if (abbreviation === 'fr') {
|
||||||
|
return this.translate.instant('French');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user