refactor: i18n for settings module

This commit is contained in:
Rainer Killinger
2021-02-09 10:38:28 +01:00
parent abf7595c03
commit 350185b0d3
8 changed files with 23 additions and 61 deletions

View File

@@ -20,6 +20,7 @@ import {ThingPropertyNameTranslatePipe, ThingTranslatePipe} from './thing-transl
import {ThingTranslateService} from './thing-translate.service';
// tslint:disable: completed-docs
export interface ThingTranslateModuleConfig {
parser?: Provider;
}

View File

@@ -16,6 +16,7 @@
import {Injectable, OnDestroy} from '@angular/core';
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
import {SCLanguage, SCThings, SCThingTranslator, SCThingType, SCTranslations} from '@openstapps/core';
import moment from 'moment';
import {Subscription} from 'rxjs';
import {isDefined, ThingTranslateParser} from './thing-translate.parser';
@@ -41,10 +42,12 @@ export class ThingTranslateService implements OnDestroy {
public parser: ThingTranslateParser){
this.translator = new SCThingTranslator('de' ?? this.translateService.currentLang as keyof SCTranslations<SCLanguage>);
moment.updateLocale(this.translator.language);
/** set the default language from configuration */
this.onLangChange = this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.translator.language = event.lang as keyof SCTranslations<SCLanguage>;
moment.updateLocale(event.lang);
});
}