feat(i18n): add Transloco translation framework with EN/ES and 7 language scaffolds (#2681)

* feat(i18n): add Transloco translation framework and translate all settings tabs (EN/ES)

* feat(i18n): translate shared, layout, dashboard, library-creator, and app-root components (EN/ES) and scaffold 7 new languages

* feat(i18n): translate bookdrop and metadata components (EN/ES), remove i18n-audit from tracking

* fix(i18n): deep-merge English as fallback base for incomplete language translations
This commit is contained in:
ACX
2026-02-10 07:49:01 -07:00
committed by GitHub
parent 45dba44833
commit 0f60faa124
376 changed files with 10487 additions and 4810 deletions
@@ -1,13 +1,14 @@
<ng-container *transloco="let t; prefix: 'bookdrop.bulkEdit'">
<div class="bulk-edit-container">
<div class="info-banner">
<i class="pi pi-info-circle"></i>
<span>Select which fields to apply to <strong>{{ fileCount }}</strong> selected file(s). Only checked fields will be updated.</span>
<span [innerHTML]="t('infoBanner', { fileCount: fileCount })"></span>
</div>
<p-divider></p-divider>
<div class="fields-section">
<h4>Text Fields</h4>
<h4>{{ t('textFieldsTitle') }}</h4>
<div class="field-grid">
@for (field of textFields; track field.name) {
<div class="field-row">
@@ -15,7 +16,7 @@
[binary]="true"
[ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label">
[ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<input
@@ -32,7 +33,7 @@
<p-divider></p-divider>
<div class="fields-section">
<h4>Number Fields</h4>
<h4>{{ t('numberFieldsTitle') }}</h4>
<div class="field-grid">
@for (field of numberFields; track field.name) {
<div class="field-row">
@@ -40,7 +41,7 @@
[binary]="true"
[ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label">
[ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<input
@@ -59,9 +60,9 @@
<div class="fields-section">
<div class="section-header">
<h4>Array Fields</h4>
<h4>{{ t('arrayFieldsTitle') }}</h4>
<div class="merge-toggle">
<span class="merge-label" id="merge-mode-label">Mode:</span>
<span class="merge-label" id="merge-mode-label">{{ t('modeLabel') }}</span>
<p-selectButton
[options]="mergeOptions"
[(ngModel)]="mergeArrays"
@@ -71,7 +72,7 @@
</p-selectButton>
</div>
</div>
<p class="helper-text"><i class="pi pi-info-circle"></i> Type and press Enter to add each item.</p>
<p class="helper-text"><i class="pi pi-info-circle"></i> {{ t('helperText') }}</p>
<div class="field-grid">
@for (field of chipFields; track field.name) {
<div class="field-row">
@@ -79,7 +80,7 @@
[binary]="true"
[ngModel]="isFieldEnabled(field.name)"
(ngModelChange)="toggleField(field.name)"
[ariaLabel]="'Enable ' + field.label">
[ariaLabel]="t('enableField', { label: field.label })">
</p-checkbox>
<label class="field-label" [attr.for]="field.controlName">{{ field.label }}</label>
<p-autoComplete
@@ -102,13 +103,13 @@
<div class="dialog-footer">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
(click)="cancel()">
</p-button>
<p-button
label="Apply to Selected"
[label]="t('applyToSelected')"
icon="pi pi-check"
severity="success"
[disabled]="!hasEnabledFields"
@@ -116,3 +117,4 @@
</p-button>
</div>
</div>
</ng-container>
@@ -8,6 +8,7 @@ import {AutoComplete} from 'primeng/autocomplete';
import {Divider} from 'primeng/divider';
import {SelectButton} from 'primeng/selectbutton';
import {BookMetadata} from '../../../book/model/book.model';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
export interface BulkEditResult {
fields: Partial<BookMetadata>;
@@ -34,6 +35,8 @@ interface BulkEditField {
AutoComplete,
Divider,
SelectButton,
TranslocoDirective,
TranslocoPipe,
],
templateUrl: './bookdrop-bulk-edit-dialog.component.html',
styleUrl: './bookdrop-bulk-edit-dialog.component.scss'
@@ -43,6 +46,7 @@ export class BookdropBulkEditDialogComponent implements OnInit {
private readonly dialogRef = inject(DynamicDialogRef);
private readonly config = inject(DynamicDialogConfig);
private readonly cdr = inject(ChangeDetectorRef);
private readonly t = inject(TranslocoService);
fileCount: number = 0;
mergeArrays = true;
@@ -61,25 +65,25 @@ export class BookdropBulkEditDialogComponent implements OnInit {
});
textFields: BulkEditField[] = [
{name: 'seriesName', label: 'Series Name', type: 'text', controlName: 'seriesName'},
{name: 'publisher', label: 'Publisher', type: 'text', controlName: 'publisher'},
{name: 'language', label: 'Language', type: 'text', controlName: 'language'},
{name: 'seriesName', label: this.t.translate('bookdrop.bulkEdit.seriesName'), type: 'text', controlName: 'seriesName'},
{name: 'publisher', label: this.t.translate('bookdrop.bulkEdit.publisher'), type: 'text', controlName: 'publisher'},
{name: 'language', label: this.t.translate('bookdrop.bulkEdit.language'), type: 'text', controlName: 'language'},
];
numberFields: BulkEditField[] = [
{name: 'seriesTotal', label: 'Series Total', type: 'number', controlName: 'seriesTotal'},
{name: 'seriesTotal', label: this.t.translate('bookdrop.bulkEdit.seriesTotal'), type: 'number', controlName: 'seriesTotal'},
];
chipFields: BulkEditField[] = [
{name: 'authors', label: 'Authors', type: 'chips', controlName: 'authors'},
{name: 'categories', label: 'Genres', type: 'chips', controlName: 'categories'},
{name: 'moods', label: 'Moods', type: 'chips', controlName: 'moods'},
{name: 'tags', label: 'Tags', type: 'chips', controlName: 'tags'},
{name: 'authors', label: this.t.translate('bookdrop.bulkEdit.authors'), type: 'chips', controlName: 'authors'},
{name: 'categories', label: this.t.translate('bookdrop.bulkEdit.genres'), type: 'chips', controlName: 'categories'},
{name: 'moods', label: this.t.translate('bookdrop.bulkEdit.moods'), type: 'chips', controlName: 'moods'},
{name: 'tags', label: this.t.translate('bookdrop.bulkEdit.tags'), type: 'chips', controlName: 'tags'},
];
mergeOptions = [
{label: 'Merge', value: true},
{label: 'Replace', value: false},
{label: this.t.translate('bookdrop.bulkEdit.mergeOption'), value: true},
{label: this.t.translate('bookdrop.bulkEdit.replaceOption'), value: false},
];
ngOnInit(): void {
@@ -113,7 +117,7 @@ export class BookdropBulkEditDialogComponent implements OnInit {
target.value = '';
}
}
if (!this.enabledFields.has(fieldName)) {
const control = this.bulkEditForm.get(fieldName);
const value = control?.value;
@@ -1,17 +1,18 @@
<ng-container *transloco="let t; prefix: 'bookdrop.metadataPicker'">
@if (fetchedMetadata && fetchedMetadata.title) {
<form [formGroup]="metadataForm" class="metapicker">
<div class="form-scroll">
<div class="metaheader">
<label class="field-label"></label>
<div class="header-fields-row">
<p class="header-column">File Data</p>
<p class="header-column">{{ t('fileData') }}</p>
<div class="midbuttons">
<p-button
size="small"
icon="pi pi-angle-left"
class="btn-margin"
[outlined]="true"
pTooltip="Copy missing fields from fetched metadata"
[pTooltip]="t('copyMissingTooltip')"
tooltipPosition="bottom"
(onClick)="copyMissing()"
></p-button>
@@ -20,7 +21,7 @@
icon="pi pi-angle-double-left"
class="btn-margin"
[outlined]="true"
pTooltip="Overwrite all fields with fetched metadata"
[pTooltip]="t('overwriteAllTooltip')"
tooltipPosition="bottom"
(onClick)="copyAll()"
></p-button>
@@ -30,12 +31,12 @@
icon="pi pi-refresh"
class="btn-margin"
[outlined]="true"
pTooltip="Reset all fields to original values"
[pTooltip]="t('resetAllTooltip')"
tooltipPosition="bottom"
(onClick)="confirmReset()"
></p-button>
</div>
<p class="header-column">Fetched Data</p>
<p class="header-column">{{ t('fetchedData') }}</p>
</div>
</div>
<div class="metacontent">
@@ -57,7 +58,7 @@
></p-image>
}
@else {
<div class="thumbnail no-cover-text">No cover image</div>
<div class="thumbnail no-cover-text">{{ t('noCoverImage') }}</div>
}
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl"/>
</div>
@@ -82,7 +83,7 @@
></p-image>
}
@else {
<div class="thumbnail no-cover-text">Cover image not found</div>
<div class="thumbnail no-cover-text">{{ t('coverImageNotFound') }}</div>
}
<input type="hidden" [value]="fetchedMetadata.thumbnailUrl" readonly/>
</div>
@@ -317,14 +318,14 @@
<div class="form-scroll">
<div class="metaheader">
<p class="missingmd">
Unable to fetch metadata for this file
{{ t('unableToFetchMetadata') }}
</p>
<p-button
size="small"
severity="warn"
icon="pi pi-refresh"
[outlined]="true"
pTooltip="Reset all fields to original values"
[pTooltip]="t('resetAllTooltip')"
tooltipPosition="left"
(onClick)="confirmReset()"
></p-button>
@@ -490,3 +491,4 @@
</div>
</form>
}
</ng-container>
@@ -14,6 +14,7 @@ import {ConfirmationService} from 'primeng/api';
import {DatePicker} from 'primeng/datepicker';
import {ALL_METADATA_FIELDS, getArrayFields, getBottomFields, getTextareaFields, MetadataFieldConfig} from '../../../../shared/metadata';
import {MetadataUtilsService} from '../../../../shared/metadata';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-bookdrop-file-metadata-picker-component',
@@ -29,6 +30,7 @@ import {MetadataUtilsService} from '../../../../shared/metadata';
Image,
LazyLoadImageModule,
DatePicker,
TranslocoDirective,
],
templateUrl: './bookdrop-file-metadata-picker.component.html',
styleUrl: './bookdrop-file-metadata-picker.component.scss'
@@ -38,6 +40,7 @@ export class BookdropFileMetadataPickerComponent {
private readonly confirmationService = inject(ConfirmationService);
private readonly metadataUtils = inject(MetadataUtilsService);
protected readonly urlHelper = inject(UrlHelperService);
private readonly t = inject(TranslocoService);
@Input() fetchedMetadata!: BookMetadata;
@Input() originalMetadata?: BookMetadata;
@@ -130,8 +133,8 @@ export class BookdropFileMetadataPickerComponent {
confirmReset(): void {
this.confirmationService.confirm({
message: 'Are you sure you want to reset all metadata changes made to this file?',
header: 'Reset Metadata Changes?',
message: this.t.translate('bookdrop.metadataPicker.confirmResetMessage'),
header: this.t.translate('bookdrop.metadataPicker.confirmResetHeader'),
icon: 'pi pi-exclamation-triangle',
acceptButtonStyleClass: 'p-button-danger',
accept: () => this.resetAll()
@@ -1,31 +1,28 @@
<ng-container *transloco="let t; prefix: 'bookdrop.fileReview'">
<div class="main-card">
<div class="header">
<div class="header-content">
<h2>
Review Bookdrop Files
{{ t('title') }}
<a href="https://booklore.org/docs/bookdrop" target="_blank" rel="noopener noreferrer">
<i
class="pi pi-external-link external-link-icon"
pTooltip="View documentation"
[pTooltip]="t('viewDocumentationTooltip')"
tooltipPosition="top"></i>
</a>
</h2>
<p>
These files were uploaded to the
<strong>Bookdrop Folder</strong>.
Review their fetched metadata, assign a library and subpath, and finalize where they belong in your collection.
</p>
<p [innerHTML]="t('description')"></p>
</div>
<div class="header-actions">
<p-button
label="Rescan"
[label]="t('rescan')"
size="small"
icon="pi pi-refresh"
severity="primary"
outlined
(click)="rescanBookdrop()"
pTooltip="Manually trigger a rescan of the Bookdrop folder"
[pTooltip]="t('rescanTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -36,7 +33,7 @@
<div class="loading-overlay">
<div class="loading-content">
<p-progressSpinner strokeWidth="4"/>
<span>Loading Bookdrop files. Please wait...</span>
<span>{{ t('loadingMessage') }}</span>
</div>
</div>
@@ -48,7 +45,7 @@
<p-progressSpinner strokeWidth="4"/>
<div class="saving-message">
<span>
Organizing and moving files to their designated libraries. Please wait...
{{ t('savingMessage') }}
</span>
</div>
</div>
@@ -62,14 +59,14 @@
size="small"
outlined
severity="info"
label="Import&nbsp;Metadata"
[label]="t('importMetadata')"
icon="pi pi-copy"
[disabled]="!hasSelectedFiles"
(click)="copyMetadata()"
pTooltip="Import fetched metadata for selected files"
[pTooltip]="t('importMetadataTooltip')"
tooltipPosition="top">
</p-button>
<p-inputgroup-addon pTooltip="Include book covers when importing fetched metadata" tooltipPosition="top">
<p-inputgroup-addon [pTooltip]="t('includeCoversTooltip')" tooltipPosition="top">
<p-checkbox
inputId="includecovers"
[disabled]="!hasSelectedFiles"
@@ -85,11 +82,11 @@
class="bulkedit"
outlined
severity="help"
label="Bulk&nbsp;Edit"
[label]="t('bulkEdit')"
icon="pi pi-pencil"
[disabled]="!hasSelectedFiles"
(click)="openBulkEditDialog()"
pTooltip="Edit metadata fields in bulk for selected files"
[pTooltip]="t('bulkEditTooltip')"
tooltipPosition="top">
</p-button>
@@ -98,18 +95,18 @@
class="extractpattern"
outlined
severity="warn"
label="Extract&nbsp;Pattern"
[label]="t('extractPattern')"
icon="pi pi-sliders-h"
[disabled]="!hasSelectedFiles"
(click)="openPatternExtractDialog()"
pTooltip="Extract metadata from selected filenames using a pattern"
[pTooltip]="t('extractPatternTooltip')"
tooltipPosition="top">
</p-button>
</div>
<div class="default-controls">
<i class="pi pi-book"
pTooltip="Specify library and subpath for selected files"
[pTooltip]="t('specifyLibraryTooltip')"
tooltipPosition="left"></i>
<p-select
@@ -117,7 +114,7 @@
[options]="libraryOptions"
optionLabel="label"
optionValue="value"
placeholder="Library"
[placeholder]="t('libraryPlaceholder')"
appendTo="body"
[(ngModel)]="defaultLibraryId">
</p-select>
@@ -127,7 +124,7 @@
[options]="selectedLibraryPaths"
optionLabel="label"
optionValue="value"
placeholder="Subpath"
[placeholder]="t('subpathPlaceholder')"
appendTo="body"
[(ngModel)]="defaultPathId">
</p-select>
@@ -138,7 +135,7 @@
severity="info"
[disabled]="!canApplyDefaults"
(click)="applyLibraryDefaults()"
pTooltip="Apply library and subpath to selected files"
[pTooltip]="t('applyLibraryTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -149,7 +146,7 @@
<div class="content-area">
@if (bookdropFileUis.length === 0) {
<div class="empty-state">
No bookdrop files to review.
{{ t('emptyState') }}
</div>
} @else {
@for (file of bookdropFileUis; track file) {
@@ -166,22 +163,22 @@
<img
[src]="file.metadataForm.get('thumbnailUrl')?.value"
alt="Cover"
title="Original cover"
[title]="t('originalCoverTitle')"
class="cover-image"
(click)="file.showDetails = !file.showDetails"/>
} @else {
<div title="No cover found" class="cover-image cover-placeholder">?</div>
<div [title]="t('noCoverFoundTitle')" class="cover-image cover-placeholder">?</div>
}
@if (file.file.fetchedMetadata?.thumbnailUrl) {
<img
[src]="file.file.fetchedMetadata?.thumbnailUrl"
alt="Fetched Cover"
title="Fetched cover"
[title]="t('fetchedCoverTitle')"
class="cover-image"
(click)="file.showDetails = !file.showDetails"/>
} @else {
<div title="No cover fetched" class="cover-image cover-placeholder">?</div>
<div [title]="t('noCoverFetchedTitle')" class="cover-image cover-placeholder">?</div>
}
<div class="file-name" (click)="file.showDetails = !file.showDetails">
@@ -197,10 +194,10 @@
'pi-exclamation-triangle not-applied': file.file.fetchedMetadata && !copiedFlags[file.file.id]
}"
[pTooltip]="copiedFlags[file.file.id]
? 'Fetched metadata has been applied.'
? t('metadataAppliedTooltip')
: (!file.file.fetchedMetadata || !file.file.fetchedMetadata.title)
? 'No fetched metadata available. Original metadata will be used.'
: 'Fetched metadata hasn’t been applied yet. Open metadata picker to review.'"
? t('noMetadataTooltip')
: t('metadataNotAppliedTooltip')"
tooltipPosition="top">
</i>
@@ -209,7 +206,7 @@
[options]="libraryOptions"
optionLabel="label"
optionValue="value"
placeholder="Library"
[placeholder]="t('libraryPlaceholder')"
class="library-select"
appendTo="body"
[(ngModel)]="file.selectedLibraryId"
@@ -221,7 +218,7 @@
[options]="file.availablePaths"
optionLabel="name"
optionValue="id"
placeholder="Subpath"
[placeholder]="t('subpathPlaceholder')"
class="path-select"
appendTo="body"
[(ngModel)]="file.selectedPathId">
@@ -233,10 +230,10 @@
[icon]="file.showDetails ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
(click)="file.showDetails = !file.showDetails"
[pTooltip]="file.showDetails
? 'Hide metadata'
? t('hideMetadataTooltip')
: file.file.fetchedMetadata?.title
? 'Review and copy fetched metadata'
: 'Show file metadata (no fetched metadata)'"
? t('reviewMetadataTooltip')
: t('showMetadataTooltip')"
tooltipPosition="left">
</p-button>
</div>
@@ -270,27 +267,27 @@
@if (bookdropFileUis.length > 0) {
<p-inputgroup class="selectall">
<p-inputgroup-addon>
<label class="selected-count-label" pTooltip="Number of files selected" tooltipPosition="top">{{ selectedCount }}</label>
<label class="selected-count-label" [pTooltip]="t('selectedCountTooltip')" tooltipPosition="top">{{ selectedCount }}</label>
</p-inputgroup-addon>
<p-button
label="Select&nbsp;All"
[label]="t('selectAll')"
icon="pi pi-check-square"
severity="info"
(click)="selectAll(true)"
outlined
pTooltip="Select all files across all pages"
[pTooltip]="t('selectAllTooltip')"
tooltipPosition="top">
</p-button>
</p-inputgroup>
<p-button
label="Clear"
[label]="t('clear')"
icon="pi pi-times-circle"
severity="warn"
[disabled]="!hasSelectedFiles"
(click)="selectAll(false)"
outlined
pTooltip="Deselect all files across all pages"
[pTooltip]="t('clearTooltip')"
tooltipPosition="top">
</p-button>
} @else {
@@ -315,33 +312,33 @@
<div class="footer-right">
<p-button
label="Reset"
[label]="t('reset')"
icon="pi pi-refresh"
severity="warn"
[disabled]="!hasSelectedFiles"
outlined
(click)="confirmReset()"
pTooltip="Discard all changes made to metadata of selected files"
[pTooltip]="t('resetTooltip')"
tooltipPosition="top">
</p-button>
<p-button
label="Delete"
[label]="t('delete')"
icon="pi pi-times"
severity="danger"
[disabled]="!hasSelectedFiles"
outlined
(click)="confirmDelete()"
pTooltip="Permanently delete selected Bookdrop files and discard any changes"
[pTooltip]="t('deleteTooltip')"
tooltipPosition="top">
</p-button>
<p-button
label="Finalize"
[label]="t('finalize')"
[icon]="saving ? 'pi pi-spin pi-spinner' : 'pi pi-save'"
severity="success"
outlined
[disabled]="!canFinalize || saving"
(click)="confirmFinalize()"
pTooltip="Move selected files into the chosen library and subpath"
[pTooltip]="t('finalizeTooltip')"
tooltipPosition="top">
</p-button>
</div>
@@ -349,3 +346,4 @@
</div>
}
</div>
</ng-container>
@@ -29,6 +29,7 @@ import {BookdropFileMetadataPickerComponent} from '../bookdrop-file-metadata-pic
import {BookdropBulkEditDialogComponent, BulkEditResult} from '../bookdrop-bulk-edit-dialog/bookdrop-bulk-edit-dialog.component';
import {BookdropPatternExtractDialogComponent} from '../bookdrop-pattern-extract-dialog/bookdrop-pattern-extract-dialog.component';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
export interface BookdropFileUI {
file: BookdropFile;
@@ -60,6 +61,7 @@ export interface BookdropFileUI {
Paginator,
InputGroup,
InputGroupAddonModule,
TranslocoDirective,
],
})
export class BookdropFileReviewComponent implements OnInit {
@@ -73,6 +75,7 @@ export class BookdropFileReviewComponent implements OnInit {
private readonly urlHelper = inject(UrlHelperService);
private readonly activatedRoute = inject(ActivatedRoute);
private readonly pageTitle = inject(PageTitleService);
private readonly t = inject(TranslocoService);
@ViewChildren('metadataPicker') metadataPickers!: QueryList<BookdropFileMetadataPickerComponent>;
@@ -99,7 +102,7 @@ export class BookdropFileReviewComponent implements OnInit {
excludedFiles = new Set<number>();
ngOnInit(): void {
this.pageTitle.setPageTitle('Review Bookdrop Files');
this.pageTitle.setPageTitle(this.t.translate('bookdrop.fileReview.title'));
this.activatedRoute.queryParams
.pipe(startWith({}), tap(() => {
@@ -374,18 +377,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to reset metadata.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesResetDetail'),
});
return;
}
this.confirmationService.confirm({
message: 'Are you sure you want to reset all metadata changes made to the selected files?',
header: 'Confirm Reset',
message: this.t.translate('bookdrop.fileReview.toast.confirmResetMessage'),
header: this.t.translate('bookdrop.fileReview.toast.confirmResetHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Reset',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmResetAccept'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: {
severity: 'secondary',
outlined: true
@@ -403,18 +406,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to finalize.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesFinalizeDetail'),
});
return;
}
this.confirmationService.confirm({
message: `Are you sure you want to finalize the import of ${selectedCount} file${selectedCount !== 1 ? 's' : ''}?`,
header: 'Confirm Finalize',
message: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeMessage', {count: selectedCount}),
header: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Finalize',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmFinalizeAccept'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: {
severity: 'secondary',
outlined: true
@@ -432,18 +435,18 @@ export class BookdropFileReviewComponent implements OnInit {
if (selectedCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to delete.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesDeleteDetail'),
});
return;
}
this.confirmationService.confirm({
message: `Are you sure you want to delete ${selectedCount} selected Bookdrop file${selectedCount !== 1 ? 's' : ''}? This action cannot be undone.`,
header: 'Confirm Delete',
message: this.t.translate('bookdrop.fileReview.toast.confirmDeleteMessage', {count: selectedCount}),
header: this.t.translate('bookdrop.fileReview.toast.confirmDeleteHeader'),
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Delete',
rejectLabel: 'Cancel',
acceptLabel: this.t.translate('bookdrop.fileReview.toast.confirmDeleteAccept'),
rejectLabel: this.t.translate('common.cancel'),
rejectButtonProps: {
severity: 'secondary',
outlined: true
@@ -469,8 +472,8 @@ export class BookdropFileReviewComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Files Deleted',
detail: 'Selected Bookdrop files were deleted successfully.',
summary: this.t.translate('bookdrop.fileReview.toast.filesDeletedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.filesDeletedDetail'),
});
this.getSelectedFiles().forEach(file => delete this.fileUiCache[file.file.id]);
@@ -483,8 +486,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error deleting files:', err);
this.messageService.add({
severity: 'error',
summary: 'Delete Failed',
detail: 'An error occurred while deleting Bookdrop files.',
summary: this.t.translate('bookdrop.fileReview.toast.deleteFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.deleteFailedDetail'),
});
},
});
@@ -549,8 +552,8 @@ export class BookdropFileReviewComponent implements OnInit {
this.messageService.add({
severity: 'success',
summary: 'Import Complete',
detail: 'Import process finished. See details below.',
summary: this.t.translate('bookdrop.fileReview.toast.importCompleteSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.importCompleteDetail'),
});
this.dialogLauncherService.openBookdropFinalizeResultDialog(result);
@@ -569,8 +572,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error finalizing import:', err);
this.messageService.add({
severity: 'error',
summary: 'Import Failed',
detail: 'Some files could not be moved. Please check the console for more details.',
summary: this.t.translate('bookdrop.fileReview.toast.importFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.importFailedDetail'),
});
this.saving = false;
}
@@ -635,15 +638,15 @@ export class BookdropFileReviewComponent implements OnInit {
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Rescan Triggered',
detail: 'Bookdrop rescan has been started successfully.',
summary: this.t.translate('bookdrop.fileReview.toast.rescanTriggeredSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.rescanTriggeredDetail'),
});
},
error: (err) => {
this.messageService.add({
severity: 'error',
summary: 'Rescan Failed',
detail: 'Unable to trigger bookdrop rescan. Please try again.',
summary: this.t.translate('bookdrop.fileReview.toast.rescanFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.rescanFailedDetail'),
});
console.error(err);
}
@@ -659,14 +662,14 @@ export class BookdropFileReviewComponent implements OnInit {
if (totalCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to bulk edit.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesBulkEditDetail'),
});
return;
}
const dialogRef = this.dialogLauncherService.openDialog(BookdropBulkEditDialogComponent, {
header: `Bulk Edit ${totalCount} Files`,
header: this.t.translate('bookdrop.fileReview.toast.bulkEditDialogHeader', {count: totalCount}),
width: '600px',
modal: true,
closable: true,
@@ -689,8 +692,8 @@ export class BookdropFileReviewComponent implements OnInit {
if (totalCount === 0) {
this.messageService.add({
severity: 'warn',
summary: 'No files selected',
detail: 'Please select files to extract metadata from.',
summary: this.t.translate('bookdrop.fileReview.toast.noFilesSelectedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.noFilesExtractDetail'),
});
return;
}
@@ -699,7 +702,7 @@ export class BookdropFileReviewComponent implements OnInit {
const selectedIds = selectedFiles.map(f => f.file.id);
const dialogRef = this.dialogLauncherService.openDialog(BookdropPatternExtractDialogComponent, {
header: 'Extract Metadata from Filenames',
header: this.t.translate('bookdrop.fileReview.toast.extractMetadataDialogHeader'),
width: '700px',
modal: true,
closable: true,
@@ -736,8 +739,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error loading pages into cache:', err);
this.messageService.add({
severity: 'error',
summary: 'Bulk Edit Failed',
detail: 'An error occurred while loading files into cache.',
summary: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.bulkEditCacheFailedDetail'),
});
return;
}
@@ -763,16 +766,16 @@ export class BookdropFileReviewComponent implements OnInit {
next: (backendResult: BackendBulkEditResult) => {
this.messageService.add({
severity: 'success',
summary: 'Bulk Edit Applied',
detail: `Updated metadata for ${backendResult.successfullyUpdated} of ${backendResult.totalFiles} file(s).`,
summary: this.t.translate('bookdrop.fileReview.toast.bulkEditAppliedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.bulkEditAppliedDetail', {success: backendResult.successfullyUpdated, total: backendResult.totalFiles}),
});
},
error: (err) => {
console.error('Error applying bulk edit:', err);
this.messageService.add({
severity: 'error',
summary: 'Bulk Edit Failed',
detail: 'An error occurred while applying bulk edits.',
summary: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.bulkEditFailedDetail'),
});
},
});
@@ -814,8 +817,8 @@ export class BookdropFileReviewComponent implements OnInit {
console.error('Error loading pages into cache:', err);
this.messageService.add({
severity: 'error',
summary: 'Pattern Extraction Failed',
detail: 'An error occurred while loading files into cache.',
summary: this.t.translate('bookdrop.fileReview.toast.patternExtractionCacheFailedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.patternExtractionCacheFailedDetail'),
});
return;
}
@@ -849,8 +852,8 @@ export class BookdropFileReviewComponent implements OnInit {
this.messageService.add({
severity: 'success',
summary: 'Pattern Extraction Applied',
detail: `Applied extracted metadata to ${appliedCount} file(s).`,
summary: this.t.translate('bookdrop.fileReview.toast.patternExtractionAppliedSummary'),
detail: this.t.translate('bookdrop.fileReview.toast.patternExtractionAppliedDetail', {count: appliedCount}),
});
}
}
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'bookdrop.filesWidget'">
<div class="staging-border">
<div class="widget-row">
<div class="widget-info">
<p class="widget-title">Pending Bookdrop Files</p>
<p class="widget-title">{{ t('title') }}</p>
<p class="widget-count">{{ pendingCount }}</p>
@if (lastUpdatedAt) {
<p class="widget-date">
Last updated: {{ lastUpdatedAt | date: 'short' }}
{{ t('lastUpdated') }} {{ lastUpdatedAt | date: 'short' }}
</p>
}
</div>
@@ -17,8 +18,9 @@
outlined
severity="info"
(click)="openReviewDialog()">
Review
{{ t('reviewBtn') }}
</p-button>
</div>
</div>
</div>
</ng-container>
@@ -5,6 +5,7 @@ import {BookdropFileNotification, BookdropFileService} from '../../service/bookd
import {DatePipe} from '@angular/common';
import {Router} from '@angular/router';
import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-bookdrop-files-widget-component',
@@ -13,7 +14,8 @@ import {Button} from 'primeng/button';
styleUrl: './bookdrop-files-widget.component.scss',
imports: [
DatePipe,
Button
Button,
TranslocoDirective
]
})
export class BookdropFilesWidgetComponent implements OnInit, OnDestroy {
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'bookdrop.finalizeResult'">
<div class="import-result-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-file-import header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Import Summary</h2>
<p class="panel-description">Results of your book import</p>
<h2 class="panel-title">{{ t('panelTitle') }}</h2>
<p class="panel-description">{{ t('panelDescription') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -21,20 +22,20 @@
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value total">{{ result.totalFiles }}</div>
<div class="stat-label">Total Files</div>
<div class="stat-label">{{ t('totalFiles') }}</div>
</div>
<div class="stat-card">
<div class="stat-value success">{{ result.successfullyImported }}</div>
<div class="stat-label">Successfully Imported</div>
<div class="stat-label">{{ t('successfullyImported') }}</div>
</div>
<div class="stat-card">
<div class="stat-value failed">{{ result.failed }}</div>
<div class="stat-label">Failed</div>
<div class="stat-label">{{ t('failed') }}</div>
</div>
</div>
<div class="processed-info">
<div class="processed-label">Processed at</div>
<div class="processed-label">{{ t('processedAt') }}</div>
<div class="processed-time">{{ result.processedAt | date:'medium' }}</div>
</div>
@@ -65,3 +66,4 @@
</div>
</div>
</div>
</ng-container>
@@ -3,13 +3,15 @@ import {DatePipe, NgClass} from '@angular/common';
import {BookdropFinalizeResult} from '../../service/bookdrop.service';
import {DynamicDialogConfig, DynamicDialogRef} from "primeng/dynamicdialog";
import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-bookdrop-finalize-result-dialog',
imports: [
NgClass,
DatePipe,
Button
Button,
TranslocoDirective
],
templateUrl: './bookdrop-finalize-result-dialog.component.html',
styleUrl: './bookdrop-finalize-result-dialog.component.scss'
@@ -1,39 +1,37 @@
<ng-container *transloco="let t; prefix: 'bookdrop.patternExtract'">
<div class="pattern-extract-container">
<div class="info-banner">
<i class="pi pi-info-circle"></i>
<span>
Enter a pattern to extract metadata from filenames of <strong>{{ fileCount }}</strong> selected file(s).
Use placeholders like <code>{{ '{' }}SeriesName{{ '}' }}</code> to capture values.
</span>
<span [innerHTML]="t('infoBanner', { fileCount: fileCount })"></span>
</div>
<p-divider></p-divider>
<div class="pattern-section">
<h4>Pattern</h4>
<h4>{{ t('patternTitle') }}</h4>
<div class="pattern-input-row">
<input
#patternInput
pInputText
[formControl]="patternControl"
[placeholder]="patternPlaceholderText"
[placeholder]="t('patternPlaceholder')"
id="pattern-input"
aria-label="Filename pattern for metadata extraction"
[attr.aria-label]="t('patternAriaLabel')"
class="pattern-input"
(input)="previewPattern()"/>
<p-button
icon="pi pi-eye"
label="Preview"
[label]="t('preview')"
severity="secondary"
[disabled]="!hasValidPattern"
[ariaLabel]="'Preview pattern extraction on sample files'"
[ariaLabel]="t('previewAriaLabel')"
(click)="previewPattern()">
</p-button>
</div>
</div>
<div class="placeholders-section">
<h4>Available Placeholders</h4>
<h4>{{ t('availablePlaceholdersTitle') }}</h4>
<div class="placeholder-chips">
@for (placeholder of availablePlaceholders; track placeholder.name) {
<p-chip
@@ -48,11 +46,11 @@
</div>
<div class="common-patterns-section">
<h4>Common Patterns</h4>
<h4>{{ t('commonPatternsTitle') }}</h4>
<div class="common-pattern-buttons">
@for (commonPattern of commonPatterns; track commonPattern.pattern) {
<p-button
[label]="commonPattern.label"
[label]="getCommonPatternLabel(commonPattern.labelKey)"
severity="secondary"
size="small"
outlined
@@ -66,7 +64,7 @@
@if (previewResults.length > 0) {
<div class="preview-section">
<h4>Preview (Sample Files)</h4>
<h4>{{ t('previewTitle') }}</h4>
<div class="preview-list">
@for (preview of previewResults; track preview.fileName) {
<div class="preview-item" [ngClass]="getPreviewClass(preview)">
@@ -102,18 +100,18 @@
@if (isExtracting) {
<div class="extracting-indicator">
<p-progressSpinner strokeWidth="4" [style]="spinnerStyle"></p-progressSpinner>
<span>Extracting metadata...</span>
<span>{{ t('extractingMessage') }}</span>
</div>
}
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
[disabled]="isExtracting"
(click)="cancel()">
</p-button>
<p-button
label="Extract and Apply"
[label]="t('extractAndApply')"
icon="pi pi-check"
severity="success"
[disabled]="!hasValidPattern || isExtracting"
@@ -121,3 +119,4 @@
</p-button>
</div>
</div>
</ng-container>
@@ -10,11 +10,12 @@ import {BookdropService, PatternExtractResult} from '../../service/bookdrop.serv
import {MessageService} from 'primeng/api';
import {NgClass} from '@angular/common';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
interface PatternPlaceholder {
name: string;
description: string;
example: string;
descriptionKey: string;
exampleKey: string;
}
interface PreviewResult {
@@ -24,6 +25,22 @@ interface PreviewResult {
errorMessage?: string;
}
const PLACEHOLDER_KEY_MAP: Record<string, string> = {
'*': 'wildcard',
'SeriesName': 'seriesName',
'Title': 'title',
'Subtitle': 'subtitle',
'Authors': 'authors',
'SeriesNumber': 'seriesNumber',
'Published': 'published',
'Publisher': 'publisher',
'Language': 'language',
'SeriesTotal': 'seriesTotal',
'ISBN10': 'isbn10',
'ISBN13': 'isbn13',
'ASIN': 'asin',
};
@Component({
selector: 'app-bookdrop-pattern-extract-dialog',
standalone: true,
@@ -36,6 +53,8 @@ interface PreviewResult {
ProgressSpinner,
NgClass,
Tooltip,
TranslocoDirective,
TranslocoPipe,
],
templateUrl: './bookdrop-pattern-extract-dialog.component.html',
styleUrl: './bookdrop-pattern-extract-dialog.component.scss'
@@ -46,6 +65,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
private readonly config = inject(DynamicDialogConfig);
private readonly bookdropService = inject(BookdropService);
private readonly messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
@ViewChild('patternInput', {static: false}) patternInput?: ElementRef<HTMLInputElement>;
@@ -57,7 +77,6 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
isExtracting = false;
previewResults: PreviewResult[] = [];
patternPlaceholderText = 'e.g., {SeriesName} - Ch {SeriesNumber}';
spinnerStyle = {width: '24px', height: '24px'};
patternForm = new FormGroup({
@@ -65,32 +84,32 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
});
availablePlaceholders: PatternPlaceholder[] = [
{name: '*', description: 'Wildcard - skips any text (not a metadata field)', example: 'anything'},
{name: 'SeriesName', description: 'Series or comic name', example: 'Chronicles of Earth'},
{name: 'Title', description: 'Book title', example: 'The Lost City'},
{name: 'Subtitle', description: 'Book subtitle', example: 'A Tale of Adventure'},
{name: 'Authors', description: 'Author name(s)', example: 'John Smith'},
{name: 'SeriesNumber', description: 'Book number in series', example: '25'},
{name: 'Published', description: 'Full date with format', example: '{Published:yyyy-MM-dd}'},
{name: 'Publisher', description: 'Publisher name', example: 'Epic Press'},
{name: 'Language', description: 'Language code', example: 'en'},
{name: 'SeriesTotal', description: 'Total books in series', example: '50'},
{name: 'ISBN10', description: 'ISBN-10 identifier', example: '1234567890'},
{name: 'ISBN13', description: 'ISBN-13 identifier', example: '1234567890123'},
{name: 'ASIN', description: 'Amazon ASIN', example: 'B012345678'},
{name: '*', descriptionKey: 'placeholders.wildcard', exampleKey: 'placeholderExamples.wildcard'},
{name: 'SeriesName', descriptionKey: 'placeholders.seriesName', exampleKey: 'placeholderExamples.seriesName'},
{name: 'Title', descriptionKey: 'placeholders.title', exampleKey: 'placeholderExamples.title'},
{name: 'Subtitle', descriptionKey: 'placeholders.subtitle', exampleKey: 'placeholderExamples.subtitle'},
{name: 'Authors', descriptionKey: 'placeholders.authors', exampleKey: 'placeholderExamples.authors'},
{name: 'SeriesNumber', descriptionKey: 'placeholders.seriesNumber', exampleKey: 'placeholderExamples.seriesNumber'},
{name: 'Published', descriptionKey: 'placeholders.published', exampleKey: 'placeholderExamples.published'},
{name: 'Publisher', descriptionKey: 'placeholders.publisher', exampleKey: 'placeholderExamples.publisher'},
{name: 'Language', descriptionKey: 'placeholders.language', exampleKey: 'placeholderExamples.language'},
{name: 'SeriesTotal', descriptionKey: 'placeholders.seriesTotal', exampleKey: 'placeholderExamples.seriesTotal'},
{name: 'ISBN10', descriptionKey: 'placeholders.isbn10', exampleKey: 'placeholderExamples.isbn10'},
{name: 'ISBN13', descriptionKey: 'placeholders.isbn13', exampleKey: 'placeholderExamples.isbn13'},
{name: 'ASIN', descriptionKey: 'placeholders.asin', exampleKey: 'placeholderExamples.asin'},
];
commonPatterns = [
{label: 'Author - Title', pattern: '{Authors} - {Title}'},
{label: 'Title - Author', pattern: '{Title} - {Authors}'},
{label: 'Title (Year)', pattern: '{Title} ({Published:yyyy})'},
{label: 'Author - Title (Year)', pattern: '{Authors} - {Title} ({Published:yyyy})'},
{label: 'Series #Number', pattern: '{SeriesName} #{SeriesNumber}'},
{label: 'Series - Chapter Number', pattern: '{SeriesName} - Chapter {SeriesNumber}'},
{label: 'Series - Vol Number', pattern: '{SeriesName} - Vol {SeriesNumber}'},
{label: '[Tag] Series - Chapter Number', pattern: '[*] {SeriesName} - Chapter {SeriesNumber}'},
{label: 'Title by Author', pattern: '{Title} by {Authors}'},
{label: 'Series vX (of Total)', pattern: '{SeriesName} v{SeriesNumber} (of {SeriesTotal})'},
{labelKey: 'commonPatternLabels.authorTitle', pattern: '{Authors} - {Title}'},
{labelKey: 'commonPatternLabels.titleAuthor', pattern: '{Title} - {Authors}'},
{labelKey: 'commonPatternLabels.titleYear', pattern: '{Title} ({Published:yyyy})'},
{labelKey: 'commonPatternLabels.authorTitleYear', pattern: '{Authors} - {Title} ({Published:yyyy})'},
{labelKey: 'commonPatternLabels.seriesNumber', pattern: '{SeriesName} #{SeriesNumber}'},
{labelKey: 'commonPatternLabels.seriesChapter', pattern: '{SeriesName} - Chapter {SeriesNumber}'},
{labelKey: 'commonPatternLabels.seriesVol', pattern: '{SeriesName} - Vol {SeriesNumber}'},
{labelKey: 'commonPatternLabels.tagSeriesChapter', pattern: '[*] {SeriesName} - Chapter {SeriesNumber}'},
{labelKey: 'commonPatternLabels.titleByAuthor', pattern: '{Title} by {Authors}'},
{labelKey: 'commonPatternLabels.seriesVTotal', pattern: '{SeriesName} v{SeriesNumber} (of {SeriesTotal})'},
];
ngOnInit(): void {
@@ -104,23 +123,23 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
const patternControl = this.patternForm.get('pattern');
const currentPattern = patternControl?.value ?? '';
const inputElement = this.patternInput?.nativeElement;
const textToInsert = placeholderName === '*' ? '*' : `{${placeholderName}}`;
const patternToModify = placeholderName === '*'
? currentPattern
const patternToModify = placeholderName === '*'
? currentPattern
: this.removeExistingPlaceholder(currentPattern, placeholderName);
if (inputElement) {
const cursorPosition = this.calculateCursorPosition(inputElement, currentPattern, patternToModify);
const newPattern = this.insertTextAtCursor(patternToModify, textToInsert, cursorPosition);
patternControl?.setValue(newPattern);
this.focusInputAfterInsertion(inputElement, cursorPosition, textToInsert.length);
} else {
patternControl?.setValue(patternToModify + textToInsert);
}
this.previewPattern();
}
@@ -131,7 +150,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
private calculateCursorPosition(inputElement: HTMLInputElement, originalPattern: string, modifiedPattern: string): number {
let cursorPosition = inputElement.selectionStart ?? modifiedPattern.length;
if (originalPattern !== modifiedPattern) {
const existingPlaceholderRegex = new RegExp(`\\{\\w+(?::[^}]*)?\\}`, 'g');
const matchBefore = originalPattern.substring(0, cursorPosition).match(existingPlaceholderRegex);
@@ -140,7 +159,7 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}
cursorPosition = Math.max(0, cursorPosition);
}
return cursorPosition;
}
@@ -218,8 +237,11 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
this.isExtracting = false;
this.messageService.add({
severity: 'success',
summary: 'Extraction Complete',
detail: `Successfully extracted metadata from ${result.successfullyExtracted} of ${result.totalFiles} files.`,
summary: this.t.translate('bookdrop.patternExtract.toast.extractionCompleteSummary'),
detail: this.t.translate('bookdrop.patternExtract.toast.extractionCompleteDetail', {
success: result.successfullyExtracted,
total: result.totalFiles
}),
});
this.dialogRef.close(result);
},
@@ -228,8 +250,8 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
console.error('Pattern extraction failed:', err);
this.messageService.add({
severity: 'error',
summary: 'Extraction Failed',
detail: 'An error occurred during pattern extraction.',
summary: this.t.translate('bookdrop.patternExtract.toast.extractionFailedSummary'),
detail: this.t.translate('bookdrop.patternExtract.toast.extractionFailedDetail'),
});
},
});
@@ -253,7 +275,13 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}
getPlaceholderTooltip(placeholder: PatternPlaceholder): string {
return `${placeholder.description} (e.g., ${placeholder.example})`;
const description = this.t.translate(`bookdrop.patternExtract.${placeholder.descriptionKey}`);
const example = this.t.translate(`bookdrop.patternExtract.${placeholder.exampleKey}`);
return `${description} (e.g., ${example})`;
}
getCommonPatternLabel(labelKey: string): string {
return this.t.translate(`bookdrop.patternExtract.${labelKey}`);
}
getPreviewClass(preview: PreviewResult): Record<string, boolean> {
@@ -272,10 +300,10 @@ export class BookdropPatternExtractDialogComponent implements OnInit {
}
getErrorMessage(preview: PreviewResult): string {
return preview.errorMessage || 'Pattern did not match';
return preview.errorMessage || this.t.translate('bookdrop.patternExtract.patternDidNotMatch');
}
getErrorTooltip(preview: PreviewResult): string {
return preview.success ? '' : (preview.errorMessage || 'Pattern did not match filename structure');
return preview.success ? '' : (preview.errorMessage || this.t.translate('bookdrop.patternExtract.patternDidNotMatchStructure'));
}
}