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-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-23 16:42:17 +02:00
|
|
|
constructor(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
|
|
|
}
|