2018-06-16 18:05:46 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2018-06-29 17:24:44 +02:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2018-07-04 17:51:31 +02:00
|
|
|
import { AutoupdateService } from 'app/core/services/autoupdate.service';
|
2018-07-06 09:38:25 +02:00
|
|
|
import { OperatorService } from 'app/core/services/operator.service';
|
2018-06-13 18:34:10 +02:00
|
|
|
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* Angular's global App Component
|
|
|
|
*/
|
2018-06-13 18:34:10 +02:00
|
|
|
@Component({
|
2018-06-19 16:55:50 +02:00
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
styleUrls: ['./app.component.css']
|
2018-06-13 18:34:10 +02:00
|
|
|
})
|
2018-07-06 09:38:25 +02:00
|
|
|
export class AppComponent {
|
2018-07-12 14:11:31 +02:00
|
|
|
/**
|
|
|
|
* Initialises the operator, the auto update (and therefore a websocket) feature and the translation unit.
|
|
|
|
* @param operator
|
|
|
|
* @param autoupdate
|
|
|
|
* @param translate
|
|
|
|
*/
|
2018-07-04 17:51:31 +02:00
|
|
|
constructor(
|
2018-07-06 09:38:25 +02:00
|
|
|
private operator: OperatorService,
|
2018-07-04 17:51:31 +02:00
|
|
|
private autoupdate: AutoupdateService,
|
|
|
|
private translate: TranslateService
|
|
|
|
) {
|
2018-06-29 17:24:44 +02:00
|
|
|
// manually add the supported languages
|
|
|
|
translate.addLangs(['en', 'de', 'fr']);
|
|
|
|
// this language will be used as a fallback when a translation isn't found in the current language
|
|
|
|
translate.setDefaultLang('en');
|
|
|
|
// get the browsers default language
|
|
|
|
const browserLang = translate.getBrowserLang();
|
|
|
|
// try to use the browser language if it is available. If not, uses english.
|
|
|
|
translate.use(translate.getLangs().includes(browserLang) ? browserLang : 'en');
|
|
|
|
}
|
2018-06-13 18:34:10 +02:00
|
|
|
}
|