diff options
Diffstat (limited to 'webapp/src/app/app.component.ts')
-rw-r--r-- | webapp/src/app/app.component.ts | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/webapp/src/app/app.component.ts b/webapp/src/app/app.component.ts index 40cfb24..0d1ce12 100644 --- a/webapp/src/app/app.component.ts +++ b/webapp/src/app/app.component.ts @@ -1,37 +1,45 @@ -import { Component, OnInit, OnDestroy } from "@angular/core"; -import { Router } from '@angular/router'; -//TODO import {TranslateService} from "ng2-translate"; +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { ConfigService, IConfig } from './services/config.service'; @Component({ - selector: 'app', - templateUrl: './app/app.component.html', - styleUrls: ['./app/app.component.css'] + selector: 'app-root', + templateUrl: 'app.component.html', + styleUrls: ['app.component.css'] }) export class AppComponent implements OnInit, OnDestroy { + private defaultLanguage = 'en'; + public isCollapsed = true; - isCollapsed: boolean = true; - - private defaultLanguage: string = 'en'; - - // I initialize the app component. - //TODO constructor(private translate: TranslateService) { - constructor(public router: Router) { + constructor(private translate: TranslateService, private configSvr: ConfigService) { } ngOnInit() { - - /* TODO - this.translate.addLangs(["en", "fr"]); + this.translate.addLangs(['en', 'fr']); this.translate.setDefaultLang(this.defaultLanguage); - let browserLang = this.translate.getBrowserLang(); + const browserLang = this.translate.getBrowserLang(); this.translate.use(browserLang.match(/en|fr/) ? browserLang : this.defaultLanguage); - */ + + this.configSvr.Conf$.subscribe((cfg: IConfig) => { + let lang: string; + switch (cfg.language) { + case 'ENG': + lang = 'en'; + break; + case 'FRA': + lang = 'fr'; + break; + default: + lang = this.defaultLanguage; + } + this.translate.use(lang); + }); } ngOnDestroy(): void { + // this.aglIdentityService.loginResponse.unsubscribe(); + // this.aglIdentityService.logoutResponse.unsubscribe(); } - - } |