diff --git a/src/frontend/app/pipes/StringifySortingMethod.ts b/src/frontend/app/pipes/StringifySortingMethod.ts index 2dde1db4..740d5972 100644 --- a/src/frontend/app/pipes/StringifySortingMethod.ts +++ b/src/frontend/app/pipes/StringifySortingMethod.ts @@ -1,26 +1,12 @@ import { Pipe, PipeTransform } from '@angular/core'; import { SortingMethods } from '../../../common/entities/SortingMethods'; +import {EnumTranslations} from '../ui/EnumTranslations'; @Pipe({ name: 'stringifySorting' }) export class StringifySortingMethod implements PipeTransform { transform(method: SortingMethods): string { - switch (method) { - case SortingMethods.ascRating: - return $localize`ascending rating`; - case SortingMethods.descRating: - return $localize`descending rating`; - case SortingMethods.ascName: - return $localize`ascending name`; - case SortingMethods.descName: - return $localize`descending name`; - case SortingMethods.ascDate: - return $localize`ascending date`; - case SortingMethods.descDate: - return $localize`descending date`; - case SortingMethods.random: - return $localize`random`; - } + return EnumTranslations[SortingMethods[method]]; } } diff --git a/src/frontend/app/ui/EnumTranslations.ts b/src/frontend/app/ui/EnumTranslations.ts new file mode 100644 index 00000000..d0f80e32 --- /dev/null +++ b/src/frontend/app/ui/EnumTranslations.ts @@ -0,0 +1,51 @@ +import {UserRoles} from '../../../common/entities/UserDTO'; +import {ConfigPriority, MapProviders, NavigationLinkTypes} from '../../../common/config/public/ClientConfig'; +import {ReIndexingSensitivity} from '../../../common/config/private/PrivateConfig'; +import {SortingMethods} from '../../../common/entities/SortingMethods'; + +export const EnumTranslations: Record = {}; +export const enumToTranslatedArray = (EnumType: any): { key: number; value: string }[] => { + const arr: Array<{ key: number; value: string }> = []; + for (const enumMember in EnumType) { + const key = parseInt(enumMember, 10); + if (key >= 0) { + arr.push({key, value: EnumTranslations[EnumType[enumMember]] || EnumType[enumMember]}); + } + } + return arr; +}; +EnumTranslations[UserRoles[UserRoles.Developer]] = $localize`Developer`; +EnumTranslations[UserRoles[UserRoles.Admin]] = $localize`Admin`; +EnumTranslations[UserRoles[UserRoles.User]] = $localize`User`; +EnumTranslations[UserRoles[UserRoles.Guest]] = $localize`Guest`; +EnumTranslations[UserRoles[UserRoles.LimitedGuest]] = $localize`LimitedGuest`; + + +EnumTranslations[ConfigPriority[ConfigPriority.basic]] = $localize`Basic`; +EnumTranslations[ConfigPriority[ConfigPriority.advanced]] = $localize`Advanced`; +EnumTranslations[ConfigPriority[ConfigPriority.underTheHood]] = $localize`Under the hood`; + +EnumTranslations[MapProviders[MapProviders.Custom]] = $localize`Custom`; +EnumTranslations[MapProviders[MapProviders.OpenStreetMap]] = $localize`OpenStreetMap`; +EnumTranslations[MapProviders[MapProviders.Mapbox]] = $localize`Mapbox`; + + +EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.low]] = $localize`low`; +EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.high]] = $localize`high`; +EnumTranslations[ReIndexingSensitivity[ReIndexingSensitivity.medium]] = $localize`medium`; + + +EnumTranslations[SortingMethods[SortingMethods.descDate]] = $localize`descending date`; +EnumTranslations[SortingMethods[SortingMethods.ascDate]] = $localize`ascending date`; +EnumTranslations[SortingMethods[SortingMethods.descName]] = $localize`descending name`; +EnumTranslations[SortingMethods[SortingMethods.ascName]] = $localize`ascending name`; +EnumTranslations[SortingMethods[SortingMethods.descRating]] = $localize`descending rating`; +EnumTranslations[SortingMethods[SortingMethods.ascRating]] = $localize`ascending rating`; +EnumTranslations[SortingMethods[SortingMethods.random]] = $localize`random`; + + +EnumTranslations[NavigationLinkTypes[NavigationLinkTypes.url]] = $localize`Url`; +EnumTranslations[NavigationLinkTypes[NavigationLinkTypes.search]] = $localize`Search`; +EnumTranslations[NavigationLinkTypes[NavigationLinkTypes.gallery]] = $localize`Gallery`; +EnumTranslations[NavigationLinkTypes[NavigationLinkTypes.albums]] = $localize`Albums`; +EnumTranslations[NavigationLinkTypes[NavigationLinkTypes.faces]] = $localize`Faces`; diff --git a/src/frontend/app/ui/admin/admin.component.ts b/src/frontend/app/ui/admin/admin.component.ts index 42f1685e..1f82f951 100644 --- a/src/frontend/app/ui/admin/admin.component.ts +++ b/src/frontend/app/ui/admin/admin.component.ts @@ -11,6 +11,7 @@ import {Utils} from '../../../../common/Utils'; import {WebConfig} from '../../../../common/config/private/WebConfig'; import {ISettingsComponent} from '../settings/template/ISettingsComponent'; import {WebConfigClassBuilder} from '../../../../../node_modules/typeconfig/src/decorators/builders/WebConfigClassBuilder'; +import {enumToTranslatedArray} from '../EnumTranslations'; @Component({ selector: 'app-admin', @@ -32,7 +33,7 @@ export class AdminComponent implements OnInit, AfterViewInit { public notificationService: NotificationService, public settingsService: SettingsService, ) { - this.configPriorities = Utils.enumToArray(ConfigPriority); + this.configPriorities = enumToTranslatedArray(ConfigPriority); const wc = WebConfigClassBuilder.attachPrivateInterface(new WebConfig()); this.configPaths = Object.keys(wc.State) .filter(s => !wc.__state[s].volatile); diff --git a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts index 8bdde4ea..22c26a44 100644 --- a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts +++ b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts @@ -7,6 +7,7 @@ import {MapLayers, NavigationLinkConfig, NavigationLinkTypes, TAGS} from '../../ import {SettingsService} from '../../settings.service'; import {WebConfig} from '../../../../../../common/config/private/WebConfig'; import {JobScheduleConfig, UserConfig} from '../../../../../../common/config/private/PrivateConfig'; +import {enumToTranslatedArray} from '../../../EnumTranslations'; interface IState { shouldHide(): boolean; @@ -264,7 +265,7 @@ export class SettingsEntryComponent value: o + (state.tags?.unit ? state.tags?.unit : '') })); } else { - optionsView = Utils.enumToArray(eClass); + optionsView = enumToTranslatedArray(eClass); } return optionsView; }