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:
+57
-58
@@ -1,20 +1,20 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsNaming'">
|
||||
<div class="file-naming-container">
|
||||
<div class="settings-header">
|
||||
<h2 class="settings-title">
|
||||
<i class="pi pi-file"></i>
|
||||
File Naming Patterns
|
||||
{{ t('title') }}
|
||||
<app-external-doc-link docType="fileNamePatterns"></app-external-doc-link>
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure automatic file organization using metadata placeholders. Patterns are applied when uploading, moving files, or after metadata updates.
|
||||
{{ t('description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="warning-notice">
|
||||
<i class="pi pi-exclamation-triangle"></i>
|
||||
<div>
|
||||
<strong>Metadata Quality Notice:</strong> File naming relies entirely on metadata stored in Booklore.
|
||||
This feature is recommended only for high-quality, curated libraries with complete metadata.
|
||||
<strong>{{ t('warning.title') }}</strong> {{ t('warning.text') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-bolt"></i>
|
||||
Default Pattern
|
||||
{{ t('defaultPattern.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">Fallback pattern when no library-specific override is configured.</p>
|
||||
<p class="section-description">{{ t('defaultPattern.sectionDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
@@ -35,11 +35,11 @@
|
||||
pInputText
|
||||
id="defaultPattern"
|
||||
[(ngModel)]="defaultPattern"
|
||||
placeholder="e.g., {title} - {authors}"
|
||||
[placeholder]="t('defaultPattern.placeholder')"
|
||||
(input)="onDefaultPatternChange(defaultPattern)"
|
||||
class="pattern-input"/>
|
||||
<p-button
|
||||
label="Save"
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-save"
|
||||
(onClick)="savePatterns()"
|
||||
severity="success"
|
||||
@@ -53,7 +53,7 @@
|
||||
<div class="preview-row">
|
||||
<span class="preview-label">
|
||||
<i class="pi pi-eye"></i>
|
||||
Preview:
|
||||
{{ t('defaultPattern.preview') }}
|
||||
</span>
|
||||
<code class="preview-value">{{ generateDefaultPreview() }}</code>
|
||||
</div>
|
||||
@@ -66,10 +66,10 @@
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-folder"></i>
|
||||
Library Overrides
|
||||
{{ t('libraryOverrides.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
Define custom patterns for specific libraries. Leave empty to use the default pattern.
|
||||
{{ t('libraryOverrides.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -77,8 +77,8 @@
|
||||
@if (libraries.length === 0) {
|
||||
<div class="empty-state">
|
||||
<i class="pi pi-folder-open"></i>
|
||||
<p class="empty-title">No libraries found</p>
|
||||
<p class="empty-subtitle">Create a library to configure custom naming patterns</p>
|
||||
<p class="empty-title">{{ t('libraryOverrides.emptyTitle') }}</p>
|
||||
<p class="empty-subtitle">{{ t('libraryOverrides.emptySubtitle') }}</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="libraries-list">
|
||||
@@ -91,9 +91,9 @@
|
||||
</div>
|
||||
<span class="library-name">{{ library.name }}</span>
|
||||
@if (library.fileNamingPattern) {
|
||||
<span class="custom-badge">Custom</span>
|
||||
<span class="custom-badge">{{ t('libraryOverrides.custom') }}</span>
|
||||
} @else {
|
||||
<span class="default-badge">Using Default</span>
|
||||
<span class="default-badge">{{ t('libraryOverrides.usingDefault') }}</span>
|
||||
}
|
||||
</div>
|
||||
<p-button
|
||||
@@ -104,7 +104,7 @@
|
||||
[rounded]="true"
|
||||
(onClick)="clearLibraryPattern(library)"
|
||||
[disabled]="!library.fileNamingPattern"
|
||||
pTooltip="Clear pattern">
|
||||
[pTooltip]="t('libraryOverrides.clearPattern')">
|
||||
</p-button>
|
||||
</div>
|
||||
<div class="library-body">
|
||||
@@ -112,13 +112,13 @@
|
||||
<input
|
||||
pInputText
|
||||
[(ngModel)]="library.fileNamingPattern"
|
||||
placeholder="Leave empty to use default pattern"
|
||||
[placeholder]="t('libraryOverrides.placeholder')"
|
||||
(input)="onLibraryPatternChange(library)"
|
||||
class="pattern-input"/>
|
||||
<div class="preview-row">
|
||||
<span class="preview-label">
|
||||
<i class="pi pi-eye"></i>
|
||||
Preview:
|
||||
{{ t('libraryOverrides.preview') }}
|
||||
</span>
|
||||
<code class="preview-value">{{ generateLibraryPreview(library) }}</code>
|
||||
</div>
|
||||
@@ -130,7 +130,7 @@
|
||||
|
||||
<div class="actions-row">
|
||||
<p-button
|
||||
label="Save All"
|
||||
[label]="t('libraryOverrides.saveAll')"
|
||||
(onClick)="saveLibraryPatterns()"
|
||||
severity="success"
|
||||
icon="pi pi-save"
|
||||
@@ -145,10 +145,10 @@
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
Placeholders Reference
|
||||
{{ t('placeholders.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
Use placeholders to dynamically insert metadata into file names and folder paths.
|
||||
{{ t('placeholders.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -157,43 +157,41 @@
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-hashtag"></i>
|
||||
Available Placeholders
|
||||
{{ t('placeholders.available') }}
|
||||
</h4>
|
||||
<div class="placeholder-list">
|
||||
<div class="placeholder-item"><code>{{ '{title}' }}</code><span>Book title</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>Book subtitle</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{authors}' }}</code><span>Author(s)</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{year}' }}</code><span>Publication year</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{series}' }}</code><span>Series name</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>Series index</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{language}' }}</code><span>Language code</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>Publisher</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>ISBN number</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>Original filename</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title}' }}</code><span>{{ t('placeholders.title') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{subtitle}' }}</code><span>{{ t('placeholders.subtitle') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{authors}' }}</code><span>{{ t('placeholders.authors') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{year}' }}</code><span>{{ t('placeholders.year') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{series}' }}</code><span>{{ t('placeholders.series') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{seriesIndex}' }}</code><span>{{ t('placeholders.seriesIndex') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{language}' }}</code><span>{{ t('placeholders.language') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{publisher}' }}</code><span>{{ t('placeholders.publisher') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{isbn}' }}</code><span>{{ t('placeholders.isbn') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{currentFilename}' }}</code><span>{{ t('placeholders.currentFilename') }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-code"></i>
|
||||
Optional Blocks
|
||||
{{ t('placeholders.optionalBlocks') }}
|
||||
</h4>
|
||||
<p class="group-description">
|
||||
Wrap parts in angle brackets <code>{{ '{<...>}' }}</code> to make them conditional.
|
||||
If any placeholder in the block has no value, the entire block is omitted.
|
||||
<p class="group-description" [innerHTML]="t('placeholders.optionalDesc', { syntax: '{<...>}' })">
|
||||
</p>
|
||||
<div class="example-block">
|
||||
<div class="example-pattern">
|
||||
<span class="pattern-prefix">Pattern:</span>
|
||||
<span class="pattern-prefix">{{ t('placeholders.pattern') }}</span>
|
||||
<code>{{ '{<{seriesIndex} - >{title}' }}</code>
|
||||
</div>
|
||||
<div class="example-results">
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">With index:</span>
|
||||
<span class="result-prefix">{{ t('placeholders.withIndex') }}</span>
|
||||
<code>01 - Dune</code>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">Without:</span>
|
||||
<span class="result-prefix">{{ t('placeholders.without') }}</span>
|
||||
<code>Dune</code>
|
||||
</div>
|
||||
</div>
|
||||
@@ -207,10 +205,10 @@
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-eye"></i>
|
||||
Pattern Examples
|
||||
{{ t('examples.sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
Sample patterns with example metadata to help you understand how patterns work.
|
||||
{{ t('examples.sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -220,7 +218,7 @@
|
||||
<div class="category-header">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
With Full Metadata
|
||||
{{ t('examples.withFull') }}
|
||||
</h4>
|
||||
<div class="sample-metadata">
|
||||
<div class="metadata-items">
|
||||
@@ -236,32 +234,32 @@
|
||||
|
||||
<div class="example-grid">
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Basic pattern</span>
|
||||
<span class="pattern-label">{{ t('examples.basicPattern') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors} - {title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss - The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">With punctuation</span>
|
||||
<span class="pattern-label">{{ t('examples.withPunctuation') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}: {series}' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind: The Kingkiller Chronicle.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Series in folder</span>
|
||||
<span class="pattern-label">{{ t('examples.seriesInFolder') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/{series}/{seriesIndex} - {title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss/The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Folder only</span>
|
||||
<span class="pattern-label">{{ t('examples.folderOnly') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}/' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Absolute path</span>
|
||||
<span class="pattern-label">{{ t('examples.absolutePath') }}</span>
|
||||
<span class="pattern-col"><code>{{ '/{authors}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>/Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Title + Subtitle</span>
|
||||
<span class="pattern-label">{{ t('examples.titleSubtitle') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}: {subtitle}' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span>
|
||||
</div>
|
||||
@@ -274,48 +272,48 @@
|
||||
<div class="category-header">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-question-circle"></i>
|
||||
With Missing Optional Fields
|
||||
{{ t('examples.withMissing') }}
|
||||
</h4>
|
||||
<div class="sample-metadata">
|
||||
<div class="metadata-items">
|
||||
<span><strong>title:</strong> <code>Project Hail Mary</code></span>
|
||||
<span><strong>subtitle:</strong> <em class="not-set">not set</em></span>
|
||||
<span><strong>subtitle:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
|
||||
<span><strong>authors:</strong> <code>Andy Weir</code></span>
|
||||
<span><strong>year:</strong> <code>2021</code></span>
|
||||
<span><strong>series:</strong> <em class="not-set">not set</em></span>
|
||||
<span><strong>seriesIndex:</strong> <em class="not-set">not set</em></span>
|
||||
<span><strong>series:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
|
||||
<span><strong>seriesIndex:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="example-grid">
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Optional blocks</span>
|
||||
<span class="pattern-label">{{ t('examples.optionalBlocks') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/<{series}/><{seriesIndex}. >{title}< ({year})>' }}</code></span>
|
||||
<span class="result-col"><code>Andy Weir/Project Hail Mary (2021).epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">SeriesIndex fallback</span>
|
||||
<span class="pattern-label">{{ t('examples.seriesIndexFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{seriesIndex}. >{title}< - {authors}>' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Brackets fallback</span>
|
||||
<span class="pattern-label">{{ t('examples.bracketsFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<[{series}] >{title} - {authors}' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Series punctuation</span>
|
||||
<span class="pattern-label">{{ t('examples.seriesPunctuation') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}: >{title} by {authors}' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary by Andy Weir.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Year prefix</span>
|
||||
<span class="pattern-label">{{ t('examples.yearPrefix') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/{year}__{currentFilename}' }}</code></span>
|
||||
<span class="result-col"><code>Andy Weir/2021__project_hail_mary_final.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">Subtitle fallback</span>
|
||||
<span class="pattern-label">{{ t('examples.subtitleFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}<: {subtitle}>' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
@@ -325,3 +323,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+10
-7
@@ -9,13 +9,15 @@ import {catchError, filter, take} from 'rxjs/operators';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {LibraryService} from '../../book/service/library.service';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-file-naming-pattern',
|
||||
templateUrl: './file-naming-pattern.component.html',
|
||||
standalone: true,
|
||||
imports: [FormsModule, Button, InputText, ExternalDocLinkComponent],
|
||||
imports: [FormsModule, Button, InputText, Tooltip, ExternalDocLinkComponent, TranslocoDirective, TranslocoPipe],
|
||||
styleUrls: ['./file-naming-pattern.component.scss'],
|
||||
})
|
||||
export class FileNamingPatternComponent implements OnInit {
|
||||
@@ -38,6 +40,7 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
|
||||
@@ -100,7 +103,7 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
|
||||
onDefaultPatternChange(pattern: string): void {
|
||||
this.defaultPattern = pattern;
|
||||
this.defaultErrorMessage = this.validatePattern(pattern) ? '' : 'Pattern contains invalid characters.';
|
||||
this.defaultErrorMessage = this.validatePattern(pattern) ? '' : this.t.translate('settingsNaming.defaultPattern.invalidChars');
|
||||
}
|
||||
|
||||
onLibraryPatternChange(library: Library): void {
|
||||
@@ -113,7 +116,7 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
|
||||
savePatterns(): void {
|
||||
if (this.defaultErrorMessage) {
|
||||
this.showMessage('error', 'Invalid Pattern', 'Please fix errors before saving.');
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.invalidError'));
|
||||
return;
|
||||
}
|
||||
this.appSettingsService
|
||||
@@ -121,8 +124,8 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
{key: AppSettingKey.UPLOAD_FILE_PATTERN, newValue: this.defaultPattern},
|
||||
])
|
||||
.subscribe({
|
||||
next: () => this.showMessage('success', 'Settings Saved', 'The default pattern was successfully saved!'),
|
||||
error: () => this.showMessage('error', 'Error', 'There was an error saving the settings.'),
|
||||
next: () => this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.defaultPattern.saveSuccess')),
|
||||
error: () => this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.defaultPattern.saveError')),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -135,9 +138,9 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
forkJoin(patchRequests).subscribe(results => {
|
||||
const failures = results.filter(result => result === null);
|
||||
if (failures.length === 0) {
|
||||
this.showMessage('success', 'Library Patterns Saved', 'Library-specific patterns were successfully saved!');
|
||||
this.showMessage('success', this.t.translate('common.success'), this.t.translate('settingsNaming.libraryOverrides.saveSuccess'));
|
||||
} else {
|
||||
this.showMessage('error', 'Error', `Failed to save ${failures.length} library pattern(s).`);
|
||||
this.showMessage('error', this.t.translate('common.error'), this.t.translate('settingsNaming.libraryOverrides.saveError', {count: failures.length}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user