mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Adding Enum translations #569
This commit is contained in:
parent
84ed0cf256
commit
bd5f89fd09
@ -1,26 +1,12 @@
|
|||||||
import { Pipe, PipeTransform } from '@angular/core';
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
import { SortingMethods } from '../../../common/entities/SortingMethods';
|
import { SortingMethods } from '../../../common/entities/SortingMethods';
|
||||||
|
import {EnumTranslations} from '../ui/EnumTranslations';
|
||||||
|
|
||||||
@Pipe({ name: 'stringifySorting' })
|
@Pipe({ name: 'stringifySorting' })
|
||||||
export class StringifySortingMethod implements PipeTransform {
|
export class StringifySortingMethod implements PipeTransform {
|
||||||
|
|
||||||
transform(method: SortingMethods): string {
|
transform(method: SortingMethods): string {
|
||||||
switch (method) {
|
return EnumTranslations[SortingMethods[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`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
51
src/frontend/app/ui/EnumTranslations.ts
Normal file
51
src/frontend/app/ui/EnumTranslations.ts
Normal file
@ -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<string, string> = {};
|
||||||
|
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`;
|
@ -11,6 +11,7 @@ import {Utils} from '../../../../common/Utils';
|
|||||||
import {WebConfig} from '../../../../common/config/private/WebConfig';
|
import {WebConfig} from '../../../../common/config/private/WebConfig';
|
||||||
import {ISettingsComponent} from '../settings/template/ISettingsComponent';
|
import {ISettingsComponent} from '../settings/template/ISettingsComponent';
|
||||||
import {WebConfigClassBuilder} from '../../../../../node_modules/typeconfig/src/decorators/builders/WebConfigClassBuilder';
|
import {WebConfigClassBuilder} from '../../../../../node_modules/typeconfig/src/decorators/builders/WebConfigClassBuilder';
|
||||||
|
import {enumToTranslatedArray} from '../EnumTranslations';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin',
|
selector: 'app-admin',
|
||||||
@ -32,7 +33,7 @@ export class AdminComponent implements OnInit, AfterViewInit {
|
|||||||
public notificationService: NotificationService,
|
public notificationService: NotificationService,
|
||||||
public settingsService: SettingsService,
|
public settingsService: SettingsService,
|
||||||
) {
|
) {
|
||||||
this.configPriorities = Utils.enumToArray(ConfigPriority);
|
this.configPriorities = enumToTranslatedArray(ConfigPriority);
|
||||||
const wc = WebConfigClassBuilder.attachPrivateInterface(new WebConfig());
|
const wc = WebConfigClassBuilder.attachPrivateInterface(new WebConfig());
|
||||||
this.configPaths = Object.keys(wc.State)
|
this.configPaths = Object.keys(wc.State)
|
||||||
.filter(s => !wc.__state[s].volatile);
|
.filter(s => !wc.__state[s].volatile);
|
||||||
|
@ -7,6 +7,7 @@ import {MapLayers, NavigationLinkConfig, NavigationLinkTypes, TAGS} from '../../
|
|||||||
import {SettingsService} from '../../settings.service';
|
import {SettingsService} from '../../settings.service';
|
||||||
import {WebConfig} from '../../../../../../common/config/private/WebConfig';
|
import {WebConfig} from '../../../../../../common/config/private/WebConfig';
|
||||||
import {JobScheduleConfig, UserConfig} from '../../../../../../common/config/private/PrivateConfig';
|
import {JobScheduleConfig, UserConfig} from '../../../../../../common/config/private/PrivateConfig';
|
||||||
|
import {enumToTranslatedArray} from '../../../EnumTranslations';
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
shouldHide(): boolean;
|
shouldHide(): boolean;
|
||||||
@ -264,7 +265,7 @@ export class SettingsEntryComponent
|
|||||||
value: o + (state.tags?.unit ? state.tags?.unit : '')
|
value: o + (state.tags?.unit ? state.tags?.unit : '')
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
optionsView = Utils.enumToArray(eClass);
|
optionsView = enumToTranslatedArray(eClass);
|
||||||
}
|
}
|
||||||
return optionsView;
|
return optionsView;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user