Consider language from user settings (#1179)

pull/1180/head
Thomas Kaul 2 years ago committed by GitHub
parent df0e9ad03b
commit 56bf422407
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,10 @@ export class UpdateUserSettingDto {
@IsOptional()
isRestrictedView?: boolean;
@IsString()
@IsOptional()
language?: string;
@IsString()
@IsOptional()
locale?: string;

@ -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
) {

@ -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 = `../`;
}
}
});
});
}

@ -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>

@ -3,6 +3,7 @@ import { ViewMode } from '@prisma/client';
export interface UserSettings {
baseCurrency?: string;
isRestrictedView?: boolean;
language?: string;
locale: string;
viewMode?: ViewMode;
}

Loading…
Cancel
Save