Skip to content
Snippets Groups Projects
Commit d2839612 authored by mathias.chouet's avatar mathias.chouet
Browse files

Fix #130

parent 0ea6425b
No related branches found
No related tags found
No related merge requests found
......@@ -103,8 +103,15 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
}
ngOnInit() {
this.intlService.addObserver(this);
this.intlService.setLocale(this.appSetupService.language);
// try to detect the browser's language
const navLang = navigator.language;
try {
this.intlService.setLocale(navLang);
} catch (e) {
console.error(e.toString());
this.intlService.setLocale(this.appSetupService.language);
}
this.formulaireService.addObserver(this);
this.subscribeErrorService();
this._innerWidth = window.innerWidth;
......@@ -206,14 +213,6 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
this.errorService.removeObserver(this);
}
private updateLocale() {
const tag = this.appSetupService.language;
document["locale"] = tag;
this.intlService.setLocale(tag);
this.appRef.tick();
}
// interface Observer
update(sender: any, data: any): void {
......@@ -260,8 +259,6 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
this.closeCalculator(form);
break;
}
} else if (sender instanceof I18nService) {
this.updateLocale();
} else if (sender instanceof FormulaireDefinition) {
switch (data["action"]) {
case "nameChanged":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment