X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fapp.component.ts;h=b644ecd3b7b9a35016c07ef415a474d989b52a9f;hb=b0d130807fb9bf36f5ac1abe21cbd558eb86d5cc;hp=40cfb245e317f27fa855d77a6a1fdf906be83286;hpb=2d90eac319979dba64371258b30e61e77a15db7d;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/app.component.ts b/webapp/src/app/app.component.ts index 40cfb24..b644ecd 100644 --- a/webapp/src/app/app.component.ts +++ b/webapp/src/app/app.component.ts @@ -1,37 +1,44 @@ -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' }) 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(); } - - }