refactor: some i18n improvements

This commit is contained in:
4gray committed 2021-02-26 18:05:30 +01:00
1 parent 7ae0a4303b
commit 0ba3854909
2 files changed
+16 -20

No files matched your search

+11 -13
View File
@@ -96,19 +96,17 @@ export class AppComponent {
*/
ngOnInit(): void {
this.storage.get('settings').subscribe((settings: Settings) => {
if (
settings &&
Object.keys(settings).length > 0 &&
settings.epgUrl
) {
this.translate.setDefaultLang(settings.language ?? 'en');
this.electronService.ipcRenderer.send(EPG_FETCH, {
url: settings.epgUrl,
});
this.snackBar.open('Fetch EPG data...', 'Close', {
verticalPosition: 'bottom',
horizontalPosition: 'right',
});
if (settings && Object.keys(settings).length > 0) {
this.translate.use(settings.language ?? 'en');
if (settings.epgUrl) {
this.electronService.ipcRenderer.send(EPG_FETCH, {
url: settings.epgUrl,
});
this.snackBar.open('Fetch EPG data...', 'Close', {
verticalPosition: 'bottom',
horizontalPosition: 'right',
});
}
}
});
}
+5 -7
View File
@@ -134,6 +134,11 @@ export class SettingsComponent implements OnInit, OnDestroy {
.set('settings', this.settingsForm.value)
.subscribe(() => {
this.settingsForm.markAsPristine();
// check whether the epg url was changed or not
if (this.settingsForm.value.epgUrl) {
this.fetchEpg();
}
this.translate.use(this.settingsForm.value.language);
this.snackBar.open(
this.translate.instant('SETTINGS.SETTINGS_SAVED'),
null,
@@ -141,13 +146,6 @@ export class SettingsComponent implements OnInit, OnDestroy {
duration: 2000,
}
);
// check whether the epg url was changed or not
if (this.settingsForm.value.epgUrl) {
this.fetchEpg();
}
this.translate.setDefaultLang(
this.settingsForm.value.language
);
})
);
}