mirror of
https://github.com/booklore-app/booklore.git
synced 2026-02-18 00:17:53 +01:00
feat(i18n): translate dashboard scroller titles dynamically (EN/ES)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<ng-container *transloco="let t; prefix: 'dashboard.scroller'">
|
||||
<div class="dashboard-scroller-container">
|
||||
<h2 class="dashboard-scroller-title">
|
||||
{{ title }}
|
||||
{{ title | transloco }}
|
||||
@if (isMagicShelf) {
|
||||
<i class="pi pi-sparkles magic-shelf-icon"></i>
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {ScrollerType} from '../../models/dashboard-config.model';
|
||||
import { BookCardOverlayPreferenceService } from '../../../book/components/book-browser/book-card-overlay-preference.service';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard-scroller',
|
||||
@@ -18,7 +18,8 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
BookCardComponent,
|
||||
ProgressSpinnerModule,
|
||||
NgClass,
|
||||
TranslocoDirective
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
|
||||
@@ -114,23 +114,21 @@ export class DashboardSettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
getScrollerTitle(scroller: ScrollerConfig): string {
|
||||
const t = (key: string) => this.translocoService.translate(`dashboard.settings.scrollerTypes.${key}`);
|
||||
|
||||
if (scroller.type === ScrollerType.MAGIC_SHELF && scroller.magicShelfId) {
|
||||
return this.magicShelvesMap.get(scroller.magicShelfId) || t('magicShelf');
|
||||
return this.magicShelvesMap.get(scroller.magicShelfId) || 'dashboard.scroller.magicShelf';
|
||||
}
|
||||
|
||||
switch (scroller.type) {
|
||||
case ScrollerType.LAST_READ:
|
||||
return t('lastRead');
|
||||
return 'dashboard.scroller.continueReading';
|
||||
case ScrollerType.LAST_LISTENED:
|
||||
return t('lastListened');
|
||||
return 'dashboard.scroller.continueListening';
|
||||
case ScrollerType.LATEST_ADDED:
|
||||
return t('latestAdded');
|
||||
return 'dashboard.scroller.recentlyAdded';
|
||||
case ScrollerType.RANDOM:
|
||||
return t('random');
|
||||
return 'dashboard.scroller.discoverNew';
|
||||
default:
|
||||
return t('default');
|
||||
return 'dashboard.scroller.default';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ export interface DashboardConfig {
|
||||
|
||||
export const DEFAULT_DASHBOARD_CONFIG: DashboardConfig = {
|
||||
scrollers: [
|
||||
{id: '1', type: ScrollerType.LAST_LISTENED, title: 'Continue Listening', enabled: true, order: 1, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '2', type: ScrollerType.LAST_READ, title: 'Continue Reading', enabled: true, order: 2, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '3', type: ScrollerType.LATEST_ADDED, title: 'Recently Added', enabled: true, order: 3, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '4', type: ScrollerType.RANDOM, title: 'Discover Something New', enabled: true, order: 4, maxItems: DEFAULT_MAX_ITEMS}
|
||||
{id: '1', type: ScrollerType.LAST_LISTENED, title: 'dashboard.scroller.continueListening', enabled: true, order: 1, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '2', type: ScrollerType.LAST_READ, title: 'dashboard.scroller.continueReading', enabled: true, order: 2, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '3', type: ScrollerType.LATEST_ADDED, title: 'dashboard.scroller.recentlyAdded', enabled: true, order: 3, maxItems: DEFAULT_MAX_ITEMS},
|
||||
{id: '4', type: ScrollerType.RANDOM, title: 'dashboard.scroller.discoverNew', enabled: true, order: 4, maxItems: DEFAULT_MAX_ITEMS}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -9,7 +9,13 @@
|
||||
},
|
||||
"scroller": {
|
||||
"noBooksFound": "No books found for this scroller.",
|
||||
"loadError": "Failed to load books! Please try refreshing the page."
|
||||
"loadError": "Failed to load books! Please try refreshing the page.",
|
||||
"continueListening": "Continue Listening",
|
||||
"continueReading": "Continue Reading",
|
||||
"recentlyAdded": "Recently Added",
|
||||
"discoverNew": "Discover Something New",
|
||||
"magicShelf": "Magic Shelf",
|
||||
"default": "Scroller"
|
||||
},
|
||||
"settings": {
|
||||
"title": "Dashboard Configuration",
|
||||
|
||||
@@ -9,7 +9,13 @@
|
||||
},
|
||||
"scroller": {
|
||||
"noBooksFound": "No se encontraron libros para este carrusel.",
|
||||
"loadError": "Error al cargar los libros. Por favor, intenta actualizar la pagina."
|
||||
"loadError": "Error al cargar los libros. Por favor, intenta actualizar la pagina.",
|
||||
"continueListening": "Seguir escuchando",
|
||||
"continueReading": "Seguir leyendo",
|
||||
"recentlyAdded": "Añadidos recientemente",
|
||||
"discoverNew": "Descubre algo nuevo",
|
||||
"magicShelf": "Estante mágico",
|
||||
"default": "Carrusel"
|
||||
},
|
||||
"settings": {
|
||||
"title": "Configuración del panel",
|
||||
|
||||
Reference in New Issue
Block a user