feat: add i18n translations for stats, pdf reader, magic shelf, and remaining components (en/es) (#2742)
This commit is contained in:
@@ -166,7 +166,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
private sideBarFilter = new SideBarFilter(this.selectedFilter, this.selectedFilterMode);
|
||||
private headerFilter = new HeaderFilter(this.searchTerm$);
|
||||
protected bookSorter = new BookSorter(
|
||||
sortCriteria => this.onMultiSortChange(sortCriteria)
|
||||
sortCriteria => this.onMultiSortChange(sortCriteria),
|
||||
this.t
|
||||
);
|
||||
private sortService = inject(SortService);
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
<p-accordion-header>
|
||||
<span class="filter-type-label">
|
||||
<span class="filter-label-text">
|
||||
{{ filterLabels[filterType] || (filterType | titlecase) }}
|
||||
{{ getFilterLabel(filterType) }}
|
||||
</span>
|
||||
@if (activeFilters[filterType]?.length) {
|
||||
<span class="active-filter-count">
|
||||
|
||||
+11
-5
@@ -5,16 +5,16 @@ import {Shelf} from '../../../model/shelf.model';
|
||||
import {EntityType} from '../book-browser.component';
|
||||
import {Accordion, AccordionContent, AccordionHeader, AccordionPanel} from 'primeng/accordion';
|
||||
import {CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport} from '@angular/cdk/scrolling';
|
||||
import {AsyncPipe, NgClass, TitleCasePipe} from '@angular/common';
|
||||
import {AsyncPipe, NgClass} from '@angular/common';
|
||||
import {Badge} from 'primeng/badge';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {SelectButton} from 'primeng/selectbutton';
|
||||
import {BookFilterMode, DEFAULT_VISIBLE_FILTERS, UserService, VisibleFilterType} from '../../../../settings/user-management/user.service';
|
||||
import {MagicShelf} from '../../../../magic-shelf/service/magic-shelf.service';
|
||||
import {Filter, FILTER_LABELS, FilterType} from './book-filter.config';
|
||||
import {Filter, FILTER_LABEL_KEYS, FilterType} from './book-filter.config';
|
||||
import {BookFilterService} from './book-filter.service';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
type FilterModeOption = { label: string; value: BookFilterMode };
|
||||
|
||||
@@ -27,7 +27,7 @@ type FilterModeOption = { label: string; value: BookFilterMode };
|
||||
imports: [
|
||||
Accordion, AccordionPanel, AccordionHeader, AccordionContent,
|
||||
CdkVirtualScrollViewport, CdkFixedSizeVirtualScroll, CdkVirtualForOf,
|
||||
NgClass, Badge, AsyncPipe, TitleCasePipe, FormsModule, SelectButton,
|
||||
NgClass, Badge, AsyncPipe, FormsModule, SelectButton,
|
||||
TranslocoDirective
|
||||
]
|
||||
})
|
||||
@@ -42,6 +42,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
|
||||
private readonly filterService = inject(BookFilterService);
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
private readonly activeFilters$ = new BehaviorSubject<Record<string, unknown[]> | null>(null);
|
||||
@@ -57,7 +58,12 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
private _selectedFilterMode: BookFilterMode = 'and';
|
||||
private _visibleFilters: VisibleFilterType[] = [...DEFAULT_VISIBLE_FILTERS];
|
||||
|
||||
readonly filterLabels = FILTER_LABELS;
|
||||
readonly filterLabelKeys = FILTER_LABEL_KEYS;
|
||||
|
||||
getFilterLabel(type: FilterType): string {
|
||||
const key = this.filterLabelKeys[type];
|
||||
return key ? this.t.translate(key) : type;
|
||||
}
|
||||
readonly filterModeOptions: FilterModeOption[] = [
|
||||
{label: 'AND', value: 'and'},
|
||||
{label: 'OR', value: 'or'},
|
||||
|
||||
+65
@@ -269,6 +269,71 @@ export const FILTER_EXTRACTORS: Readonly<Record<Exclude<FilterType, 'library'>,
|
||||
}
|
||||
};
|
||||
|
||||
// Translation key for each FilterType — used by UI components to translate filter labels
|
||||
export const FILTER_LABEL_KEYS: Readonly<Record<FilterType, string>> = {
|
||||
author: 'book.filter.labels.author',
|
||||
category: 'book.filter.labels.category',
|
||||
series: 'book.filter.labels.series',
|
||||
bookType: 'book.filter.labels.bookType',
|
||||
readStatus: 'book.filter.labels.readStatus',
|
||||
personalRating: 'book.filter.labels.personalRating',
|
||||
publisher: 'book.filter.labels.publisher',
|
||||
matchScore: 'book.filter.labels.matchScore',
|
||||
library: 'book.filter.labels.library',
|
||||
shelf: 'book.filter.labels.shelf',
|
||||
shelfStatus: 'book.filter.labels.shelfStatus',
|
||||
tag: 'book.filter.labels.tag',
|
||||
publishedDate: 'book.filter.labels.publishedDate',
|
||||
fileSize: 'book.filter.labels.fileSize',
|
||||
amazonRating: 'book.filter.labels.amazonRating',
|
||||
goodreadsRating: 'book.filter.labels.goodreadsRating',
|
||||
hardcoverRating: 'book.filter.labels.hardcoverRating',
|
||||
language: 'book.filter.labels.language',
|
||||
pageCount: 'book.filter.labels.pageCount',
|
||||
mood: 'book.filter.labels.mood',
|
||||
ageRating: 'book.filter.labels.ageRating',
|
||||
contentRating: 'book.filter.labels.contentRating',
|
||||
narrator: 'book.filter.labels.narrator',
|
||||
comicCharacter: 'book.filter.labels.comicCharacter',
|
||||
comicTeam: 'book.filter.labels.comicTeam',
|
||||
comicLocation: 'book.filter.labels.comicLocation',
|
||||
comicCreator: 'book.filter.labels.comicCreator'
|
||||
};
|
||||
|
||||
export const READ_STATUS_LABEL_KEYS: Readonly<Record<ReadStatus, string>> = {
|
||||
[ReadStatus.UNREAD]: 'book.filter.readStatus.unread',
|
||||
[ReadStatus.READING]: 'book.filter.readStatus.reading',
|
||||
[ReadStatus.RE_READING]: 'book.filter.readStatus.reReading',
|
||||
[ReadStatus.PARTIALLY_READ]: 'book.filter.readStatus.partiallyRead',
|
||||
[ReadStatus.PAUSED]: 'book.filter.readStatus.paused',
|
||||
[ReadStatus.READ]: 'book.filter.readStatus.read',
|
||||
[ReadStatus.WONT_READ]: 'book.filter.readStatus.wontRead',
|
||||
[ReadStatus.ABANDONED]: 'book.filter.readStatus.abandoned',
|
||||
[ReadStatus.UNSET]: 'book.filter.readStatus.unset'
|
||||
};
|
||||
|
||||
export const CONTENT_RATING_LABEL_KEYS: Readonly<Record<string, string>> = {
|
||||
'EVERYONE': 'book.filter.contentRating.everyone',
|
||||
'TEEN': 'book.filter.contentRating.teen',
|
||||
'MATURE': 'book.filter.contentRating.mature',
|
||||
'ADULT': 'book.filter.contentRating.adult',
|
||||
'EXPLICIT': 'book.filter.contentRating.explicit'
|
||||
};
|
||||
|
||||
export const SHELF_STATUS_LABEL_KEYS: Readonly<Record<string, string>> = {
|
||||
'shelved': 'book.filter.shelfStatus.shelved',
|
||||
'unshelved': 'book.filter.shelfStatus.unshelved'
|
||||
};
|
||||
|
||||
export const COMIC_ROLE_LABEL_KEYS: Readonly<Record<string, string>> = {
|
||||
penciller: 'book.filter.comicRoles.penciller',
|
||||
inker: 'book.filter.comicRoles.inker',
|
||||
colorist: 'book.filter.comicRoles.colorist',
|
||||
letterer: 'book.filter.comicRoles.letterer',
|
||||
coverArtist: 'book.filter.comicRoles.coverArtist',
|
||||
editor: 'book.filter.comicRoles.editor'
|
||||
};
|
||||
|
||||
export const FILTER_CONFIGS: Readonly<Record<Exclude<FilterType, 'library'>, Omit<FilterConfig, 'extractor'>>> = {
|
||||
author: {label: 'Author', sortMode: 'count'},
|
||||
category: {label: 'Genre', sortMode: 'count'},
|
||||
|
||||
+23
-23
@@ -55,29 +55,29 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
readonly allColumns = [
|
||||
{field: 'readStatus', header: '📖'},
|
||||
{field: 'title', header: 'Title'},
|
||||
{field: 'authors', header: 'Authors'},
|
||||
{field: 'publisher', header: 'Publisher'},
|
||||
{field: 'seriesName', header: 'Series'},
|
||||
{field: 'seriesNumber', header: 'Series #'},
|
||||
{field: 'categories', header: 'Genres'},
|
||||
{field: 'publishedDate', header: 'Published'},
|
||||
{field: 'lastReadTime', header: 'Last Read'},
|
||||
{field: 'addedOn', header: 'Added'},
|
||||
{field: 'fileName', header: 'File Name'},
|
||||
{field: 'fileSizeKb', header: 'File Size'},
|
||||
{field: 'language', header: 'Language'},
|
||||
{field: 'isbn', header: 'ISBN'},
|
||||
{field: 'pageCount', header: 'Pages'},
|
||||
{field: 'amazonRating', header: 'Amazon'},
|
||||
{field: 'amazonReviewCount', header: 'AZ #'},
|
||||
{field: 'goodreadsRating', header: 'Goodreads'},
|
||||
{field: 'goodreadsReviewCount', header: 'GR #'},
|
||||
{field: 'hardcoverRating', header: 'Hardcover'},
|
||||
{field: 'hardcoverReviewCount', header: 'HC #'},
|
||||
{field: 'ranobedbRating', header: 'Ranobedb'},
|
||||
readonly allColumns: { field: string; header: string }[] = [
|
||||
{field: 'readStatus', header: this.t.translate('book.columnPref.columns.readStatus')},
|
||||
{field: 'title', header: this.t.translate('book.columnPref.columns.title')},
|
||||
{field: 'authors', header: this.t.translate('book.columnPref.columns.authors')},
|
||||
{field: 'publisher', header: this.t.translate('book.columnPref.columns.publisher')},
|
||||
{field: 'seriesName', header: this.t.translate('book.columnPref.columns.seriesName')},
|
||||
{field: 'seriesNumber', header: this.t.translate('book.columnPref.columns.seriesNumber')},
|
||||
{field: 'categories', header: this.t.translate('book.columnPref.columns.categories')},
|
||||
{field: 'publishedDate', header: this.t.translate('book.columnPref.columns.publishedDate')},
|
||||
{field: 'lastReadTime', header: this.t.translate('book.columnPref.columns.lastReadTime')},
|
||||
{field: 'addedOn', header: this.t.translate('book.columnPref.columns.addedOn')},
|
||||
{field: 'fileName', header: this.t.translate('book.columnPref.columns.fileName')},
|
||||
{field: 'fileSizeKb', header: this.t.translate('book.columnPref.columns.fileSizeKb')},
|
||||
{field: 'language', header: this.t.translate('book.columnPref.columns.language')},
|
||||
{field: 'isbn', header: this.t.translate('book.columnPref.columns.isbn')},
|
||||
{field: 'pageCount', header: this.t.translate('book.columnPref.columns.pageCount')},
|
||||
{field: 'amazonRating', header: this.t.translate('book.columnPref.columns.amazonRating')},
|
||||
{field: 'amazonReviewCount', header: this.t.translate('book.columnPref.columns.amazonReviewCount')},
|
||||
{field: 'goodreadsRating', header: this.t.translate('book.columnPref.columns.goodreadsRating')},
|
||||
{field: 'goodreadsReviewCount', header: this.t.translate('book.columnPref.columns.goodreadsReviewCount')},
|
||||
{field: 'hardcoverRating', header: this.t.translate('book.columnPref.columns.hardcoverRating')},
|
||||
{field: 'hardcoverReviewCount', header: this.t.translate('book.columnPref.columns.hardcoverReviewCount')},
|
||||
{field: 'ranobedbRating', header: this.t.translate('book.columnPref.columns.ranobedbRating')},
|
||||
];
|
||||
|
||||
scrollHeight = 'calc(100dvh - 160px)';
|
||||
|
||||
@@ -1,41 +1,80 @@
|
||||
import {SortDirection, SortOption} from '../../../model/sort.model';
|
||||
import {CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
export const SORT_OPTION_LABEL_KEYS: Readonly<Record<string, string>> = {
|
||||
title: 'book.sorting.options.title',
|
||||
fileName: 'book.sorting.options.fileName',
|
||||
filePath: 'book.sorting.options.filePath',
|
||||
author: 'book.sorting.options.author',
|
||||
authorSurnameVorname: 'book.sorting.options.authorSurnameVorname',
|
||||
seriesName: 'book.sorting.options.seriesName',
|
||||
seriesNumber: 'book.sorting.options.seriesNumber',
|
||||
lastReadTime: 'book.sorting.options.lastReadTime',
|
||||
personalRating: 'book.sorting.options.personalRating',
|
||||
addedOn: 'book.sorting.options.addedOn',
|
||||
fileSizeKb: 'book.sorting.options.fileSizeKb',
|
||||
locked: 'book.sorting.options.locked',
|
||||
publisher: 'book.sorting.options.publisher',
|
||||
publishedDate: 'book.sorting.options.publishedDate',
|
||||
readStatus: 'book.sorting.options.readStatus',
|
||||
dateFinished: 'book.sorting.options.dateFinished',
|
||||
readingProgress: 'book.sorting.options.readingProgress',
|
||||
bookType: 'book.sorting.options.bookType',
|
||||
amazonRating: 'book.sorting.options.amazonRating',
|
||||
amazonReviewCount: 'book.sorting.options.amazonReviewCount',
|
||||
goodreadsRating: 'book.sorting.options.goodreadsRating',
|
||||
goodreadsReviewCount: 'book.sorting.options.goodreadsReviewCount',
|
||||
hardcoverRating: 'book.sorting.options.hardcoverRating',
|
||||
hardcoverReviewCount: 'book.sorting.options.hardcoverReviewCount',
|
||||
ranobedbRating: 'book.sorting.options.ranobedbRating',
|
||||
narrator: 'book.sorting.options.narrator',
|
||||
pageCount: 'book.sorting.options.pageCount',
|
||||
random: 'book.sorting.options.random'
|
||||
};
|
||||
|
||||
const SORT_FIELDS: { field: string; defaultLabel: string }[] = [
|
||||
{field: 'title', defaultLabel: 'Title'},
|
||||
{field: 'fileName', defaultLabel: 'File Name'},
|
||||
{field: 'filePath', defaultLabel: 'File Path'},
|
||||
{field: 'author', defaultLabel: 'Author'},
|
||||
{field: 'authorSurnameVorname', defaultLabel: 'Author (Surname)'},
|
||||
{field: 'seriesName', defaultLabel: 'Series Name'},
|
||||
{field: 'seriesNumber', defaultLabel: 'Series Number'},
|
||||
{field: 'lastReadTime', defaultLabel: 'Last Read'},
|
||||
{field: 'personalRating', defaultLabel: 'Personal Rating'},
|
||||
{field: 'addedOn', defaultLabel: 'Added On'},
|
||||
{field: 'fileSizeKb', defaultLabel: 'File Size'},
|
||||
{field: 'locked', defaultLabel: 'Locked'},
|
||||
{field: 'publisher', defaultLabel: 'Publisher'},
|
||||
{field: 'publishedDate', defaultLabel: 'Published Date'},
|
||||
{field: 'readStatus', defaultLabel: 'Read Status'},
|
||||
{field: 'dateFinished', defaultLabel: 'Date Finished'},
|
||||
{field: 'readingProgress', defaultLabel: 'Reading Progress'},
|
||||
{field: 'bookType', defaultLabel: 'Book Type'},
|
||||
{field: 'amazonRating', defaultLabel: 'Amazon Rating'},
|
||||
{field: 'amazonReviewCount', defaultLabel: 'Amazon #'},
|
||||
{field: 'goodreadsRating', defaultLabel: 'Goodreads Rating'},
|
||||
{field: 'goodreadsReviewCount', defaultLabel: 'Goodreads #'},
|
||||
{field: 'hardcoverRating', defaultLabel: 'Hardcover Rating'},
|
||||
{field: 'hardcoverReviewCount', defaultLabel: 'Hardcover #'},
|
||||
{field: 'ranobedbRating', defaultLabel: 'Ranobedb Rating'},
|
||||
{field: 'narrator', defaultLabel: 'Narrator'},
|
||||
{field: 'pageCount', defaultLabel: 'Pages'},
|
||||
{field: 'random', defaultLabel: 'Random'},
|
||||
];
|
||||
|
||||
export class BookSorter {
|
||||
selectedSortCriteria: SortOption[] = [];
|
||||
|
||||
sortOptions: SortOption[] = [
|
||||
{label: 'Title', field: 'title', direction: SortDirection.ASCENDING},
|
||||
{label: 'File Name', field: 'fileName', direction: SortDirection.ASCENDING},
|
||||
{label: 'File Path', field: 'filePath', direction: SortDirection.ASCENDING},
|
||||
{label: 'Author', field: 'author', direction: SortDirection.ASCENDING},
|
||||
{label: 'Author (Surname)', field: 'authorSurnameVorname', direction: SortDirection.ASCENDING},
|
||||
{label: 'Series Name', field: 'seriesName', direction: SortDirection.ASCENDING},
|
||||
{label: 'Series Number', field: 'seriesNumber', direction: SortDirection.ASCENDING},
|
||||
{label: 'Last Read', field: 'lastReadTime', direction: SortDirection.ASCENDING},
|
||||
{label: 'Personal Rating', field: 'personalRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Added On', field: 'addedOn', direction: SortDirection.ASCENDING},
|
||||
{label: 'File Size', field: 'fileSizeKb', direction: SortDirection.ASCENDING},
|
||||
{label: 'Locked', field: 'locked', direction: SortDirection.ASCENDING},
|
||||
{label: 'Publisher', field: 'publisher', direction: SortDirection.ASCENDING},
|
||||
{label: 'Published Date', field: 'publishedDate', direction: SortDirection.ASCENDING},
|
||||
{label: 'Read Status', field: 'readStatus', direction: SortDirection.ASCENDING},
|
||||
{label: 'Date Finished', field: 'dateFinished', direction: SortDirection.ASCENDING},
|
||||
{label: 'Reading Progress', field: 'readingProgress', direction: SortDirection.ASCENDING},
|
||||
{label: 'Book Type', field: 'bookType', direction: SortDirection.ASCENDING},
|
||||
{label: 'Amazon Rating', field: 'amazonRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Amazon #', field: 'amazonReviewCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Goodreads Rating', field: 'goodreadsRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Goodreads #', field: 'goodreadsReviewCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Ranobedb Rating', field: 'ranobedbRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Narrator', field: 'narrator', direction: SortDirection.ASCENDING},
|
||||
{label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Random', field: 'random', direction: SortDirection.ASCENDING},
|
||||
];
|
||||
sortOptions: SortOption[];
|
||||
|
||||
constructor(private onSortChange: (criteria: SortOption[]) => void) {
|
||||
constructor(private onSortChange: (criteria: SortOption[]) => void, translocoService?: TranslocoService) {
|
||||
this.sortOptions = SORT_FIELDS.map(({field, defaultLabel}) => {
|
||||
const key = SORT_OPTION_LABEL_KEYS[field];
|
||||
const label = key && translocoService ? translocoService.translate(key) : defaultLabel;
|
||||
return {label, field, direction: SortDirection.ASCENDING};
|
||||
});
|
||||
}
|
||||
|
||||
// For backward compatibility - get first sort option
|
||||
|
||||
@@ -443,8 +443,8 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
message: this.t.translate('book.browser.confirm.regenCoverMessage', {count}),
|
||||
header: this.t.translate('book.browser.confirm.regenCoverHeader'),
|
||||
icon: 'pi pi-image',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
acceptButtonProps: {
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
@@ -483,8 +483,8 @@ export class SeriesPageComponent implements OnDestroy {
|
||||
message: this.t.translate('book.browser.confirm.customCoverMessage', {count}),
|
||||
header: this.t.translate('book.browser.confirm.customCoverHeader'),
|
||||
icon: 'pi pi-palette',
|
||||
acceptLabel: 'Yes',
|
||||
rejectLabel: 'No',
|
||||
acceptLabel: this.t.translate('common.yes'),
|
||||
rejectLabel: this.t.translate('common.no'),
|
||||
acceptButtonProps: {
|
||||
label: this.t.translate('common.yes'),
|
||||
severity: 'success'
|
||||
|
||||
@@ -334,7 +334,7 @@ export class BookMenuService {
|
||||
|
||||
if (allShelfIds.size === 0) {
|
||||
this.loadingService.hide(loader);
|
||||
this.messageService.add({ severity: 'info', summary: 'Info', detail: this.t.translate('book.menuService.toast.noBooksOnShelvesDetail') });
|
||||
this.messageService.add({ severity: 'info', summary: this.t.translate('common.info'), detail: this.t.translate('book.menuService.toast.noBooksOnShelvesDetail') });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user