2018-09-13 14:40:04 +02:00
|
|
|
import { Component } from '@angular/core';
|
2018-06-29 17:24:44 +02:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2018-08-28 11:07:10 +02:00
|
|
|
import { OperatorService } from './core/services/operator.service';
|
2018-09-06 07:14:55 +02:00
|
|
|
import { LoginDataService } from './core/services/login-data.service';
|
|
|
|
import { ConfigService } from './core/services/config.service';
|
2018-09-10 08:15:31 +02:00
|
|
|
import { ConstantsService } from './core/services/constants.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-09-03 17:57:20 +02:00
|
|
|
selector: 'os-root',
|
2018-06-19 16:55:50 +02:00
|
|
|
templateUrl: './app.component.html',
|
2018-08-28 09:33:50 +02:00
|
|
|
styleUrls: ['./app.component.scss']
|
2018-06-13 18:34:10 +02:00
|
|
|
})
|
2018-07-06 09:38:25 +02:00
|
|
|
export class AppComponent {
|
2018-08-28 11:07:10 +02:00
|
|
|
/**
|
|
|
|
* Initialises the translation unit.
|
2018-08-23 15:28:57 +02:00
|
|
|
* @param autoupdateService
|
|
|
|
* @param notifyService
|
2018-07-12 14:11:31 +02:00
|
|
|
* @param translate
|
|
|
|
*/
|
2018-08-29 13:21:25 +02:00
|
|
|
public constructor(
|
|
|
|
translate: TranslateService,
|
2018-09-13 14:40:04 +02:00
|
|
|
operator: OperatorService,
|
|
|
|
configService: ConfigService,
|
2018-09-10 08:15:31 +02:00
|
|
|
loginDataService: LoginDataService,
|
|
|
|
constantsService: ConstantsService // Needs to be started, so it can register itself to the WebsocketService
|
2018-08-23 15:28:57 +02:00
|
|
|
) {
|
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
|
|
|
}
|