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:
+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