Consider language from user settings (#1179)

This commit is contained in:
Thomas Kaul
2022-08-21 18:06:31 +02:00
committed by GitHub
parent df0e9ad03b
commit 56bf422407
5 changed files with 22 additions and 6 deletions

View File

@@ -72,7 +72,13 @@ export class AuthGuard implements CanActivate {
})
)
.subscribe((user) => {
if (
const userLanguage = user?.settings?.language;
if (userLanguage && document.documentElement.lang !== userLanguage) {
window.location.href = `../${userLanguage}`;
resolve(false);
return;
} else if (
state.url.startsWith('/home') &&
user.settings.viewMode === ViewMode.ZEN
) {

View File

@@ -149,10 +149,6 @@ export class AccountPageComponent implements OnDestroy, OnInit {
this.update();
}
public onChangeLanguage(aLanguage: string) {
window.location.href = `../${aLanguage}/account`;
}
public onChangeUserSetting(aKey: string, aValue: string) {
this.dataService
.putUserSetting({ [aKey]: aValue })
@@ -167,6 +163,14 @@ export class AccountPageComponent implements OnDestroy, OnInit {
this.user = user;
this.changeDetectorRef.markForCheck();
if (aKey === 'language') {
if (aValue) {
window.location.href = `../${aValue}/account`;
} else {
window.location.href = `../`;
}
}
});
});
}

View File

@@ -120,8 +120,9 @@
<mat-select
name="language"
[value]="language"
(selectionChange)="onChangeLanguage($event.value)"
(selectionChange)="onChangeUserSetting('language', $event.value)"
>
<mat-option [value]="null"></mat-option>
<mat-option value="de">Deutsch</mat-option>
<mat-option value="en">English</mat-option>
</mat-select>