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,111 +1,113 @@
<div>
<div class="settings-content" style="position: relative;">
<div class="float-top-right">
<p-button
icon="pi pi-upload"
rounded
size="large"
(click)="openUploadDialog()"
[disabled]="customFonts.length >= maxFonts"
></p-button>
</div>
@if (customFonts.length === 0 && !isLoading) {
<div class="preferences-section">
<div class="empty-state">
<div class="empty-icon-wrapper">
<i class="pi pi-palette empty-icon"></i>
</div>
<h3 class="empty-title">No Custom Fonts Yet</h3>
<p class="empty-description">
Upload your favorite fonts to personalize your reading experience.<br>
Click the "Add New Font" button above to get started.
</p>
<p class="empty-hint">
<i class="pi pi-info-circle"></i>
Supported formats: <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong>
</p>
</div>
<ng-container *transloco="let t; prefix: 'settingsReader.fonts'">
<div>
<div class="settings-content" style="position: relative;">
<div class="float-top-right">
<p-button
icon="pi pi-upload"
rounded
size="large"
(click)="openUploadDialog()"
[disabled]="customFonts.length >= maxFonts"
></p-button>
</div>
} @else {
<div class="preferences-section">
<div class="section-header">
<div>
<h3 class="section-title">
Your Font Library
<span class="font-count">({{ customFonts.length }})</span>
</h3>
</div>
</div>
<div class="fonts-grid">
@for (font of customFonts; track font.id) {
<div class="settings-card font-card">
<div class="font-card-header">
<div class="font-title-group">
<h4 class="font-name">{{ font.fontName }}</h4>
<span class="format-tag">{{ font.format }}</span>
</div>
<p-button
icon="pi pi-trash"
severity="danger"
[text]="true"
[rounded]="true"
size="small"
(click)="deleteFont(font)"
pTooltip="Delete font"
tooltipPosition="left"
></p-button>
</div>
<div class="font-preview-area">
<label class="preview-label">
<i class="pi pi-eye"></i>
Preview
</label>
@if (!fontsLoadedInBrowser) {
<div class="font-preview-skeleton">
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="60%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="95%" height="0.875rem"></p-skeleton>
</div>
} @else {
<div class="font-preview" [style.font-family]="font.fontName">
<p class="preview-paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<p class="preview-paragraph-small">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<div class="preview-characters">
<span>ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789</span>
</div>
</div>
}
</div>
<div class="font-metadata">
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-file"></i>File</span>
<span class="meta-value">{{ font.originalFileName }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-database"></i>Size</span>
<span class="meta-value">{{ formatFileSize(font.fileSize) }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-calendar"></i>Uploaded</span>
<span class="meta-value">{{ font.uploadedAt | date: 'mediumDate' }}</span>
</div>
</div>
@if (customFonts.length === 0 && !isLoading) {
<div class="preferences-section">
<div class="empty-state">
<div class="empty-icon-wrapper">
<i class="pi pi-palette empty-icon"></i>
</div>
}
<h3 class="empty-title">{{ t('emptyTitle') }}</h3>
<p class="empty-description">
{{ t('emptyDesc') }}<br>
{{ t('emptyHint') }}
</p>
<p class="empty-hint">
<i class="pi pi-info-circle"></i>
{{ t('supportedFormats') }} <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong>
</p>
</div>
</div>
</div>
}
</div>
</div>
} @else {
<div class="preferences-section">
<div class="section-header">
<div>
<h3 class="section-title">
{{ t('yourLibrary') }}
<span class="font-count">({{ customFonts.length }})</span>
</h3>
</div>
</div>
<p-confirmDialog></p-confirmDialog>
<div class="fonts-grid">
@for (font of customFonts; track font.id) {
<div class="settings-card font-card">
<div class="font-card-header">
<div class="font-title-group">
<h4 class="font-name">{{ font.fontName }}</h4>
<span class="format-tag">{{ font.format }}</span>
</div>
<p-button
icon="pi pi-trash"
severity="danger"
[text]="true"
[rounded]="true"
size="small"
(click)="deleteFont(font)"
[pTooltip]="t('deleteFont')"
tooltipPosition="left"
></p-button>
</div>
<div class="font-preview-area">
<label class="preview-label">
<i class="pi pi-eye"></i>
{{ t('preview') }}
</label>
@if (!fontsLoadedInBrowser) {
<div class="font-preview-skeleton">
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="100%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="60%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="85%" height="1rem" class="mb-3"></p-skeleton>
<p-skeleton width="95%" height="0.875rem"></p-skeleton>
</div>
} @else {
<div class="font-preview" [style.font-family]="font.fontName">
<p class="preview-paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<p class="preview-paragraph-small">
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<div class="preview-characters">
<span>ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789</span>
</div>
</div>
}
</div>
<div class="font-metadata">
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-file"></i>{{ t('file') }}</span>
<span class="meta-value">{{ font.originalFileName }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-database"></i>{{ t('size') }}</span>
<span class="meta-value">{{ formatFileSize(font.fileSize) }}</span>
</div>
<div class="metadata-row">
<span class="meta-label"><i class="pi pi-calendar"></i>{{ t('uploaded') }}</span>
<span class="meta-value">{{ font.uploadedAt | date: 'mediumDate' }}</span>
</div>
</div>
</div>
}
</div>
</div>
}
</div>
</div>
<p-confirmDialog></p-confirmDialog>
</ng-container>
@@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core';
import {Component, inject, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
@@ -11,11 +11,12 @@ import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
import {FontUploadDialogComponent} from './font-upload-dialog/font-upload-dialog.component';
import {Skeleton} from 'primeng/skeleton';
import {DialogSize, DialogStyle} from '../../../shared/services/dialog-launcher.service';
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-custom-fonts',
standalone: true,
imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton],
imports: [CommonModule, Button, ConfirmDialog, Tooltip, Skeleton, TranslocoDirective],
templateUrl: './custom-fonts.component.html',
styleUrls: ['./custom-fonts.component.scss'],
providers: [ConfirmationService, DialogService]
@@ -28,6 +29,8 @@ export class CustomFontsComponent implements OnInit {
readonly maxFonts = 10;
private t = inject(TranslocoService);
constructor(
private customFontService: CustomFontService,
private messageService: MessageService,
@@ -60,8 +63,8 @@ export class CustomFontsComponent implements OnInit {
console.error('Failed to load fonts:', error);
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Failed to load custom fonts'
summary: this.t.translate('common.error'),
detail: this.t.translate('settingsReader.fonts.loadError')
});
this.isLoading = false;
this.fontsLoadedInBrowser = true;
@@ -72,8 +75,8 @@ export class CustomFontsComponent implements OnInit {
if (this.customFonts.length >= this.maxFonts) {
this.messageService.add({
severity: 'error',
summary: 'Quota Exceeded',
detail: `Maximum ${this.maxFonts} fonts allowed per user`
summary: this.t.translate('settingsReader.fonts.quotaExceeded'),
detail: this.t.translate('settingsReader.fonts.quotaExceededDetail', {max: this.maxFonts})
});
return;
}
@@ -98,8 +101,8 @@ export class CustomFontsComponent implements OnInit {
deleteFont(font: CustomFont): void {
this.confirmationService.confirm({
message: `Are you sure you want to delete the font "${font.fontName}"?`,
header: 'Delete Font',
message: this.t.translate('settingsReader.fonts.deleteFontConfirm', {name: font.fontName}),
header: this.t.translate('settingsReader.fonts.deleteFontHeader'),
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.customFontService.deleteFont(font.id).subscribe({
@@ -108,15 +111,15 @@ export class CustomFontsComponent implements OnInit {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Font "${font.fontName}" deleted successfully`
detail: this.t.translate('settingsReader.fonts.deleteSuccess', {name: font.fontName})
});
},
error: (error) => {
console.error('Failed to delete font:', error);
this.messageService.add({
severity: 'error',
summary: 'Delete Failed',
detail: 'Failed to delete font'
summary: this.t.translate('settingsReader.fonts.deleteFailed'),
detail: this.t.translate('settingsReader.fonts.deleteError')
});
}
});
@@ -1,12 +1,13 @@
<ng-container *transloco="let t; prefix: 'settingsReader.fonts.upload'">
<div class="font-upload-dialog">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-upload header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Add New Font</h2>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">
Upload a custom font for your EPUB reader
{{ t('description') }}
</p>
</div>
<p-button
@@ -24,7 +25,7 @@
<div class="section-header">
<span class="section-title">
<i class="pi pi-file"></i>
Select Font File
{{ t('selectFile') }}
</span>
</div>
@@ -47,12 +48,9 @@
<div class="empty-icon-wrapper">
<i class="pi pi-cloud-upload empty-icon"></i>
</div>
<h3 class="empty-title">Drag and Drop Font File</h3>
<p class="empty-description">
Supported formats: <strong>TTF</strong>, <strong>OTF</strong>, <strong>WOFF</strong>, <strong>WOFF2</strong>
<br/>
Maximum file size: 5 MB
</p>
<h3 class="empty-title">{{ t('dragDrop') }}</h3>
<p class="empty-description" [innerHTML]="t('supportedFormats')"></p>
<p class="empty-description">{{ t('maxSize') }}</p>
</div>
</div>
} @else {
@@ -69,7 +67,7 @@
<div class="preview-section">
<label class="preview-label">
<i class="pi pi-eye"></i>
Font Preview
{{ t('fontPreview') }}
</label>
<div class="font-preview" [style.font-family]="previewFontFamily">
<p class="preview-paragraph">
@@ -91,9 +89,9 @@
<div class="setting-item">
<div class="setting-info">
<label for="fontName" class="setting-label">Font Display Name</label>
<label for="fontName" class="setting-label">{{ t('displayName') }}</label>
<p class="setting-description">
This name will appear in the font selector when reading EPUB books.
{{ t('displayNameDesc') }}
</p>
</div>
<div class="setting-control">
@@ -101,7 +99,7 @@
pInputText
id="fontName"
[(ngModel)]="uploadedFontName"
placeholder="e.g., Bookerly, Open Sans, Merriweather"
[placeholder]="t('displayNamePlaceholder')"
[disabled]="isUploading"
class="font-name-input"
/>
@@ -110,10 +108,11 @@
</div>
}
</div>
</div>
<div class="dialog-footer">
<p-button
label="Cancel"
[label]="'common.cancel' | transloco"
icon="pi pi-times"
severity="secondary"
[outlined]="true"
@@ -121,7 +120,7 @@
[disabled]="isUploading"
></p-button>
<p-button
label="Upload Font"
[label]="t('uploadBtn')"
icon="pi pi-upload"
(click)="uploadFont()"
[disabled]="isUploading || !selectedFile || !uploadedFontName.trim()"
@@ -129,3 +128,4 @@
></p-button>
</div>
</div>
</ng-container>
@@ -1,4 +1,4 @@
import {Component, ViewChild, ElementRef, OnDestroy} from '@angular/core';
import {Component, ViewChild, ElementRef, OnDestroy, inject} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Button} from 'primeng/button';
import {MessageService} from 'primeng/api';
@@ -7,16 +7,18 @@ import {formatFileSize} from '../../../../shared/model/custom-font.model';
import {InputText} from 'primeng/inputtext';
import {FormsModule} from '@angular/forms';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
@Component({
selector: 'app-font-upload-dialog',
standalone: true,
imports: [CommonModule, Button, InputText, FormsModule],
imports: [CommonModule, Button, InputText, FormsModule, TranslocoDirective, TranslocoPipe],
templateUrl: './font-upload-dialog.component.html',
styleUrls: ['./font-upload-dialog.component.scss']
})
export class FontUploadDialogComponent implements OnDestroy {
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
private readonly t = inject(TranslocoService);
isUploading = false;
uploadedFontName = '';
@@ -96,8 +98,8 @@ export class FontUploadDialogComponent implements OnDestroy {
this.previewFontFamily = null;
this.messageService.add({
severity: 'warn',
summary: 'Preview Failed',
detail: 'Unable to preview font, but you can still upload it'
summary: this.t.translate('settingsReader.fonts.upload.previewFailed'),
detail: this.t.translate('settingsReader.fonts.upload.previewFailedDetail')
});
}
} finally {
@@ -111,8 +113,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (!this.selectedFile) {
this.messageService.add({
severity: 'warn',
summary: 'No File Selected',
detail: 'Please select a font file to upload'
summary: this.t.translate('settingsReader.fonts.upload.noFileSelected'),
detail: this.t.translate('settingsReader.fonts.upload.noFileSelectedDetail')
});
return;
}
@@ -122,21 +124,20 @@ export class FontUploadDialogComponent implements OnDestroy {
next: (font) => {
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: `Font "${font.fontName}" uploaded successfully`
summary: this.t.translate('settingsReader.fonts.upload.success'),
detail: this.t.translate('settingsReader.fonts.upload.successDetail', {name: font.fontName})
});
this.isUploading = false;
this.dialogRef.close(font); // Return the uploaded font
},
error: (error) => {
console.error('Failed to upload font:', error);
let errorMessage = 'Failed to upload font';
if (error.status === 400) {
errorMessage = 'Invalid file format or quota exceeded';
}
const errorMessage = error.status === 400
? this.t.translate('settingsReader.fonts.upload.uploadFailedInvalid')
: this.t.translate('settingsReader.fonts.upload.uploadFailedDefault');
this.messageService.add({
severity: 'error',
summary: 'Upload Failed',
summary: this.t.translate('settingsReader.fonts.upload.uploadFailed'),
detail: errorMessage
});
@@ -193,8 +194,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (!isValidFormat) {
this.messageService.add({
severity: 'error',
summary: 'Invalid File Type',
detail: 'Please upload a TTF, OTF, WOFF, or WOFF2 font file'
summary: this.t.translate('settingsReader.fonts.upload.invalidFileType'),
detail: this.t.translate('settingsReader.fonts.upload.invalidFileTypeDetail')
});
return false;
}
@@ -202,8 +203,8 @@ export class FontUploadDialogComponent implements OnDestroy {
if (file.size > this.maxFileSize) {
this.messageService.add({
severity: 'error',
summary: 'File Too Large',
detail: `File size must not exceed ${this.formatFileSize(this.maxFileSize)}`
summary: this.t.translate('settingsReader.fonts.upload.fileTooLarge'),
detail: this.t.translate('settingsReader.fonts.upload.fileTooLargeDetail', {size: this.formatFileSize(this.maxFileSize)})
});
return false;
}