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 @@
@if ((libraryState$ | async)?.libraries; as libraries) {
<ng-container *transloco="let t; prefix: 'shared.bookUploader'">
<div class="book-uploader">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-cloud-upload header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Upload Books</h2>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">
Upload your books to library or bookdrop folder
{{ t('description') }}
</p>
</div>
<p-button
@@ -24,7 +25,7 @@
<div class="section-header">
<span class="section-title">
<i class="pi pi-map-marker"></i>
Upload Destination
{{ t('uploadDestination') }}
</span>
</div>
<div class="destination-selector">
@@ -44,28 +45,28 @@
<div class="section-header">
<span class="section-title">
<i class="pi pi-building"></i>
Library Selection
{{ t('librarySelection') }}
</span>
</div>
<div class="selection-fields">
<div class="field-group">
<label for="library-select" class="field-label">Library</label>
<label for="library-select" class="field-label">{{ t('libraryLabel') }}</label>
<p-select
inputId="library-select"
[options]="libraries"
optionLabel="name"
placeholder="Select Library"
[placeholder]="t('selectLibrary')"
[(ngModel)]="selectedLibrary"
class="full-width">
</p-select>
</div>
<div class="field-group">
<label for="subpath-select" class="field-label">Subpath</label>
<label for="subpath-select" class="field-label">{{ t('subpathLabel') }}</label>
<p-select
inputId="subpath-select"
[options]="selectedLibrary?.paths"
optionLabel="path"
placeholder="Select Subpath"
[placeholder]="t('selectSubpath')"
[(ngModel)]="selectedPath"
[disabled]="!selectedLibrary"
class="full-width">
@@ -81,7 +82,7 @@
<div class="section-header">
<span class="section-title">
<i class="pi pi-file"></i>
Select Files
{{ t('selectFiles') }}
</span>
</div>
<p-fileupload
@@ -98,30 +99,30 @@
severity="info"
(onClick)="choose($event, chooseCallback)"
icon="pi pi-images"
label="Choose"
[label]="t('chooseBtn')"
[outlined]="true"
[disabled]="isChooseDisabled()"
pTooltip="Choose files to upload"
[pTooltip]="t('chooseTooltip')"
tooltipPosition="top"/>
<p-button
(onClick)="uploadEvent(uploadCallback)"
icon="pi pi-cloud-upload"
label="Upload"
[label]="t('uploadBtn')"
severity="success"
[disabled]="isUploadDisabled()"
pTooltip="Start uploading selected files"
[pTooltip]="t('uploadTooltip')"
tooltipPosition="top"/>
<p-button
(onClick)="onClear(clearCallback)"
icon="pi pi-times"
label="Clear"
[label]="t('clearBtn')"
severity="danger"
[outlined]="true"
[disabled]="!filesPresent() || isUploading"
pTooltip="Clear selected files"
[pTooltip]="t('clearTooltip')"
tooltipPosition="top"/>
</div>
<small class="upload-hint">Click "Choose" to select files or drag and drop them below</small>
<small class="upload-hint">{{ t('uploadHint') }}</small>
</div>
</ng-template>
<ng-template #content let-files let-removeFileCallback="removeFileCallback">
@@ -132,16 +133,16 @@
<span class="progress-status">
@if (isUploading) {
<i class="pi pi-spin pi-spinner"></i>
Uploading...
{{ t('uploading') }}
} @else {
<i class="pi pi-check-circle"></i>
Complete
{{ t('complete') }}
}
</span>
<span class="progress-files">
{{ getUploadedCount() }}/{{ this.files.length }} files
{{ t('filesCount', { uploaded: getUploadedCount(), total: this.files.length }) }}
@if (getFailedCount() > 0) {
<span class="failed-count">({{ getFailedCount() }} failed)</span>
<span class="failed-count">{{ t('failedCount', { count: getFailedCount() }) }}</span>
}
</span>
<span class="progress-bytes">{{ formatSize(getUploadedBytes()) }} / {{ formatSize(getTotalBytes()) }}</span>
@@ -187,7 +188,7 @@
@if (hasUploadCompleted()) {
<i
class="pi pi-exclamation-triangle status-icon warning"
[pTooltip]="uploadFile.errorMessage || 'File too large'"
[pTooltip]="uploadFile.errorMessage || t('fileTooLargeTooltip')"
tooltipPosition="top">
</i>
} @else {
@@ -201,7 +202,7 @@
} @else {
<i
class="pi pi-exclamation-triangle status-icon error"
[pTooltip]="uploadFile.errorMessage || 'Upload failed'"
[pTooltip]="uploadFile.errorMessage || t('uploadFailedTooltip')"
tooltipPosition="top">
</i>
}
@@ -219,11 +220,11 @@
<div class="empty-icon-wrapper">
<i class="pi pi-cloud-upload empty-icon" [class.active]="isUploadZoneActive()"></i>
</div>
<h3 class="empty-title">Drag and Drop Files</h3>
<h3 class="empty-title">{{ t('dragDropTitle') }}</h3>
<p class="empty-description">
Supported formats: <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, <strong>.cb7</strong>, <strong>.fb2</strong>, <strong>.m4b</strong>, <strong>.mp3</strong>
<span [innerHTML]="t('supportedFormats')"></span>
<br/>
Maximum file size: {{ maxFileSizeDisplay }} per file
{{ t('maxFileSize', { size: maxFileSizeDisplay }) }}
</p>
</div>
</ng-template>
@@ -231,4 +232,5 @@
</div>
</div>
</div>
</ng-container>
}
@@ -20,6 +20,7 @@ import {AppSettings} from '../../model/app-settings.model';
import {SelectButton} from 'primeng/selectbutton';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {ProgressBar} from 'primeng/progressbar';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
interface UploadingFile {
file: File;
@@ -40,7 +41,8 @@ interface UploadingFile {
Badge,
Tooltip,
SelectButton,
ProgressBar
ProgressBar,
TranslocoDirective
],
templateUrl: './book-uploader.component.html',
styleUrl: './book-uploader.component.scss'
@@ -59,14 +61,15 @@ export class BookUploaderComponent implements OnInit {
private readonly appSettingsService = inject(AppSettingsService);
private readonly http = inject(HttpClient);
private readonly ref = inject(DynamicDialogRef);
private readonly t = inject(TranslocoService);
readonly libraryState$: Observable<LibraryState> = this.libraryService.libraryState$;
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
maxFileSizeBytes?: number;
maxFileSizeDisplay: string = '100 MB';
stateOptions = [
{label: 'Library', value: 'library'},
{label: 'Bookdrop', value: 'bookdrop'}
{label: this.t.translate('shared.bookUploader.destinationLibrary'), value: 'library'},
{label: this.t.translate('shared.bookUploader.destinationBookdrop'), value: 'bookdrop'}
];
value = 'library';
@@ -124,8 +127,8 @@ export class BookUploaderComponent implements OnInit {
if (this.value === 'library' && (!this.selectedLibrary || !this.selectedPath)) {
this.messageService.add({
severity: 'error',
summary: 'No Destination Selected',
detail: 'Please select a library and subpath before adding files.',
summary: this.t.translate('shared.bookUploader.toast.noDestinationSummary'),
detail: this.t.translate('shared.bookUploader.toast.noDestinationDetail'),
life: 5000
});
// We need to clear the files input explicitely, otherwise the files remain selected in the file upload component
@@ -150,8 +153,8 @@ export class BookUploaderComponent implements OnInit {
});
this.messageService.add({
severity: 'error',
summary: 'File Too Large',
detail: `${file.name} exceeds the maximum file size of ${this.formatSize(this.maxFileSizeBytes)}`,
summary: this.t.translate('shared.bookUploader.toast.fileTooLargeSummary'),
detail: this.t.translate('shared.bookUploader.toast.fileTooLargeDetail', {fileName: file.name, maxSize: this.formatSize(this.maxFileSizeBytes)}),
life: 5000
});
} else {
@@ -179,8 +182,8 @@ export class BookUploaderComponent implements OnInit {
if (this.value === 'library' && (!this.selectedLibrary || !this.selectedPath)) {
this.messageService.add({
severity: 'warn',
summary: 'Missing Data',
detail: 'Please select a library and path before uploading.',
summary: this.t.translate('shared.bookUploader.toast.missingDataSummary'),
detail: this.t.translate('shared.bookUploader.toast.missingDataDetail'),
life: 4000
});
return;
@@ -251,7 +254,7 @@ export class BookUploaderComponent implements OnInit {
error: (err) => {
uploadFile.status = 'Failed';
uploadFile.progress = 0;
uploadFile.errorMessage = err?.error?.message || 'Upload failed due to unknown error.';
uploadFile.errorMessage = err?.error?.message || this.t.translate('shared.bookUploader.toast.uploadFailedDefault');
if (--pending === 0) {
setTimeout(() => {
this.uploadBatch(files, startIndex + batchSize, batchSize, destination, libraryId, pathId);
@@ -305,17 +308,17 @@ export class BookUploaderComponent implements OnInit {
getFileStatusLabel(uploadFile: UploadingFile): string {
if (uploadFile.status === 'Failed' && uploadFile.errorMessage?.includes('exceeds maximum size')) {
return 'Too Large';
return this.t.translate('shared.bookUploader.statusTooLarge');
}
switch (uploadFile.status) {
case 'Pending':
return 'Ready';
return this.t.translate('shared.bookUploader.statusReady');
case 'Uploading':
return 'Uploading';
return this.t.translate('shared.bookUploader.statusUploading');
case 'Uploaded':
return 'Uploaded';
return this.t.translate('shared.bookUploader.statusUploaded');
case 'Failed':
return 'Failed';
return this.t.translate('shared.bookUploader.statusFailed');
default:
return uploadFile.status;
}
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'shared.changePassword'">
<div class="change-password-container">
<div class="change-password-card-wrapper">
<div class="change-password-card-border">
@@ -8,15 +9,15 @@
<i class="pi pi-key"></i>
</div>
</div>
<h1 class="change-password-title">Change Password</h1>
<p class="change-password-subtitle">Update your password to keep your account secure</p>
<h1 class="change-password-title">{{ t('title') }}</h1>
<p class="change-password-subtitle">{{ t('subtitle') }}</p>
</div>
<form class="change-password-form" #changePasswordForm="ngForm" (ngSubmit)="changePassword()">
<div class="form-field">
<label for="currentPassword" class="form-label">
<i class="pi pi-lock"></i>
<span>Current Password</span>
<span>{{ t('currentPasswordLabel') }}</span>
</label>
<p-password
id="currentPassword"
@@ -24,7 +25,7 @@
required
[(ngModel)]="currentPassword"
[feedback]="false"
placeholder="Enter your current password"
[placeholder]="t('currentPasswordPlaceholder')"
[toggleMask]="true"
[fluid]="true"
autocomplete="current-password"
@@ -34,7 +35,7 @@
<div class="form-field">
<label for="newPassword" class="form-label">
<i class="pi pi-lock-open"></i>
<span>New Password</span>
<span>{{ t('newPasswordLabel') }}</span>
</label>
<p-password
id="newPassword"
@@ -42,7 +43,7 @@
required
[(ngModel)]="newPassword"
[feedback]="false"
placeholder="Enter your new password"
[placeholder]="t('newPasswordPlaceholder')"
[toggleMask]="true"
[fluid]="true"
autocomplete="new-password"
@@ -52,7 +53,7 @@
<div class="form-field">
<label for="confirmNewPassword" class="form-label">
<i class="pi pi-check-circle"></i>
<span>Confirm New Password</span>
<span>{{ t('confirmPasswordLabel') }}</span>
</label>
<p-password
id="confirmNewPassword"
@@ -60,7 +61,7 @@
required
[(ngModel)]="confirmNewPassword"
[feedback]="false"
placeholder="Confirm your new password"
[placeholder]="t('confirmPasswordPlaceholder')"
[toggleMask]="true"
[fluid]="true"
autocomplete="new-password"
@@ -68,7 +69,7 @@
@if (!passwordsMatch && confirmNewPassword) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
New passwords do not match
{{ t('validation.passwordsMismatch') }}
</small>
}
</div>
@@ -76,7 +77,7 @@
<p-button
fluid
type="submit"
label="Update Password"
[label]="t('updateBtn')"
icon="pi pi-check"
[disabled]="!changePasswordForm.valid || !passwordsMatch"
class="change-password-button"
@@ -98,3 +99,4 @@
</div>
</div>
</div>
</ng-container>
@@ -7,6 +7,7 @@ import {Password} from 'primeng/password';
import {MessageService} from 'primeng/api';
import {UserService} from '../../../features/settings/user-management/user.service';
import {AuthService} from '../../service/auth.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-change-password',
@@ -16,7 +17,8 @@ import {AuthService} from '../../service/auth.service';
FormsModule,
Message,
Password,
ReactiveFormsModule
ReactiveFormsModule,
TranslocoDirective
],
templateUrl: './change-password.component.html',
styleUrl: './change-password.component.scss'
@@ -31,6 +33,7 @@ export class ChangePasswordComponent {
protected userService = inject(UserService);
protected authService = inject(AuthService);
protected messageService = inject(MessageService);
private readonly t = inject(TranslocoService);
get passwordsMatch(): boolean {
return this.newPassword === this.confirmNewPassword;
@@ -41,31 +44,31 @@ export class ChangePasswordComponent {
this.successMessage = null;
if (!this.currentPassword || !this.newPassword || !this.confirmNewPassword) {
this.errorMessage = 'All fields are required.';
this.errorMessage = this.t.translate('shared.changePassword.validation.allFieldsRequired');
return;
}
if (!this.passwordsMatch) {
this.errorMessage = 'New passwords do not match.';
this.errorMessage = this.t.translate('shared.changePassword.validation.passwordsDoNotMatch');
return;
}
if (this.currentPassword === this.newPassword) {
this.errorMessage = 'New password cannot be the same as the current password.';
this.errorMessage = this.t.translate('shared.changePassword.validation.sameAsCurrentPassword');
return;
}
this.userService.changePassword(this.currentPassword, this.newPassword).subscribe({
next: () => {
this.successMessage = 'Password changed successfully!';
this.successMessage = this.t.translate('shared.changePassword.toast.success');
this.logout();
},
error: (err) => {
this.errorMessage = err.message;
this.messageService.add({
severity: 'error',
summary: 'Password Change Failed',
detail: this.errorMessage ?? 'An unknown error occurred.'
summary: this.t.translate('shared.changePassword.toast.failedSummary'),
detail: this.errorMessage ?? this.t.translate('shared.changePassword.toast.failedDetailDefault')
});
}
});
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'shared.directoryPicker'">
<div class="directory-picker">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-folder-open header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Select Directories</h2>
<p class="panel-description">Choose one or more directories from your file system</p>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
</div>
@@ -13,7 +14,7 @@
<div class="current-path">
<div class="path-label">
<i class="pi pi-map-marker"></i>
<span>Current Path:</span>
<span>{{ t('currentPath') }}</span>
</div>
<div class="path-value">
{{ selectedProductName || '/' }}
@@ -29,7 +30,7 @@
pInputText
[(ngModel)]="searchQuery"
(input)="onSearch()"
placeholder="Search folders..."
[placeholder]="t('searchPlaceholder')"
/>
@if (searchQuery) {
<i class="pi pi-times clear-icon" (click)="searchQuery = ''; onSearch()"></i>
@@ -39,43 +40,43 @@
icon="pi pi-arrow-up"
(click)="goUp()"
[disabled]="selectedProductName === '/' || selectedProductName === ''"
pTooltip="Go up one level"
[pTooltip]="t('goUpTooltip')"
tooltipPosition="bottom"
/>
</div>
<div class="selection-actions">
<p-button
label="Select All"
[label]="t('selectAllBtn')"
icon="pi pi-check-square"
severity="secondary"
[outlined]="true"
size="small"
(click)="selectAll()"
[disabled]="filteredPaths.length === 0"
pTooltip="Select all visible folders"
[pTooltip]="t('selectAllTooltip')"
tooltipPosition="bottom"
/>
<p-button
label="Deselect All"
[label]="t('deselectAllBtn')"
icon="pi pi-times-circle"
severity="secondary"
[outlined]="true"
size="small"
(click)="deselectAll()"
[disabled]="selectedFolders.length === 0"
pTooltip="Clear all selections"
[pTooltip]="t('deselectAllTooltip')"
tooltipPosition="bottom"
/>
<p-button
label="Select Current"
[label]="t('selectCurrentBtn')"
icon="pi pi-folder"
severity="info"
[outlined]="true"
size="small"
(click)="selectCurrent()"
[disabled]="!selectedProductName || selectedProductName === '/'"
pTooltip="Select the current directory"
[pTooltip]="t('selectCurrentTooltip')"
tooltipPosition="bottom"
/>
</div>
@@ -83,7 +84,7 @@
@if (selectedFolders.length > 0) {
<div class="selection-badge">
<i class="pi pi-check-circle"></i>
<span>{{ selectedFolders.length }} {{ selectedFolders.length === 1 ? 'folder' : 'folders' }} selected</span>
<span>{{ selectedFolders.length === 1 ? t('foldersSelected', { count: selectedFolders.length }) : t('foldersSelectedPlural', { count: selectedFolders.length }) }}</span>
</div>
}
</div>
@@ -96,7 +97,7 @@
strokeWidth="4"
animationDuration="1s"
/>
<p class="loading-text">Loading directories...</p>
<p class="loading-text">{{ t('loadingDirectories') }}</p>
</div>
} @else if (filteredPaths.length === 0) {
<div class="empty-state">
@@ -105,16 +106,16 @@
</div>
<h3 class="empty-title">
@if (searchQuery) {
No Matches Found
{{ t('noMatchesFound') }}
} @else {
Directory is Empty
{{ t('directoryEmpty') }}
}
</h3>
<p class="empty-description">
@if (searchQuery) {
No folders match your search criteria.<br/>Try adjusting your search terms.
<span [innerHTML]="t('noMatchesDescription')"></span>
} @else {
This directory doesn't contain any subfolders.
{{ t('emptyDescription') }}
}
</p>
</div>
@@ -123,7 +124,7 @@
<div class="list-header">
<span class="folder-count">
<i class="pi pi-folder"></i>
{{ filteredPaths.length }} {{ filteredPaths.length === 1 ? 'folder' : 'folders' }} available
{{ filteredPaths.length === 1 ? t('folderAvailable', { count: filteredPaths.length }) : t('foldersAvailable', { count: filteredPaths.length }) }}
</span>
</div>
@@ -164,19 +165,19 @@
@if (selectedFolders.length > 0) {
<span class="selection-info">
<i class="pi pi-info-circle"></i>
{{ selectedFolders.length }} folder{{ selectedFolders.length !== 1 ? 's' : '' }} will be selected
{{ selectedFolders.length === 1 ? t('folderWillBeSelected', { count: selectedFolders.length }) : t('foldersWillBeSelected', { count: selectedFolders.length }) }}
</span>
}
</div>
<div class="footer-actions">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
severity="secondary"
[outlined]="true"
(click)="onCancel()"
/>
<p-button
label="Select Directories"
[label]="t('selectDirectoriesBtn')"
icon="pi pi-check"
severity="success"
(click)="onSelect()"
@@ -185,3 +186,4 @@
</div>
</div>
</div>
</ng-container>
@@ -12,6 +12,7 @@ import {InputIcon} from 'primeng/inputicon';
import {Button} from 'primeng/button';
import {IconField} from 'primeng/iconfield';
import {Tooltip} from 'primeng/tooltip';
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
@Component({
selector: 'app-directory-picker-v2',
@@ -27,7 +28,9 @@ import {Tooltip} from 'primeng/tooltip';
Button,
InputIcon,
IconField,
Tooltip
Tooltip,
TranslocoDirective,
TranslocoPipe
],
styleUrls: ['./directory-picker.component.scss']
})
@@ -1,137 +1,139 @@
<div class="login-container">
<div class="login-card-wrapper">
<div class="login-card-border">
<div class="login-card">
<div class="login-header">
<div class="logo-wrapper">
<svg class="logo-icon" viewBox="0 0 126 126" fill="var(--primary-color)" xmlns="http://www.w3.org/2000/svg">
<path
d="M59 4.79297C71.5051 11.5557 80 24.7854 80 40C80 40.5959 79.987 41.1888 79.9609 41.7783C79.8609 44.0406 81.7355 46 84 46C106.091 46 124 63.9086 124 86C124 108.091 106.091 126 84 126H10C4.47715 126 0 121.523 0 116V39.0068L0.0126953 38.9941C0.357624 25.0252 7.86506 12.8347 19 5.95215V63.832C19 64.8345 20.0676 65.4391 20.9121 64.9902L21.0771 64.8867L38.2227 52.3428C38.6819 52.0068 39.3064 52.0068 39.7656 52.3428L56.9229 64.8945L57.0879 64.998C57.9324 65.447 59 64.8423 59 63.8398V4.79297Z"/>
<path
d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z"
fill="white"/>
</svg>
</div>
<h1 class="login-title">Welcome Back</h1>
<p class="login-subtitle">Sign in to continue your journey</p>
</div>
@if (showOidcBypassInfo) {
<div class="oidc-warning">
<div class="warning-content">
<div class="warning-header">
<i class="pi pi-exclamation-triangle"></i>
<span>OIDC Authentication Issues</span>
</div>
<p class="warning-message">{{ oidcBypassMessage }}</p>
<div class="warning-actions">
<p-button
size="small"
severity="warn"
label="Retry OIDC"
icon="pi pi-refresh"
(click)="retryOidc()"
/>
<p-button
size="small"
severity="success"
label="Use Local Login"
icon="pi pi-times"
(click)="dismissOidcWarning()"
/>
</div>
<ng-container *transloco="let t; prefix: 'auth.login'">
<div class="login-container">
<div class="login-card-wrapper">
<div class="login-card-border">
<div class="login-card">
<div class="login-header">
<div class="logo-wrapper">
<svg class="logo-icon" viewBox="0 0 126 126" fill="var(--primary-color)" xmlns="http://www.w3.org/2000/svg">
<path
d="M59 4.79297C71.5051 11.5557 80 24.7854 80 40C80 40.5959 79.987 41.1888 79.9609 41.7783C79.8609 44.0406 81.7355 46 84 46C106.091 46 124 63.9086 124 86C124 108.091 106.091 126 84 126H10C4.47715 126 0 121.523 0 116V39.0068L0.0126953 38.9941C0.357624 25.0252 7.86506 12.8347 19 5.95215V63.832C19 64.8345 20.0676 65.4391 20.9121 64.9902L21.0771 64.8867L38.2227 52.3428C38.6819 52.0068 39.3064 52.0068 39.7656 52.3428L56.9229 64.8945L57.0879 64.998C57.9324 65.447 59 64.8423 59 63.8398V4.79297Z"/>
<path
d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z"
fill="white"/>
</svg>
</div>
</div>
}
<form class="login-form" #loginForm="ngForm" (ngSubmit)="login()">
<div class="form-field">
<label for="username" class="form-label">
<i class="pi pi-user"></i>
<span>Username</span>
</label>
<input
fluid
pInputText
id="username"
name="username"
required
[(ngModel)]="username"
placeholder="Enter your username"
class="form-input"
autocomplete="username"
/>
<h1 class="login-title">{{ t('title') }}</h1>
<p class="login-subtitle">{{ t('subtitle') }}</p>
</div>
<div class="form-field">
<label for="password" class="form-label">
<i class="pi pi-lock"></i>
<span>Password</span>
</label>
<p-password
id="password"
name="password"
required
[(ngModel)]="password"
[feedback]="false"
placeholder="Enter your password"
[toggleMask]="true"
[fluid]="true"
autocomplete="current-password"
></p-password>
</div>
<p-button
fluid
type="submit"
label="Sign In"
icon="pi pi-sign-in"
[disabled]="!loginForm.valid || !username || !password"
class="login-button">
</p-button>
@if (errorMessage) {
<div class="error-message">
<p-message severity="error">{{ errorMessage }}</p-message>
@if (showOidcBypassInfo) {
<div class="oidc-warning">
<div class="warning-content">
<div class="warning-header">
<i class="pi pi-exclamation-triangle"></i>
<span>{{ t('oidcWarningTitle') }}</span>
</div>
<p class="warning-message">{{ oidcBypassMessage }}</p>
<div class="warning-actions">
<p-button
size="small"
severity="warn"
[label]="t('retryOidc')"
icon="pi pi-refresh"
(click)="retryOidc()"
/>
<p-button
size="small"
severity="success"
[label]="t('useLocalLogin')"
icon="pi pi-times"
(click)="dismissOidcWarning()"
/>
</div>
</div>
</div>
}
@if (oidcEnabled && !isOidcBypassed) {
<div class="divider">
<span>or continue with</span>
<form class="login-form" #loginForm="ngForm" (ngSubmit)="login()">
<div class="form-field">
<label for="username" class="form-label">
<i class="pi pi-user"></i>
<span>{{ t('usernameLabel') }}</span>
</label>
<input
fluid
pInputText
id="username"
name="username"
required
[(ngModel)]="username"
[placeholder]="t('usernamePlaceholder')"
class="form-input"
autocomplete="username"
/>
</div>
<div class="form-field">
<label for="password" class="form-label">
<i class="pi pi-lock"></i>
<span>{{ t('passwordLabel') }}</span>
</label>
<p-password
id="password"
name="password"
required
[(ngModel)]="password"
[feedback]="false"
[placeholder]="t('passwordPlaceholder')"
[toggleMask]="true"
[fluid]="true"
autocomplete="current-password"
></p-password>
</div>
<p-button
fluid
severity="secondary"
[label]="isOidcLoginInProgress ? 'Redirecting to ' + oidcName + '...' : oidcName"
[icon]="isOidcLoginInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-id-card'"
[disabled]="isOidcLoginInProgress"
(click)="loginWithOidc()"
class="oidc-button"/>
type="submit"
[label]="t('signIn')"
icon="pi pi-sign-in"
[disabled]="!loginForm.valid || !username || !password"
class="login-button">
</p-button>
<div class="help-text">
<button
type="button"
class="text-link"
(click)="bypassOidc()">
Having trouble with {{ oidcName }}? Use local login
</button>
</div>
}
@if (errorMessage) {
<div class="error-message">
<p-message severity="error">{{ errorMessage }}</p-message>
</div>
}
@if (oidcEnabled && isOidcBypassed) {
<div class="help-text">
<button
type="button"
class="text-link primary"
(click)="enableOidc()">
Re-enable {{ oidcName }} login
</button>
</div>
}
</form>
@if (oidcEnabled && !isOidcBypassed) {
<div class="divider">
<span>{{ t('orContinueWith') }}</span>
</div>
<p-button
fluid
severity="secondary"
[label]="isOidcLoginInProgress ? t('redirectingTo', {provider: oidcName}) : oidcName"
[icon]="isOidcLoginInProgress ? 'pi pi-spin pi-spinner' : 'pi pi-id-card'"
[disabled]="isOidcLoginInProgress"
(click)="loginWithOidc()"
class="oidc-button"/>
<div class="help-text">
<button
type="button"
class="text-link"
(click)="bypassOidc()">
{{ t('oidcTrouble', {provider: oidcName}) }}
</button>
</div>
}
@if (oidcEnabled && isOidcBypassed) {
<div class="help-text">
<button
type="button"
class="text-link primary"
(click)="enableOidc()">
{{ t('reEnableOidc', {provider: oidcName}) }}
</button>
</div>
}
</form>
</div>
</div>
</div>
</div>
</div>
</ng-container>
@@ -11,6 +11,7 @@ import {Observable, Subject} from 'rxjs';
import {filter, take} from 'rxjs/operators';
import {getOidcErrorCount, isOidcBypassed, resetOidcBypass} from '../../../core/security/auth-initializer';
import {AppSettingsService, PublicAppSettings} from '../../service/app-settings.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-login',
@@ -19,7 +20,8 @@ import {AppSettingsService, PublicAppSettings} from '../../service/app-settings.
Password,
Button,
Message,
InputText
InputText,
TranslocoDirective
],
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
@@ -39,6 +41,7 @@ export class LoginComponent implements OnInit, OnDestroy {
private oAuthService = inject(OAuthService);
private appSettingsService = inject(AppSettingsService);
private router = inject(Router);
private translocoService = inject(TranslocoService);
publicAppSettings$: Observable<PublicAppSettings | null> = this.appSettingsService.publicAppSettings$;
@@ -65,11 +68,11 @@ export class LoginComponent implements OnInit, OnDestroy {
this.showOidcBypassInfo = true;
if (this.isOidcBypassed && errorCount >= 3) {
this.oidcBypassMessage = `${this.oidcName} authentication has been automatically disabled after ${errorCount} consecutive failures (including timeouts). You can retry or continue with local login.`;
this.oidcBypassMessage = this.translocoService.translate('auth.login.oidcAutoDisabled', {provider: this.oidcName, count: errorCount});
} else if (this.isOidcBypassed) {
this.oidcBypassMessage = `${this.oidcName} authentication has been manually disabled. You can re-enable it or continue with local login.`;
this.oidcBypassMessage = this.translocoService.translate('auth.login.oidcManuallyDisabled', {provider: this.oidcName});
} else if (errorCount > 0) {
this.oidcBypassMessage = `${this.oidcName} authentication encountered ${errorCount} error(s), possibly due to timeouts or server issues.`;
this.oidcBypassMessage = this.translocoService.translate('auth.login.oidcErrors', {provider: this.oidcName, count: errorCount});
}
}
}
@@ -85,9 +88,9 @@ export class LoginComponent implements OnInit, OnDestroy {
},
error: (error) => {
if (error.status === 0) {
this.errorMessage = 'Cannot connect to the server. Please check your connection and try again.';
this.errorMessage = this.translocoService.translate('auth.login.connectionError');
} else {
this.errorMessage = error?.error?.message || 'An unexpected error occurred. Please try again.';
this.errorMessage = error?.error?.message || this.translocoService.translate('auth.login.unexpectedError');
}
}
});
@@ -108,7 +111,7 @@ export class LoginComponent implements OnInit, OnDestroy {
this.oAuthService.initCodeFlow();
} catch (error) {
console.error('OIDC login initiation failed:', error);
this.errorMessage = 'Failed to initiate OIDC login. Please try again or use local login.';
this.errorMessage = this.translocoService.translate('auth.login.oidcInitError');
this.isOidcLoginInProgress = false;
}
}
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'shared.setup'">
<div class="setup-container">
<div class="setup-card-wrapper">
<div class="setup-card-border">
@@ -12,15 +13,15 @@
fill="white"/>
</svg>
</div>
<h1 class="setup-title">Welcome to Booklore</h1>
<p class="setup-subtitle">Setup your initial admin account to get started</p>
<h1 class="setup-title">{{ t('title') }}</h1>
<p class="setup-subtitle">{{ t('subtitle') }}</p>
</div>
<form class="setup-form" [formGroup]="setupForm" (ngSubmit)="onSubmit()">
<div class="form-field">
<label for="username" class="form-label">
<i class="pi pi-user"></i>
<span>Username</span>
<span>{{ t('usernameLabel') }}</span>
</label>
<input
pInputText
@@ -28,14 +29,14 @@
name="username"
required
formControlName="username"
placeholder="Choose a username"
[placeholder]="t('usernamePlaceholder')"
class="form-input"
autocomplete="username"
/>
@if (setupForm.get('username')?.invalid && setupForm.get('username')?.touched) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Username is required
{{ t('validation.usernameRequired') }}
</small>
}
</div>
@@ -43,7 +44,7 @@
<div class="form-field">
<label for="name" class="form-label">
<i class="pi pi-id-card"></i>
<span>Full Name</span>
<span>{{ t('fullNameLabel') }}</span>
</label>
<input
pInputText
@@ -51,14 +52,14 @@
name="name"
required
formControlName="name"
placeholder="Enter your full name"
[placeholder]="t('fullNamePlaceholder')"
class="form-input"
autocomplete="name"
/>
@if (setupForm.get('name')?.invalid && setupForm.get('name')?.touched) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Name is required
{{ t('validation.nameRequired') }}
</small>
}
</div>
@@ -66,7 +67,7 @@
<div class="form-field">
<label for="email" class="form-label">
<i class="pi pi-envelope"></i>
<span>Email Address</span>
<span>{{ t('emailLabel') }}</span>
</label>
<input
pInputText
@@ -75,14 +76,14 @@
type="email"
required
formControlName="email"
placeholder="Enter your email address"
[placeholder]="t('emailPlaceholder')"
class="form-input"
autocomplete="email"
/>
@if (setupForm.get('email')?.invalid && setupForm.get('email')?.touched) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Valid email is required
{{ t('validation.emailRequired') }}
</small>
}
</div>
@@ -90,7 +91,7 @@
<div class="form-field">
<label for="password" class="form-label">
<i class="pi pi-lock"></i>
<span>Password</span>
<span>{{ t('passwordLabel') }}</span>
</label>
<input
pInputText
@@ -99,14 +100,14 @@
type="password"
required
formControlName="password"
placeholder="Create a secure password"
[placeholder]="t('passwordPlaceholder')"
class="form-input"
autocomplete="new-password"
/>
@if (setupForm.get('password')?.invalid && setupForm.get('password')?.touched) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Minimum 6 characters required
{{ t('validation.passwordMinLength') }}
</small>
}
</div>
@@ -114,7 +115,7 @@
<div class="form-field">
<label for="confirmPassword" class="form-label">
<i class="pi pi-lock"></i>
<span>Confirm Password</span>
<span>{{ t('confirmPasswordLabel') }}</span>
</label>
<input
pInputText
@@ -123,20 +124,20 @@
type="password"
required
formControlName="confirmPassword"
placeholder="Re-enter your password"
[placeholder]="t('confirmPasswordPlaceholder')"
class="form-input"
autocomplete="new-password"
/>
@if (setupForm.get('confirmPassword')?.invalid && setupForm.get('confirmPassword')?.touched) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Password confirmation is required
{{ t('validation.confirmPasswordRequired') }}
</small>
}
@if (setupForm.get('confirmPassword')?.touched && setupForm.hasError('passwordMismatch')) {
<small class="field-error">
<i class="pi pi-exclamation-circle"></i>
Passwords do not match
{{ t('validation.passwordsMismatch') }}
</small>
}
</div>
@@ -144,7 +145,7 @@
<p-button
fluid
type="submit"
[label]="loading ? 'Creating Account...' : 'Create Admin Account'"
[label]="loading ? t('creatingAccountBtn') : t('createAccountBtn')"
[icon]="loading ? 'pi pi-spin pi-spinner' : 'pi pi-user-plus'"
[disabled]="loading || setupForm.invalid"
class="setup-button"
@@ -158,7 +159,7 @@
@if (success) {
<div class="message-container success-message">
<p-message severity="success">Admin account created successfully! Redirecting...</p-message>
<p-message severity="success">{{ t('successMessage') }}</p-message>
</div>
}
</form>
@@ -166,3 +167,4 @@
</div>
</div>
</div>
</ng-container>
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, inject} from '@angular/core';
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
import {Router} from '@angular/router';
import {SetupService} from './setup.service';
@@ -6,6 +6,7 @@ import {InputText} from 'primeng/inputtext';
import {Button} from 'primeng/button';
import {Message} from 'primeng/message';
import {passwordMatchValidator} from '../../validators/password-match.validator';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-setup',
@@ -16,7 +17,8 @@ import {passwordMatchValidator} from '../../validators/password-match.validator'
ReactiveFormsModule,
InputText,
Button,
Message
Message,
TranslocoDirective
]
})
export class SetupComponent {
@@ -24,6 +26,7 @@ export class SetupComponent {
loading = false;
error: string | null = null;
success = false;
private readonly t = inject(TranslocoService);
constructor(
private fb: FormBuilder,
@@ -55,7 +58,7 @@ export class SetupComponent {
error: (err) => {
this.loading = false;
this.error =
err?.error?.message || 'Failed to create admin user. Try again.';
err?.error?.message || this.t.translate('shared.setup.toast.createFailedDefault');
},
});
}
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'layout.menu'">
<div class="menu-container">
<div>
<ul class="layout-menu">
@@ -63,10 +64,11 @@
(click)="openChangelogDialog()"
class="update-link"
>
(Update)
{{ t('update') }}
</a>
</div>
}
</div>
}
</div>
</ng-container>
@@ -14,11 +14,12 @@ import {UserService} from '../../../../features/settings/user-management/user.se
import {MagicShelfService, MagicShelfState} from '../../../../features/magic-shelf/service/magic-shelf.service';
import {MenuItem} from 'primeng/api';
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-menu',
standalone: true,
imports: [AppMenuitemComponent, MenuModule, AsyncPipe],
imports: [AppMenuitemComponent, MenuModule, AsyncPipe, TranslocoDirective],
templateUrl: './app.menu.component.html',
styleUrl: './app.menu.component.scss',
})
@@ -39,6 +40,7 @@ export class AppMenuComponent implements OnInit {
private dialogLauncherService = inject(DialogLauncherService);
private userService = inject(UserService);
private magicShelfService = inject(MagicShelfService);
private t = inject(TranslocoService);
librarySortField: 'name' | 'id' = 'name';
librarySortOrder: 'asc' | 'desc' = 'desc';
@@ -74,15 +76,15 @@ export class AppMenuComponent implements OnInit {
this.homeMenu$ = this.bookService.bookState$.pipe(
map((bookState) => [
{
label: 'Home',
label: this.t.translate('layout.menu.home'),
items: [
{
label: 'Dashboard',
label: this.t.translate('layout.menu.dashboard'),
icon: 'pi pi-fw pi-home',
routerLink: ['/dashboard'],
},
{
label: 'All Books',
label: this.t.translate('layout.menu.allBooks'),
type: 'All Books',
icon: 'pi pi-fw pi-book',
routerLink: ['/all-books'],
@@ -101,7 +103,7 @@ export class AppMenuComponent implements OnInit {
const sortedLibraries = this.sortArray(libraries, this.librarySortField, this.librarySortOrder);
return [
{
label: 'Libraries',
label: this.t.translate('layout.menu.libraries'),
type: 'library',
hasDropDown: true,
hasCreate: true,
@@ -125,7 +127,7 @@ export class AppMenuComponent implements OnInit {
const sortedShelves = this.sortArray(shelves, this.magicShelfSortField, this.magicShelfSortOrder);
return [
{
label: 'Magic Shelves',
label: this.t.translate('layout.menu.magicShelves'),
type: 'magicShelf',
hasDropDown: true,
hasCreate: true,
@@ -165,7 +167,7 @@ export class AppMenuComponent implements OnInit {
}));
const unshelvedItem = {
label: 'Unshelved',
label: this.t.translate('layout.menu.unshelved'),
type: 'Shelf',
icon: 'pi pi-inbox',
iconType: 'PRIME_NG' as 'PRIME_NG' | 'CUSTOM_SVG',
@@ -189,7 +191,7 @@ export class AppMenuComponent implements OnInit {
return [
{
type: 'shelf',
label: 'Shelves',
label: this.t.translate('layout.menu.shelves'),
hasDropDown: true,
hasCreate: true,
items,
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'layout.changelog'">
<div class="changelog-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-sparkles header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">What's New</h2>
<p class="panel-description">Latest updates and improvements</p>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('description') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -20,13 +21,13 @@
<div class="dialog-content">
@if (loading) {
<div class="loading-state">
Loading changelog...
{{ t('loading') }}
</div>
}
@if (!loading && changelog.length === 0) {
<div class="empty-state">
No updates available.
{{ t('empty') }}
</div>
}
@@ -46,3 +47,4 @@
}
</div>
</div>
</ng-container>
@@ -6,13 +6,15 @@ import showdown from 'showdown';
import {DatePipe} from '@angular/common';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {Button} from 'primeng/button';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-version-changelog-dialog',
standalone: true,
imports: [
DatePipe,
Button
Button,
TranslocoDirective
],
templateUrl: './version-changelog-dialog.component.html',
styleUrl: './version-changelog-dialog.component.scss'
@@ -1,3 +1,4 @@
<ng-container *transloco="let t; prefix: 'layout.topbar'">
<div class="layout-topbar">
<a class="layout-topbar-logo topbar-logo" routerLink="">
@@ -32,21 +33,21 @@
@if (userService.userState$ | async; as userState) {
@if (userState.user?.permissions?.canAccessBookdrop || userState.user?.permissions?.admin) {
<li>
<a class="topbar-item" (click)="navigateToBookdrop()" pTooltip="Bookdrop" tooltipPosition="bottom">
<a class="topbar-item" (click)="navigateToBookdrop()" [pTooltip]="t('bookdrop')" tooltipPosition="bottom">
<i class="pi pi-inbox topbar-icon"></i>
</a>
</li>
}
@if (userState.user?.permissions?.canManageLibrary || userState.user?.permissions?.admin) {
<li>
<a class="topbar-item" (click)="openLibraryCreatorDialog()" pTooltip="Create New Library" tooltipPosition="bottom">
<a class="topbar-item" (click)="openLibraryCreatorDialog()" [pTooltip]="t('createNewLibrary')" tooltipPosition="bottom">
<i class="pi pi-plus-circle topbar-icon"></i>
</a>
</li>
}
@if (userState.user?.permissions?.canUpload || userState.user?.permissions?.admin) {
<li>
<a class="topbar-item" (click)="openFileUploadDialog()" pTooltip="Upload Book" tooltipPosition="bottom">
<a class="topbar-item" (click)="openFileUploadDialog()" [pTooltip]="t('uploadBook')" tooltipPosition="bottom">
<i class="pi pi-upload topbar-icon"></i>
</a>
</li>
@@ -74,14 +75,14 @@
@if (userService.userState$ | async; as userState) {
@if (userState.user?.permissions?.canManageLibrary || userState.user?.permissions?.admin) {
<li>
<a class="topbar-item" (click)="navigateToMetadataManager()" pTooltip="Metadata Manager" tooltipPosition="bottom">
<a class="topbar-item" (click)="navigateToMetadataManager()" [pTooltip]="t('metadataManager')" tooltipPosition="bottom">
<i class="pi pi-sparkles topbar-icon"></i>
</a>
</li>
}
}
<li>
<a class="topbar-item" (click)="navigateToSettings()" pTooltip="Settings" tooltipPosition="bottom">
<a class="topbar-item" (click)="navigateToSettings()" [pTooltip]="t('settings')" tooltipPosition="bottom">
<i class="pi pi-cog topbar-icon"></i>
</a>
</li>
@@ -124,6 +125,17 @@
<span class="heart-background"></span>
<i class="pi pi-heart heart-icon"></i>
</li>
<li class="topbar-item-relative">
<button
type="button"
class="topbar-item"
(click)="langMenu.toggle($event)"
[pTooltip]="t('language')"
tooltipPosition="bottom">
<i class="pi pi-language topbar-icon"></i>
</button>
<p-menu #langMenu [model]="langMenuItems" [popup]="true" appendTo="body"/>
</li>
<li class="topbar-item-relative">
<button type="button"
class="topbar-item config-item"
@@ -144,7 +156,7 @@
href="https://booklore.org/docs/getting-started"
target="_blank"
rel="noopener noreferrer"
pTooltip="Documentation"
[pTooltip]="t('documentation')"
tooltipPosition="bottom">
<i class="pi pi-info-circle topbar-icon"></i>
</a>
@@ -154,7 +166,7 @@
@if (userService.userState$ | async; as userState) {
@if (!userState.user?.permissions?.demoUser) {
<li>
<button class="topbar-item" (click)="openUserProfileDialog()" pTooltip="Profile" tooltipPosition="bottom">
<button class="topbar-item" (click)="openUserProfileDialog()" [pTooltip]="t('profile')" tooltipPosition="bottom">
<i class="pi pi-user topbar-icon"></i>
</button>
</li>
@@ -162,7 +174,7 @@
}
<li>
<button class="topbar-item" (click)="logout()" pTooltip="Logout" tooltipPosition="left">
<button class="topbar-item" (click)="logout()" [pTooltip]="t('logout')" tooltipPosition="left">
<i class="pi pi-sign-out topbar-icon"></i>
</button>
</li>
@@ -185,7 +197,7 @@
(click)="navigateToBookdrop(); mobileMenu.hide()"
>
<i class="pi pi-inbox topbar-icon"></i>
Bookdrop
{{ t('bookdrop') }}
</button>
</li>
}
@@ -196,7 +208,7 @@
(click)="openLibraryCreatorDialog(); mobileMenu.hide()"
>
<i class="pi pi-plus-circle topbar-icon"></i>
Create Library
{{ t('createLibrary') }}
</button>
</li>
}
@@ -207,7 +219,7 @@
(click)="openFileUploadDialog(); mobileMenu.hide()"
>
<i class="pi pi-upload topbar-icon"></i>
Upload Book
{{ t('uploadBook') }}
</button>
</li>
}
@@ -224,7 +236,7 @@
<rect x="9" y="6" width="2.5" height="13" rx="0.5" fill="#10b981"/>
<rect x="13" y="8" width="2.5" height="11" rx="0.5" fill="#3b82f6"/>
</svg>
Charts
{{ t('charts') }}
</button>
@if (shouldShowStatsMenu) {
<p-menu #statsMenuMobile [model]="statsMenuItems" [popup]="true"/>
@@ -239,7 +251,7 @@
(click)="navigateToMetadataManager(); mobileMenu.hide()"
>
<i class="pi pi-sparkles topbar-icon"></i>
Metadata Manager
{{ t('metadataManager') }}
</button>
</li>
}
@@ -250,7 +262,7 @@
(click)="navigateToSettings(); mobileMenu.hide()"
>
<i class="pi pi-cog topbar-icon"></i>
Settings
{{ t('settings') }}
</button>
</li>
<li>
@@ -260,16 +272,26 @@
target="_blank"
rel="noopener noreferrer">
<i class="pi pi-info-circle topbar-icon"></i>
Documentation
{{ t('documentation') }}
</a>
</li>
<li>
<button
class="mobile-menu-item"
(click)="langMenuMobile.toggle($event)"
>
<i class="pi pi-language topbar-icon"></i>
{{ t('language') }}
</button>
<p-menu #langMenuMobile [model]="langMenuItems" [popup]="true"/>
</li>
<li>
<button
class="mobile-menu-item"
(click)="openGithubSupportDialog(); mobileMenu.hide()"
>
<i class="pi pi-thumbs-up topbar-icon"></i>
Support BookLore
{{ t('supportBookLore') }}
</button>
</li>
@@ -281,7 +303,7 @@
(click)="openUserProfileDialog(); mobileMenu.hide()"
>
<i class="pi pi-user topbar-icon"></i>
Profile
{{ t('profile') }}
</button>
</li>
}
@@ -293,7 +315,7 @@
(click)="logout(); mobileMenu.hide()"
>
<i class="pi pi-sign-out topbar-icon"></i>
Logout
{{ t('logout') }}
</button>
</li>
</ul>
@@ -301,3 +323,4 @@
</div>
</div>
</div>
</ng-container>
@@ -25,6 +25,9 @@ import {DialogLauncherService} from '../../../services/dialog-launcher.service';
import {UnifiedNotificationBoxComponent} from '../../../components/unified-notification-popover/unified-notification-popover-component';
import {Severity, LogNotification} from '../../../websocket/model/log-notification.model';
import {Menu} from 'primeng/menu';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
import {AVAILABLE_LANGS, LANG_LABELS} from '../../../../core/config/transloco-loader';
import {LANG_STORAGE_KEY} from '../../../../core/config/language-initializer';
@Component({
selector: 'app-topbar',
@@ -47,6 +50,7 @@ import {Menu} from 'primeng/menu';
UnifiedNotificationBoxComponent,
NgStyle,
Menu,
TranslocoDirective,
],
})
export class AppTopBarComponent implements OnDestroy {
@@ -75,6 +79,11 @@ export class AppTopBarComponent implements OnDestroy {
private latestHasPendingFiles = false;
private latestNotificationSeverity?: Severity;
activeLang = '';
langMenuItems: MenuItem[] = [];
private translocoService: TranslocoService;
constructor(
public layoutService: LayoutService,
private notificationService: NotificationEventService,
@@ -83,8 +92,16 @@ export class AppTopBarComponent implements OnDestroy {
protected userService: UserService,
private metadataProgressService: MetadataProgressService,
private bookdropFileService: BookdropFileService,
private dialogLauncher: DialogLauncherService
private dialogLauncher: DialogLauncherService,
translocoService: TranslocoService
) {
this.translocoService = translocoService;
this.activeLang = translocoService.getActiveLang();
this.langMenuItems = AVAILABLE_LANGS.map(lang => ({
label: LANG_LABELS[lang] || lang,
icon: lang === this.activeLang ? 'pi pi-check' : undefined,
command: () => this.switchLanguage(lang),
}));
this.subscribeToMetadataProgress();
this.subscribeToNotifications();
@@ -161,6 +178,20 @@ export class AppTopBarComponent implements OnDestroy {
this.router.navigate(['/reading-stats']);
}
switchLanguage(lang: string) {
if (lang === this.activeLang) return;
this.translocoService.load(lang).subscribe(() => {
this.translocoService.setActiveLang(lang);
localStorage.setItem(LANG_STORAGE_KEY, lang);
this.activeLang = lang;
this.langMenuItems = AVAILABLE_LANGS.map(l => ({
label: LANG_LABELS[l] || l,
icon: l === lang ? 'pi pi-check' : undefined,
command: () => this.switchLanguage(l),
}));
});
}
logout() {
this.authService.logout();
}
@@ -224,7 +255,7 @@ export class AppTopBarComponent implements OnDestroy {
if (user?.permissions?.canAccessLibraryStats || user?.permissions?.admin) {
this.statsMenuItems.push({
label: 'Library Stats',
label: this.translocoService.translate('layout.topbar.libraryStats'),
icon: 'pi pi-chart-line',
command: () => this.navigateToStats()
});
@@ -232,7 +263,7 @@ export class AppTopBarComponent implements OnDestroy {
if (user?.permissions?.canAccessUserStats || user?.permissions?.admin) {
this.statsMenuItems.push({
label: 'Reading Stats',
label: this.translocoService.translate('layout.topbar.readingStats'),
icon: 'pi pi-users',
command: () => this.navigateToUserStats()
});
@@ -249,12 +280,12 @@ export class AppTopBarComponent implements OnDestroy {
get statsTooltip(): string {
if (this.statsMenuItems.length === 0) {
return 'Stats';
return this.translocoService.translate('layout.topbar.stats');
}
if (this.statsMenuItems.length === 1) {
return this.statsMenuItems[0].label || 'Stats';
return this.statsMenuItems[0].label || this.translocoService.translate('layout.topbar.stats');
}
return 'Stats';
return this.translocoService.translate('layout.topbar.stats');
}
get iconClass(): string {
@@ -1,7 +1,8 @@
<ng-container *transloco="let t; prefix: 'layout.theme'">
<div class="config-panel-content">
<div class="config-panel-colors">
<span class="config-panel-label">Primary</span>
<span class="config-panel-label">{{ t('primary') }}</span>
<div>
@for (primaryColor of primaryColors(); track primaryColor.name) {
<button
@@ -16,7 +17,7 @@
</div>
<div class="config-panel-colors">
<span class="config-panel-label">Surface</span>
<span class="config-panel-label">{{ t('surface') }}</span>
<div>
@for (surface of surfaces; track surface.name) {
<button
@@ -31,3 +32,4 @@
</div>
</div>
</ng-container>
@@ -8,6 +8,7 @@ import {ToggleSwitchModule} from 'primeng/toggleswitch';
import Aura from '../theme-palette-extend';
import {AppConfigService} from '../../../service/app-config.service';
import {TranslocoDirective} from '@jsverse/transloco';
import {FaviconService} from './favicon-service';
type ColorPalette = Record<string, string>;
@@ -29,7 +30,8 @@ interface Palette {
FormsModule,
ButtonModule,
RadioButtonModule,
ToggleSwitchModule
ToggleSwitchModule,
TranslocoDirective
]
})
export class ThemeConfiguratorComponent {
@@ -1,9 +1,10 @@
<ng-container *transloco="let t; prefix: 'layout.uploadDialog'">
<div class="upload-dialog-content">
<div class="upload-section">
<div class="file-selector">
<label class="file-label">Choose File:</label>
<label class="file-label">{{ t('chooseFile') }}</label>
<p-button
label="Select Image"
[label]="t('selectImage')"
icon="pi pi-upload"
(click)="fileInput.click()"
outlined
@@ -16,26 +17,26 @@
accept=".jpg,.jpeg,.png,image/jpeg,image/png"
(change)="onFileSelected($event)"
style="display: none;">
<small class="file-note">Supported formats: JPEG, PNG • Maximum file size: 5 MB</small>
<small class="file-note">{{ t('fileNote') }}</small>
@if (uploadFile) {
<small class="selected-file">{{ uploadFile.name }}</small>
}
</div>
<p-divider align="center" type="solid">
<span class="or-text">OR</span>
<span class="or-text">{{ t('or') }}</span>
</p-divider>
<div class="url-section">
<label for="urlInput" class="url-label">Image URL:</label>
<label for="urlInput" class="url-label">{{ t('imageUrl') }}</label>
<input
id="urlInput"
type="text"
[(ngModel)]="uploadImageUrl"
placeholder="Paste image URL here"
[placeholder]="t('urlPlaceholder')"
class="url-input"
pInputText>
<small class="url-note">Supported formats: JPEG, PNG • Maximum file size: 5 MB</small>
<small class="url-note">{{ t('urlNote') }}</small>
</div>
@if (uploadError) {
@@ -44,16 +45,17 @@
<div class="dialog-footer">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
(click)="cancel()"
severity="secondary"
outlined>
</p-button>
<p-button
label="Submit"
[label]="'common.submit' | transloco"
icon="pi pi-check"
(click)="submit()">
</p-button>
</div>
</div>
</ng-container>
@@ -8,6 +8,7 @@ import {DividerModule} from 'primeng/divider';
import {MessageModule} from 'primeng/message';
import {BackgroundUploadService} from '../background-upload.service';
import {take} from 'rxjs';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-upload-dialog',
@@ -20,12 +21,15 @@ import {take} from 'rxjs';
ButtonModule,
InputTextModule,
DividerModule,
MessageModule
MessageModule,
TranslocoDirective,
TranslocoPipe
]
})
export class UploadDialogComponent {
private readonly dialogRef = inject(DynamicDialogRef);
private readonly backgroundUploadService = inject(BackgroundUploadService);
private readonly t = inject(TranslocoService);
uploadImageUrl = '';
uploadFile: File | null = null;
@@ -47,7 +51,7 @@ export class UploadDialogComponent {
} else if (this.uploadImageUrl.trim()) {
upload$ = this.backgroundUploadService.uploadUrl(this.uploadImageUrl.trim());
} else {
this.uploadError = 'Please select a file or paste a URL.';
this.uploadError = this.t.translate('layout.uploadDialog.errorNoInput');
return;
}