From 1b3e3da699237118b57753b128a7db5c004a78d7 Mon Sep 17 00:00:00 2001 From: ACX <8075870+acx10@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:50:12 -0700 Subject: [PATCH] Fix untranslatable UI strings, broken pluralization, and translation reactivity (#3108) (#3233) --- .../metadata-manager.component.html | 22 ++-- .../metadata-manager.component.ts | 31 +++--- ...ata-provider-field-selector.component.html | 6 +- ...adata-provider-field-selector.component.ts | 73 ++++--------- .../metadata-match-weights-component.html | 2 +- .../metadata-match-weights-component.ts | 42 +++----- .../sidebar-sorting-preferences.component.ts | 22 +++- .../view-preferences.component.ts | 102 +++++++++++------- .../github-support-dialog.html | 22 ++-- .../github-support-dialog.ts | 4 +- .../live-notification-box.component.ts | 21 +++- .../layout-topbar/app.topbar.component.ts | 6 ++ booklore-ui/src/i18n/en/metadata.json | 9 +- .../src/i18n/en/settings-metadata.json | 69 +++++++++++- booklore-ui/src/i18n/en/shared.json | 12 +++ booklore-ui/src/i18n/es/metadata.json | 9 +- .../src/i18n/es/settings-metadata.json | 63 ++++++++++- booklore-ui/src/i18n/es/shared.json | 12 +++ 18 files changed, 350 insertions(+), 177 deletions(-) diff --git a/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.html b/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.html index 432d6b80e..27928bffe 100644 --- a/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.html +++ b/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.html @@ -21,7 +21,7 @@ @for (tab of tabConfigs; track tab.type) { - {{ t(tab.labelKey).endsWith('s') ? t(tab.labelKey) : t(tab.labelKey) + 's' }} ({{ getMetadataItems(tab.type).length }}) + {{ t(tab.labelPluralKey) }} ({{ getMetadataItems(tab.type).length }}) } @@ -160,13 +160,13 @@
-

{{ t('mergeSplitDescription', { count: getSelectedItems(currentMergeType).length, type: currentMergeType }) }}

+

{{ t('mergeSplitDescription', { count: getSelectedItems(currentMergeType).length, type: getTypeLabel(currentMergeType, true) }) }}

@if (mergingInProgress) { @@ -219,7 +219,7 @@
@if (isSingleValueField(currentMergeType)) { - + } @else { - + } @if (mergingInProgress) { @@ -276,7 +276,7 @@
-

{{ t('deleteWarning', { count: currentDeleteItem ? 1 : getSelectedItems(currentMergeType).length, type: currentMergeType }) }}

+

{{ t('deleteWarning', { count: currentDeleteItem ? 1 : getSelectedItems(currentMergeType).length, type: getTypeLabel(currentMergeType, true) }) }}

@if (currentDeleteItem) { @@ -305,7 +305,7 @@

{{ t('whatWillHappen') }}

diff --git a/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.ts b/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.ts index b4ea22989..cae38d6ae 100644 --- a/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.ts +++ b/booklore-ui/src/app/features/metadata/component/metadata-manager/metadata-manager.component.ts @@ -33,6 +33,7 @@ type MetadataType = 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'pu interface TabConfig { type: MetadataType; labelKey: string; + labelPluralKey: string; placeholderKey: string; selectAllKey: 'selectAllAuthors' | 'selectAllCategories' | 'selectAllMoods' | 'selectAllTags' | 'selectAllSeries' | 'selectAllPublishers' | 'selectAllLanguages'; icon: string; @@ -125,13 +126,13 @@ export class MetadataManagerComponent implements OnInit, OnDestroy { } tabConfigs: TabConfig[] = [ - {type: 'authors', labelKey: 'tabs.author', placeholderKey: 'placeholders.searchAuthors', selectAllKey: 'selectAllAuthors', icon: 'pi-user'}, - {type: 'categories', labelKey: 'tabs.genre', placeholderKey: 'placeholders.searchGenres', selectAllKey: 'selectAllCategories', icon: 'pi-tag'}, - {type: 'moods', labelKey: 'tabs.mood', placeholderKey: 'placeholders.searchMoods', selectAllKey: 'selectAllMoods', icon: 'pi-heart'}, - {type: 'tags', labelKey: 'tabs.tag', placeholderKey: 'placeholders.searchTags', selectAllKey: 'selectAllTags', icon: 'pi-tags'}, - {type: 'series', labelKey: 'tabs.series', placeholderKey: 'placeholders.searchSeries', selectAllKey: 'selectAllSeries', icon: 'pi-book'}, - {type: 'publishers', labelKey: 'tabs.publisher', placeholderKey: 'placeholders.searchPublishers', selectAllKey: 'selectAllPublishers', icon: 'pi-building'}, - {type: 'languages', labelKey: 'tabs.language', placeholderKey: 'placeholders.searchLanguages', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'} + {type: 'authors', labelKey: 'tabs.author', labelPluralKey: 'tabs.authors', placeholderKey: 'placeholders.searchAuthors', selectAllKey: 'selectAllAuthors', icon: 'pi-user'}, + {type: 'categories', labelKey: 'tabs.genre', labelPluralKey: 'tabs.genres', placeholderKey: 'placeholders.searchGenres', selectAllKey: 'selectAllCategories', icon: 'pi-tag'}, + {type: 'moods', labelKey: 'tabs.mood', labelPluralKey: 'tabs.moods', placeholderKey: 'placeholders.searchMoods', selectAllKey: 'selectAllMoods', icon: 'pi-heart'}, + {type: 'tags', labelKey: 'tabs.tag', labelPluralKey: 'tabs.tags', placeholderKey: 'placeholders.searchTags', selectAllKey: 'selectAllTags', icon: 'pi-tags'}, + {type: 'series', labelKey: 'tabs.series', labelPluralKey: 'tabs.seriesPlural', placeholderKey: 'placeholders.searchSeries', selectAllKey: 'selectAllSeries', icon: 'pi-book'}, + {type: 'publishers', labelKey: 'tabs.publisher', labelPluralKey: 'tabs.publishers', placeholderKey: 'placeholders.searchPublishers', selectAllKey: 'selectAllPublishers', icon: 'pi-building'}, + {type: 'languages', labelKey: 'tabs.language', labelPluralKey: 'tabs.languages', placeholderKey: 'placeholders.searchLanguages', selectAllKey: 'selectAllLanguages', icon: 'pi-globe'} ]; ngOnInit() { @@ -303,7 +304,7 @@ export class MetadataManagerComponent implements OnInit, OnDestroy { this.messageService.add({ severity: 'warn', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'), - detail: this.t.translate('metadata.manager.toast.singleValueOnly', {singular: this.currentMergeType.slice(0, -1)}) + detail: this.t.translate('metadata.manager.toast.singleValueOnly', {singular: this.getTypeLabel(this.currentMergeType, false)}) }); return; } @@ -389,7 +390,7 @@ export class MetadataManagerComponent implements OnInit, OnDestroy { this.messageService.add({ severity: 'warn', summary: this.t.translate('metadata.manager.toast.invalidTargetSummary'), - detail: this.t.translate('metadata.manager.toast.singleMergeValueOnly', {singular: this.currentMergeType.slice(0, -1)}) + detail: this.t.translate('metadata.manager.toast.singleMergeValueOnly', {singular: this.getTypeLabel(this.currentMergeType, false)}) }); return; } @@ -413,8 +414,8 @@ export class MetadataManagerComponent implements OnInit, OnDestroy { ? this.t.translate('metadata.manager.toast.mergeSuccessfulSummary') : this.t.translate('metadata.manager.toast.mergeSplitSuccessfulSummary'), detail: operation === 'merge' - ? this.t.translate('metadata.manager.toast.mergeSuccessfulDetail', {selectedCount: selected.length, type: this.currentMergeType, targetCount: targetValues.length, bookCount: affectedBooks}) - : this.t.translate('metadata.manager.toast.mergeSplitSuccessfulDetail', {selectedCount: selected.length, type: this.currentMergeType, targetCount: targetValues.length, bookCount: affectedBooks}), + ? this.t.translate('metadata.manager.toast.mergeSuccessfulDetail', {selectedCount: selected.length, type: this.getTypeLabel(this.currentMergeType, true), targetCount: targetValues.length, bookCount: affectedBooks}) + : this.t.translate('metadata.manager.toast.mergeSplitSuccessfulDetail', {selectedCount: selected.length, type: this.getTypeLabel(this.currentMergeType, true), targetCount: targetValues.length, bookCount: affectedBooks}), life: 5000 }); this.showMergeDialog = false; @@ -470,7 +471,7 @@ export class MetadataManagerComponent implements OnInit, OnDestroy { this.messageService.add({ severity: 'success', summary: this.t.translate('metadata.manager.toast.deleteSuccessfulSummary'), - detail: this.t.translate('metadata.manager.toast.deleteSuccessfulDetail', {count: itemCount, type: this.currentMergeType.slice(0, -1) + (itemCount > 1 ? 's' : ''), bookCount: affectedBooks}), + detail: this.t.translate('metadata.manager.toast.deleteSuccessfulDetail', {count: itemCount, type: itemCount > 1 ? this.getTypeLabel(this.currentMergeType, true) : this.getTypeLabel(this.currentMergeType, false), bookCount: affectedBooks}), life: 5000 }); this.showDeleteDialog = false; @@ -611,6 +612,12 @@ export class MetadataManagerComponent implements OnInit, OnDestroy { }); } + protected getTypeLabel(type: MetadataType, plural: boolean): string { + const tab = this.tabConfigs.find(tc => tc.type === type); + if (!tab) return type; + return this.t.translate('metadata.manager.' + (plural ? tab.labelPluralKey : tab.labelKey)); + } + protected isSingleValueField(type: MetadataType): boolean { return type === 'series' || type === 'publishers' || type === 'languages'; } diff --git a/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.html b/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.html index 41f2d1961..b87fa8a7c 100644 --- a/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.html +++ b/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.html @@ -12,11 +12,11 @@
- @for (group of providerGroups; track group.label) { + @for (group of providerGroups; track group.labelKey) {
-

{{ group.label }}

+

{{ getProviderLabel(group.labelKey) }}

@for (field of group.fields; track field) { @@ -26,7 +26,7 @@ [ngModel]="selectedFields.includes(field)" (ngModelChange)="toggleField(field, $event)"> - +
}
diff --git a/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.ts b/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.ts index d8678c248..b715cc624 100644 --- a/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.ts +++ b/booklore-ui/src/app/features/metadata/component/metadata-provider-field-selector/metadata-provider-field-selector.component.ts @@ -4,7 +4,7 @@ import {FormsModule} from '@angular/forms'; import {AppSettingsService} from '../../../../shared/service/app-settings.service'; import {AppSettingKey, MetadataProviderSpecificFields} from '../../../../shared/model/app-settings.model'; import {filter, take} from 'rxjs/operators'; -import {TranslocoDirective} from '@jsverse/transloco'; +import {TranslocoDirective, TranslocoService} from '@jsverse/transloco'; @Component({ selector: 'app-metadata-provider-field-selector', @@ -17,63 +17,26 @@ export class MetadataProviderFieldSelectorComponent implements OnInit { @Input() selectedFields: string[] = []; private appSettingsService = inject(AppSettingsService); + private t = inject(TranslocoService); - providerGroups: { label: string, fields: string[] }[] = [ - { - label: 'Amazon', - fields: ['asin', 'amazonRating', 'amazonReviewCount'] - }, - { - label: 'Google Books', - fields: ['googleId'] - }, - { - label: 'Goodreads', - fields: ['goodreadsId', 'goodreadsRating', 'goodreadsReviewCount'] - }, - { - label: 'Hardcover', - fields: ['hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount'] - }, - { - label: 'Audible', - fields: ['audibleId', 'audibleRating', 'audibleReviewCount'] - }, - { - label: 'Comicvine', - fields: ['comicvineId'] - }, - { - label: 'Lubimyczytac', - fields: ['lubimyczytacId', 'lubimyczytacRating'] - }, - { - label: 'Ranobedb', - fields: ['ranobedbId', 'ranobedbRating'] - } + providerGroups: { labelKey: string, fields: string[] }[] = [ + {labelKey: 'amazon', fields: ['asin', 'amazonRating', 'amazonReviewCount']}, + {labelKey: 'googleBooks', fields: ['googleId']}, + {labelKey: 'goodreads', fields: ['goodreadsId', 'goodreadsRating', 'goodreadsReviewCount']}, + {labelKey: 'hardcover', fields: ['hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount']}, + {labelKey: 'audible', fields: ['audibleId', 'audibleRating', 'audibleReviewCount']}, + {labelKey: 'comicvine', fields: ['comicvineId']}, + {labelKey: 'lubimyczytac', fields: ['lubimyczytacId', 'lubimyczytacRating']}, + {labelKey: 'ranobedb', fields: ['ranobedbId', 'ranobedbRating']} ]; - fieldLabels: Record = { - 'asin': 'Amazon ASIN', - 'amazonRating': 'Amazon Rating', - 'amazonReviewCount': 'Amazon Review Count', - 'googleId': 'Google Books ID', - 'goodreadsId': 'Goodreads ID', - 'goodreadsRating': 'Goodreads Rating', - 'goodreadsReviewCount': 'Goodreads Review Count', - 'hardcoverId': 'Hardcover ID', - 'hardcoverBookId': 'Hardcover Book ID', - 'hardcoverRating': 'Hardcover Rating', - 'hardcoverReviewCount': 'Hardcover Review Count', - 'comicvineId': 'Comicvine ID', - 'lubimyczytacId': 'Lubimyczytac ID', - 'lubimyczytacRating': 'Lubimyczytac Rating', - 'ranobedbId': 'Ranobedb ID', - 'ranobedbRating': 'Ranobedb Rating', - 'audibleId': 'Audible ID', - 'audibleRating': 'Audible Rating', - 'audibleReviewCount': 'Audible Review Count', - }; + getProviderLabel(key: string): string { + return this.t.translate('settingsMeta.fieldSelector.providers.' + key); + } + + getFieldLabel(field: string): string { + return this.t.translate('settingsMeta.fieldSelector.fields.' + field); + } private readonly allFieldNames: (keyof MetadataProviderSpecificFields)[] = [ 'asin', 'amazonRating', 'amazonReviewCount', diff --git a/booklore-ui/src/app/features/settings/global-preferences/metadata-match-weights/metadata-match-weights-component.html b/booklore-ui/src/app/features/settings/global-preferences/metadata-match-weights/metadata-match-weights-component.html index c27c6d292..362c69d29 100644 --- a/booklore-ui/src/app/features/settings/global-preferences/metadata-match-weights/metadata-match-weights-component.html +++ b/booklore-ui/src/app/features/settings/global-preferences/metadata-match-weights/metadata-match-weights-component.html @@ -38,7 +38,7 @@
@for (key of orderedKeys; track key) {
- + = { - title: 'Title', - subtitle: 'Subtitle', - authors: 'Authors', - description: 'Description', - publisher: 'Publisher', - publishedDate: 'Published Date', - categories: 'Categories', - coverImage: 'Cover Image', - seriesName: 'Series Name', - seriesNumber: 'Series Number', - seriesTotal: 'Series Total', - language: 'Language', - isbn13: 'ISBN-13', - isbn10: 'ISBN-10', - pageCount: 'Page Count', - amazonRating: 'Amazon Rating', - amazonReviewCount: 'Amazon Rating #', - goodreadsRating: 'Goodreads Rating', - goodreadsReviewCount: 'Goodreads Rating #', - hardcoverRating: 'Hardcover Rating', - hardcoverReviewCount: 'Hardcover Rating #', - audibleRating: 'Audible Rating', - audibleReviewCount: 'Audible Rating #', - doubanRating: 'Douban Rating', - doubanReviewCount: 'Douban Rating #', - ranobedbRating: 'Ranobedb Rating', - }; + readonly orderedFieldKeys: string[] = [ + 'title', 'subtitle', 'authors', 'description', 'publisher', 'publishedDate', + 'categories', 'coverImage', 'seriesName', 'seriesNumber', 'seriesTotal', + 'language', 'isbn13', 'isbn10', 'pageCount', + 'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount', + 'hardcoverRating', 'hardcoverReviewCount', 'audibleRating', 'audibleReviewCount', + 'doubanRating', 'doubanReviewCount', 'ranobedbRating' + ]; form!: FormGroup; isSaving = false; @@ -103,7 +83,11 @@ export class MetadataMatchWeightsComponent implements OnInit { } get orderedKeys(): string[] { - return Object.keys(this.labelMap); + return this.orderedFieldKeys; + } + + getFieldLabel(key: string): string { + return this.t.translate('settingsMeta.matchWeights.fields.' + key); } save(): void { diff --git a/booklore-ui/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts b/booklore-ui/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts index d8c68d4c5..b82021b2c 100644 --- a/booklore-ui/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts +++ b/booklore-ui/src/app/features/settings/view-preferences-parent/sidebar-sorting-preferences/sidebar-sorting-preferences.component.ts @@ -19,13 +19,15 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco'; }) export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy { - readonly sortingOptions = [ - {label: 'Name | Ascending', value: {field: 'name', order: 'asc'}, translationKey: 'nameAsc'}, - {label: 'Name | Descending', value: {field: 'name', order: 'desc'}, translationKey: 'nameDesc'}, - {label: 'Creation Date | Ascending', value: {field: 'id', order: 'asc'}, translationKey: 'creationAsc'}, - {label: 'Creation Date | Descending', value: {field: 'id', order: 'desc'}, translationKey: 'creationDesc'}, + private readonly sortingOptionDefs = [ + {value: {field: 'name', order: 'asc'}, translationKey: 'nameAsc'}, + {value: {field: 'name', order: 'desc'}, translationKey: 'nameDesc'}, + {value: {field: 'id', order: 'asc'}, translationKey: 'creationAsc'}, + {value: {field: 'id', order: 'desc'}, translationKey: 'creationDesc'}, ]; + sortingOptions: {label: string; value: {field: string; order: string}; translationKey: string}[] = []; + selectedLibrarySorting: SidebarLibrarySorting = {field: 'id', order: 'asc'}; selectedShelfSorting: SidebarShelfSorting = {field: 'id', order: 'asc'}; selectedMagicShelfSorting: SidebarMagicShelfSorting = {field: 'id', order: 'asc'}; @@ -39,6 +41,9 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy { private currentUser: User | null = null; ngOnInit(): void { + this.buildSortingOptions(); + this.t.langChanges$.pipe(takeUntil(this.destroy$)).subscribe(() => this.buildSortingOptions()); + this.userData$.pipe( filter(userState => !!userState?.user && userState.loaded), takeUntil(this.destroy$) @@ -53,6 +58,13 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy { this.destroy$.complete(); } + private buildSortingOptions(): void { + this.sortingOptions = this.sortingOptionDefs.map(opt => ({ + ...opt, + label: this.t.translate('settingsView.sidebarSort.' + opt.translationKey) + })); + } + private loadPreferences(settings: UserSettings): void { this.selectedLibrarySorting = settings.sidebarLibrarySorting; this.selectedShelfSorting = settings.sidebarShelfSorting; diff --git a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts index 1971c9e3e..100fe6d8f 100644 --- a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts +++ b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts @@ -44,47 +44,42 @@ import {CdkDrag, CdkDragDrop, CdkDragHandle, CdkDropList, moveItemInArray} from export class ViewPreferencesComponent implements OnInit, OnDestroy { private t = inject(TranslocoService); - sortOptions: {label: string; field: string; translationKey: string}[] = [ - {label: 'Title', field: 'title', translationKey: 'sortTitle'}, - {label: 'File Name', field: 'fileName', translationKey: 'sortFileName'}, - {label: 'File Path', field: 'filePath', translationKey: 'sortFilePath'}, - {label: 'Author', field: 'author', translationKey: 'sortAuthor'}, - {label: 'Author (Surname)', field: 'authorSurnameVorname', translationKey: 'sortAuthorSurname'}, - {label: 'Series Name', field: 'seriesName', translationKey: 'sortSeriesName'}, - {label: 'Series Number', field: 'seriesNumber', translationKey: 'sortSeriesNumber'}, - {label: 'Last Read', field: 'lastReadTime', translationKey: 'sortLastRead'}, - {label: 'Personal Rating', field: 'personalRating', translationKey: 'sortPersonalRating'}, - {label: 'Added On', field: 'addedOn', translationKey: 'sortAddedOn'}, - {label: 'File Size', field: 'fileSizeKb', translationKey: 'sortFileSize'}, - {label: 'Locked', field: 'locked', translationKey: 'sortLocked'}, - {label: 'Publisher', field: 'publisher', translationKey: 'sortPublisher'}, - {label: 'Published Date', field: 'publishedDate', translationKey: 'sortPublishedDate'}, - {label: 'Read Status', field: 'readStatus', translationKey: 'sortReadStatus'}, - {label: 'Date Finished', field: 'dateFinished', translationKey: 'sortDateFinished'}, - {label: 'Reading Progress', field: 'readingProgress', translationKey: 'sortReadingProgress'}, - {label: 'Book Type', field: 'bookType', translationKey: 'sortBookType'}, - {label: 'Amazon Rating', field: 'amazonRating', translationKey: 'sortAmazonRating'}, - {label: 'Amazon #', field: 'amazonReviewCount', translationKey: 'sortAmazonCount'}, - {label: 'Goodreads Rating', field: 'goodreadsRating', translationKey: 'sortGoodreadsRating'}, - {label: 'Goodreads #', field: 'goodreadsReviewCount', translationKey: 'sortGoodreadsCount'}, - {label: 'Hardcover Rating', field: 'hardcoverRating', translationKey: 'sortHardcoverRating'}, - {label: 'Hardcover #', field: 'hardcoverReviewCount', translationKey: 'sortHardcoverCount'}, - {label: 'Ranobedb Rating', field: 'ranobedbRating', translationKey: 'sortRanobedbRating'}, - {label: 'Narrator', field: 'narrator', translationKey: 'sortNarrator'}, - {label: 'Pages', field: 'pageCount', translationKey: 'sortPages'}, - {label: 'Random', field: 'random', translationKey: 'sortRandom'}, + private readonly sortOptionDefs: {field: string; translationKey: string}[] = [ + {field: 'title', translationKey: 'sortTitle'}, + {field: 'fileName', translationKey: 'sortFileName'}, + {field: 'filePath', translationKey: 'sortFilePath'}, + {field: 'author', translationKey: 'sortAuthor'}, + {field: 'authorSurnameVorname', translationKey: 'sortAuthorSurname'}, + {field: 'seriesName', translationKey: 'sortSeriesName'}, + {field: 'seriesNumber', translationKey: 'sortSeriesNumber'}, + {field: 'lastReadTime', translationKey: 'sortLastRead'}, + {field: 'personalRating', translationKey: 'sortPersonalRating'}, + {field: 'addedOn', translationKey: 'sortAddedOn'}, + {field: 'fileSizeKb', translationKey: 'sortFileSize'}, + {field: 'locked', translationKey: 'sortLocked'}, + {field: 'publisher', translationKey: 'sortPublisher'}, + {field: 'publishedDate', translationKey: 'sortPublishedDate'}, + {field: 'readStatus', translationKey: 'sortReadStatus'}, + {field: 'dateFinished', translationKey: 'sortDateFinished'}, + {field: 'readingProgress', translationKey: 'sortReadingProgress'}, + {field: 'bookType', translationKey: 'sortBookType'}, + {field: 'amazonRating', translationKey: 'sortAmazonRating'}, + {field: 'amazonReviewCount', translationKey: 'sortAmazonCount'}, + {field: 'goodreadsRating', translationKey: 'sortGoodreadsRating'}, + {field: 'goodreadsReviewCount', translationKey: 'sortGoodreadsCount'}, + {field: 'hardcoverRating', translationKey: 'sortHardcoverRating'}, + {field: 'hardcoverReviewCount', translationKey: 'sortHardcoverCount'}, + {field: 'ranobedbRating', translationKey: 'sortRanobedbRating'}, + {field: 'narrator', translationKey: 'sortNarrator'}, + {field: 'pageCount', translationKey: 'sortPages'}, + {field: 'random', translationKey: 'sortRandom'}, ]; - entityTypeOptions: {label: string; value: string; translationKey: string}[] = [ - {label: 'Library', value: 'LIBRARY', translationKey: 'entityLibrary'}, - {label: 'Shelf', value: 'SHELF', translationKey: 'entityShelf'}, - {label: 'Magic Shelf', value: 'MAGIC_SHELF', translationKey: 'entityMagicShelf'} - ]; + sortOptions: {label: string; field: string; translationKey: string}[] = []; - viewModeOptions: {label: string; value: string; translationKey: string}[] = [ - {label: 'Grid', value: 'GRID', translationKey: 'viewGrid'}, - {label: 'Table', value: 'TABLE', translationKey: 'viewTable'} - ]; + entityTypeOptions: {label: string; value: string; translationKey: string}[] = []; + + viewModeOptions: {label: string; value: string; translationKey: string}[] = []; libraryOptions: { label: string; value: number }[] = []; shelfOptions: { label: string; value: number }[] = []; @@ -128,6 +123,20 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy { private messageService = inject(MessageService); ngOnInit(): void { + this.rebuildTranslatedLabels(); + this.t.langChanges$.pipe(takeUntil(this.destroy$)).subscribe(() => { + this.rebuildTranslatedLabels(); + this.allSortAsOptions = this.sortOptions.map(o => ({ + label: this.t.translate('settingsView.librarySort.' + o.translationKey), + field: o.field, + direction: SortDirection.ASCENDING + })); + this.globalSortAsOptions = this.toSortOptions(this.sortCriteria); + this.overrides.forEach(o => { + o.sortCriteriaAsOptions = this.toSortOptions(o.sortCriteria); + }); + }); + combineLatest([ this.userService.userState$.pipe(filter(userState => !!userState?.user && userState.loaded), take(1)), this.libraryService.libraryState$.pipe(filter(libraryState => !!libraryState?.libraries && libraryState.loaded), take(1)), @@ -196,6 +205,23 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy { }); } + private rebuildTranslatedLabels(): void { + this.sortOptions = this.sortOptionDefs.map(o => ({ + label: this.t.translate('settingsView.librarySort.' + o.translationKey), + field: o.field, + translationKey: o.translationKey + })); + this.entityTypeOptions = [ + {label: this.t.translate('settingsView.librarySort.entityLibrary'), value: 'LIBRARY', translationKey: 'entityLibrary'}, + {label: this.t.translate('settingsView.librarySort.entityShelf'), value: 'SHELF', translationKey: 'entityShelf'}, + {label: this.t.translate('settingsView.librarySort.entityMagicShelf'), value: 'MAGIC_SHELF', translationKey: 'entityMagicShelf'} + ]; + this.viewModeOptions = [ + {label: this.t.translate('settingsView.librarySort.viewGrid'), value: 'GRID', translationKey: 'viewGrid'}, + {label: this.t.translate('settingsView.librarySort.viewTable'), value: 'TABLE', translationKey: 'viewTable'} + ]; + } + ngOnDestroy(): void { this.destroy$.next(); this.destroy$.complete(); diff --git a/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.html b/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.html index 1a56dbc59..d9a55631f 100644 --- a/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.html +++ b/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.html @@ -1,11 +1,12 @@ +
-

Support BookLore

-

From a solo dev who loves books

+

{{ t('title') }}

+

{{ t('subtitle') }}

- BookLore is built and maintained by a single developer who genuinely loves books. If it's made organizing your library a little more enjoyable, here are a few ways to support the project and keep it going. + {{ t('intro') }}

-

Thank you for being part of the BookLore community.

+

{{ t('closing') }}

+
diff --git a/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.ts b/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.ts index ffaef3b4a..8aed494fd 100644 --- a/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.ts +++ b/booklore-ui/src/app/shared/components/github-support-dialog/github-support-dialog.ts @@ -1,11 +1,13 @@ import {Component, inject} from '@angular/core'; import {Button} from 'primeng/button'; import {DynamicDialogRef} from 'primeng/dynamicdialog'; +import {TranslocoDirective} from '@jsverse/transloco'; @Component({ selector: 'app-github-support-dialog', imports: [ - Button + Button, + TranslocoDirective ], templateUrl: './github-support-dialog.html', styleUrls: ['./github-support-dialog.scss'] diff --git a/booklore-ui/src/app/shared/components/live-notification-box/live-notification-box.component.ts b/booklore-ui/src/app/shared/components/live-notification-box/live-notification-box.component.ts index 65f233eb2..3e111e71e 100644 --- a/booklore-ui/src/app/shared/components/live-notification-box/live-notification-box.component.ts +++ b/booklore-ui/src/app/shared/components/live-notification-box/live-notification-box.component.ts @@ -1,8 +1,10 @@ -import {Component, inject} from '@angular/core'; +import {Component, inject, OnDestroy} from '@angular/core'; import {NotificationEventService} from '../../websocket/notification-event.service'; import {LogNotification} from '../../websocket/model/log-notification.model'; import {Tag} from 'primeng/tag'; import {TranslocoService} from '@jsverse/transloco'; +import {Subject} from 'rxjs'; +import {takeUntil} from 'rxjs/operators'; import {TagComponent} from '../tag/tag.component'; @@ -18,16 +20,29 @@ import {TagComponent} from '../tag/tag.component'; TagComponent ] }) -export class LiveNotificationBoxComponent { +export class LiveNotificationBoxComponent implements OnDestroy { private readonly t = inject(TranslocoService); + private readonly destroy$ = new Subject(); latestNotification: LogNotification = {message: this.t.translate('shared.liveNotification.defaultMessage')}; + private hasReceivedNotification = false; private notificationService = inject(NotificationEventService); constructor() { - this.notificationService.latestNotification$.subscribe(notification => { + this.notificationService.latestNotification$.pipe(takeUntil(this.destroy$)).subscribe(notification => { + this.hasReceivedNotification = true; this.latestNotification = notification; }); + this.t.langChanges$.pipe(takeUntil(this.destroy$)).subscribe(() => { + if (!this.hasReceivedNotification) { + this.latestNotification = {message: this.t.translate('shared.liveNotification.defaultMessage')}; + } + }); + } + + ngOnDestroy(): void { + this.destroy$.next(); + this.destroy$.complete(); } getSeverityColor(severity?: string): 'red' | 'amber' | 'green' | 'gray' { diff --git a/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts b/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts index 66b543aa3..c66b42cf8 100644 --- a/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts +++ b/booklore-ui/src/app/shared/layout/component/layout-topbar/app.topbar.component.ts @@ -132,6 +132,12 @@ export class AppTopBarComponent implements OnDestroy { .subscribe(() => { this.initializeStatsMenu(); }); + + this.translocoService.langChanges$ + .pipe(takeUntil(this.destroy$)) + .subscribe(() => { + this.initializeStatsMenu(); + }); } ngOnDestroy(): void { diff --git a/booklore-ui/src/i18n/en/metadata.json b/booklore-ui/src/i18n/en/metadata.json index e62bb66e9..d0bdfb607 100644 --- a/booklore-ui/src/i18n/en/metadata.json +++ b/booklore-ui/src/i18n/en/metadata.json @@ -498,12 +498,19 @@ "deleting": "Deleting...", "tabs": { "author": "Author", + "authors": "Authors", "genre": "Genre", + "genres": "Genres", "mood": "Mood", + "moods": "Moods", "tag": "Tag", + "tags": "Tags", "series": "Series", + "seriesPlural": "Series", "publisher": "Publisher", - "language": "Language" + "publishers": "Publishers", + "language": "Language", + "languages": "Languages" }, "placeholders": { "searchAuthors": "Search authors...", diff --git a/booklore-ui/src/i18n/en/settings-metadata.json b/booklore-ui/src/i18n/en/settings-metadata.json index 9a0d069dd..4082c8d28 100644 --- a/booklore-ui/src/i18n/en/settings-metadata.json +++ b/booklore-ui/src/i18n/en/settings-metadata.json @@ -63,10 +63,6 @@ "hardcoverPlaceholder": "Enter Hardcover API token", "comicvinePlaceholder": "Enter Comic Vine API token" }, - "fieldSelector": { - "sectionTitle": "Enabled Fields in Metadata Editor & Picker", - "sectionDesc": "Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface." - }, "publicReviews": { "sectionTitle": "Public Reviews", "sectionDesc": "Configure automatic downloading of user reviews from external platforms. Reviews can be fetched from Amazon, Goodreads, and Hardcover for offline access.", @@ -91,6 +87,69 @@ "saveSuccess": "Weights saved successfully", "saveError": "Failed to save weights", "recalcSuccess": "All book match scores were recalculated successfully.", - "recalcError": "Failed to recalculate match scores." + "recalcError": "Failed to recalculate match scores.", + "fields": { + "title": "Title", + "subtitle": "Subtitle", + "authors": "Authors", + "description": "Description", + "publisher": "Publisher", + "publishedDate": "Published Date", + "categories": "Categories", + "coverImage": "Cover Image", + "seriesName": "Series Name", + "seriesNumber": "Series Number", + "seriesTotal": "Series Total", + "language": "Language", + "isbn13": "ISBN-13", + "isbn10": "ISBN-10", + "pageCount": "Page Count", + "amazonRating": "Amazon Rating", + "amazonReviewCount": "Amazon Rating #", + "goodreadsRating": "Goodreads Rating", + "goodreadsReviewCount": "Goodreads Rating #", + "hardcoverRating": "Hardcover Rating", + "hardcoverReviewCount": "Hardcover Rating #", + "audibleRating": "Audible Rating", + "audibleReviewCount": "Audible Rating #", + "doubanRating": "Douban Rating", + "doubanReviewCount": "Douban Rating #", + "ranobedbRating": "Ranobedb Rating" + } + }, + "fieldSelector": { + "sectionTitle": "Enabled Fields in Metadata Editor & Picker", + "sectionDesc": "Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface.", + "providers": { + "amazon": "Amazon", + "googleBooks": "Google Books", + "goodreads": "Goodreads", + "hardcover": "Hardcover", + "audible": "Audible", + "comicvine": "Comicvine", + "lubimyczytac": "Lubimyczytac", + "ranobedb": "Ranobedb" + }, + "fields": { + "asin": "Amazon ASIN", + "amazonRating": "Amazon Rating", + "amazonReviewCount": "Amazon Review Count", + "googleId": "Google Books ID", + "goodreadsId": "Goodreads ID", + "goodreadsRating": "Goodreads Rating", + "goodreadsReviewCount": "Goodreads Review Count", + "hardcoverId": "Hardcover ID", + "hardcoverBookId": "Hardcover Book ID", + "hardcoverRating": "Hardcover Rating", + "hardcoverReviewCount": "Hardcover Review Count", + "comicvineId": "Comicvine ID", + "lubimyczytacId": "Lubimyczytac ID", + "lubimyczytacRating": "Lubimyczytac Rating", + "ranobedbId": "Ranobedb ID", + "ranobedbRating": "Ranobedb Rating", + "audibleId": "Audible ID", + "audibleRating": "Audible Rating", + "audibleReviewCount": "Audible Review Count" + } } } diff --git a/booklore-ui/src/i18n/en/shared.json b/booklore-ui/src/i18n/en/shared.json index 6fe9c4328..b295524e3 100644 --- a/booklore-ui/src/i18n/en/shared.json +++ b/booklore-ui/src/i18n/en/shared.json @@ -92,6 +92,18 @@ "liveNotification": { "defaultMessage": "No recent notifications..." }, + "supportDialog": { + "title": "Support BookLore", + "subtitle": "From a solo dev who loves books", + "intro": "BookLore is built and maintained by a single developer who genuinely loves books. If it's made organizing your library a little more enjoyable, here are a few ways to support the project and keep it going.", + "starTitle": "Star on GitHub", + "starDesc": "A star goes a long way. It helps new people find BookLore and keeps me motivated.", + "collectiveTitle": "Open Collective", + "collectiveDesc": "Recurring support that helps cover hosting and keeps development sustainable.", + "kofiTitle": "Buy me a coffee", + "kofiDesc": "A one-time tip to fuel late-night coding sessions. Every bit is appreciated!", + "closing": "Thank you for being part of the BookLore community." + }, "metadataProgress": { "taskStalled": "Task stalled or backend unavailable", "taskCancelled": "Task cancelled by user", diff --git a/booklore-ui/src/i18n/es/metadata.json b/booklore-ui/src/i18n/es/metadata.json index 54eab9356..11d6bfceb 100644 --- a/booklore-ui/src/i18n/es/metadata.json +++ b/booklore-ui/src/i18n/es/metadata.json @@ -498,12 +498,19 @@ "deleting": "Eliminando...", "tabs": { "author": "Autor", + "authors": "Autores", "genre": "Género", + "genres": "Géneros", "mood": "Estado de ánimo", + "moods": "Estados de ánimo", "tag": "Etiqueta", + "tags": "Etiquetas", "series": "Serie", + "seriesPlural": "Series", "publisher": "Editorial", - "language": "Idioma" + "publishers": "Editoriales", + "language": "Idioma", + "languages": "Idiomas" }, "placeholders": { "searchAuthors": "Buscar autores...", diff --git a/booklore-ui/src/i18n/es/settings-metadata.json b/booklore-ui/src/i18n/es/settings-metadata.json index 538fac282..5aafb9744 100644 --- a/booklore-ui/src/i18n/es/settings-metadata.json +++ b/booklore-ui/src/i18n/es/settings-metadata.json @@ -65,7 +65,38 @@ }, "fieldSelector": { "sectionTitle": "Campos habilitados en el editor y selector de metadatos", - "sectionDesc": "Selecciona qué campos de metadatos mostrar al editar información del libro o seleccionar metadatos de proveedores. Los campos deshabilitados se ocultarán de la interfaz." + "sectionDesc": "Selecciona qué campos de metadatos mostrar al editar información del libro o seleccionar metadatos de proveedores. Los campos deshabilitados se ocultarán de la interfaz.", + "providers": { + "amazon": "Amazon", + "googleBooks": "Google Books", + "goodreads": "Goodreads", + "hardcover": "Hardcover", + "audible": "Audible", + "comicvine": "Comicvine", + "lubimyczytac": "Lubimyczytac", + "ranobedb": "Ranobedb" + }, + "fields": { + "asin": "Amazon ASIN", + "amazonRating": "Valoración de Amazon", + "amazonReviewCount": "Reseñas de Amazon", + "googleId": "ID de Google Books", + "goodreadsId": "ID de Goodreads", + "goodreadsRating": "Valoración de Goodreads", + "goodreadsReviewCount": "Reseñas de Goodreads", + "hardcoverId": "ID de Hardcover", + "hardcoverBookId": "ID de libro Hardcover", + "hardcoverRating": "Valoración de Hardcover", + "hardcoverReviewCount": "Reseñas de Hardcover", + "comicvineId": "ID de Comicvine", + "lubimyczytacId": "ID de Lubimyczytac", + "lubimyczytacRating": "Valoración de Lubimyczytac", + "ranobedbId": "ID de Ranobedb", + "ranobedbRating": "Valoración de Ranobedb", + "audibleId": "ID de Audible", + "audibleRating": "Valoración de Audible", + "audibleReviewCount": "Reseñas de Audible" + } }, "publicReviews": { "sectionTitle": "Reseñas públicas", @@ -91,6 +122,34 @@ "saveSuccess": "Pesos guardados correctamente", "saveError": "Error al guardar los pesos", "recalcSuccess": "Todas las puntuaciones de coincidencia de libros se recalcularon correctamente.", - "recalcError": "Error al recalcular las puntuaciones de coincidencia." + "recalcError": "Error al recalcular las puntuaciones de coincidencia.", + "fields": { + "title": "Título", + "subtitle": "Subtítulo", + "authors": "Autores", + "description": "Descripción", + "publisher": "Editorial", + "publishedDate": "Fecha de publicación", + "categories": "Categorías", + "coverImage": "Imagen de portada", + "seriesName": "Nombre de serie", + "seriesNumber": "Número de serie", + "seriesTotal": "Total de serie", + "language": "Idioma", + "isbn13": "ISBN-13", + "isbn10": "ISBN-10", + "pageCount": "Número de páginas", + "amazonRating": "Valoración de Amazon", + "amazonReviewCount": "Valoración de Amazon #", + "goodreadsRating": "Valoración de Goodreads", + "goodreadsReviewCount": "Valoración de Goodreads #", + "hardcoverRating": "Valoración de Hardcover", + "hardcoverReviewCount": "Valoración de Hardcover #", + "audibleRating": "Valoración de Audible", + "audibleReviewCount": "Valoración de Audible #", + "doubanRating": "Valoración de Douban", + "doubanReviewCount": "Valoración de Douban #", + "ranobedbRating": "Valoración de Ranobedb" + } } } diff --git a/booklore-ui/src/i18n/es/shared.json b/booklore-ui/src/i18n/es/shared.json index 3d60247e1..f3b1e99a1 100644 --- a/booklore-ui/src/i18n/es/shared.json +++ b/booklore-ui/src/i18n/es/shared.json @@ -92,6 +92,18 @@ "liveNotification": { "defaultMessage": "Sin notificaciones recientes..." }, + "supportDialog": { + "title": "Apoyar BookLore", + "subtitle": "De un desarrollador independiente que ama los libros", + "intro": "BookLore es creado y mantenido por un solo desarrollador que realmente ama los libros. Si ha hecho que organizar tu biblioteca sea un poco más agradable, aquí tienes algunas formas de apoyar el proyecto y mantenerlo en marcha.", + "starTitle": "Estrella en GitHub", + "starDesc": "Una estrella ayuda mucho. Permite que nuevas personas descubran BookLore y me mantiene motivado.", + "collectiveTitle": "Open Collective", + "collectiveDesc": "Apoyo recurrente que ayuda a cubrir el alojamiento y mantener el desarrollo sostenible.", + "kofiTitle": "Invítame un café", + "kofiDesc": "Una propina para las sesiones de programación nocturnas. ¡Cada aporte se agradece!", + "closing": "Gracias por ser parte de la comunidad de BookLore." + }, "metadataProgress": { "taskStalled": "Tarea detenida o servidor no disponible", "taskCancelled": "Tarea cancelada por el usuario",