OpenSlides/client/src/app/app.component.ts

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-09-13 14:40:04 +02:00
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { OperatorService } from './core/services/operator.service';
import { LoginDataService } from './core/services/login-data.service';
import { ConfigService } from './core/services/config.service';
/**
* Angular's global App Component
*/
@Component({
selector: 'os-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
/**
* Initialises the translation unit.
* @param autoupdateService
* @param notifyService
* @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,
loginDataService: LoginDataService
) {
// 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');
}
}