Fix untranslatable UI strings, broken pluralization, and translation reactivity (#3108) (#3233)

This commit is contained in:
ACX
2026-03-07 16:50:12 -07:00
committed by GitHub
parent a03297bb46
commit 1b3e3da699
18 changed files with 350 additions and 177 deletions
@@ -1,11 +1,12 @@
<ng-container *transloco="let t; prefix: 'shared.supportDialog'">
<div class="support-dialog-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-heart header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Support BookLore</h2>
<p class="panel-description">From a solo dev who loves books</p>
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">{{ t('subtitle') }}</p>
</div>
<p-button
icon="pi pi-times"
@@ -19,15 +20,15 @@
<div class="dialog-content">
<p class="intro">
BookLore is built and maintained by a single developer who genuinely loves books. If it's made organizing your library a little more enjoyable, here are a few ways to support the project and keep it going.
{{ t('intro') }}
</p>
<div class="support-cards">
<a class="support-card star-card" href="https://github.com/booklore-app/booklore" target="_blank" rel="noopener noreferrer">
<i class="pi pi-github card-icon"></i>
<div class="card-text">
<span class="card-title">Star on GitHub</span>
<span class="card-desc">A star goes a long way. It helps new people find BookLore and keeps me motivated.</span>
<span class="card-title">{{ t('starTitle') }}</span>
<span class="card-desc">{{ t('starDesc') }}</span>
</div>
<i class="pi pi-arrow-up-right card-arrow"></i>
</a>
@@ -35,8 +36,8 @@
<a class="support-card collective-card" href="https://opencollective.com/booklore" target="_blank" rel="noopener noreferrer">
<i class="pi pi-heart card-icon"></i>
<div class="card-text">
<span class="card-title">Open Collective</span>
<span class="card-desc">Recurring support that helps cover hosting and keeps development sustainable.</span>
<span class="card-title">{{ t('collectiveTitle') }}</span>
<span class="card-desc">{{ t('collectiveDesc') }}</span>
</div>
<i class="pi pi-arrow-up-right card-arrow"></i>
</a>
@@ -44,13 +45,14 @@
<a class="support-card kofi-card" href="https://ko-fi.com/bookloredev" target="_blank" rel="noopener noreferrer">
<i class="pi pi-gift card-icon"></i>
<div class="card-text">
<span class="card-title">Buy me a coffee</span>
<span class="card-desc">A one-time tip to fuel late-night coding sessions. Every bit is appreciated!</span>
<span class="card-title">{{ t('kofiTitle') }}</span>
<span class="card-desc">{{ t('kofiDesc') }}</span>
</div>
<i class="pi pi-arrow-up-right card-arrow"></i>
</a>
</div>
<p class="closing">Thank you for being part of the BookLore community.</p>
<p class="closing">{{ t('closing') }}</p>
</div>
</div>
</ng-container>
@@ -1,11 +1,13 @@
import {Component, inject} from '@angular/core';
import {Button} from 'primeng/button';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {TranslocoDirective} from '@jsverse/transloco';
@Component({
selector: 'app-github-support-dialog',
imports: [
Button
Button,
TranslocoDirective
],
templateUrl: './github-support-dialog.html',
styleUrls: ['./github-support-dialog.scss']
@@ -1,8 +1,10 @@
import {Component, inject} from '@angular/core';
import {Component, inject, OnDestroy} from '@angular/core';
import {NotificationEventService} from '../../websocket/notification-event.service';
import {LogNotification} from '../../websocket/model/log-notification.model';
import {Tag} from 'primeng/tag';
import {TranslocoService} from '@jsverse/transloco';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {TagComponent} from '../tag/tag.component';
@@ -18,16 +20,29 @@ import {TagComponent} from '../tag/tag.component';
TagComponent
]
})
export class LiveNotificationBoxComponent {
export class LiveNotificationBoxComponent implements OnDestroy {
private readonly t = inject(TranslocoService);
private readonly destroy$ = new Subject<void>();
latestNotification: LogNotification = {message: this.t.translate('shared.liveNotification.defaultMessage')};
private hasReceivedNotification = false;
private notificationService = inject(NotificationEventService);
constructor() {
this.notificationService.latestNotification$.subscribe(notification => {
this.notificationService.latestNotification$.pipe(takeUntil(this.destroy$)).subscribe(notification => {
this.hasReceivedNotification = true;
this.latestNotification = notification;
});
this.t.langChanges$.pipe(takeUntil(this.destroy$)).subscribe(() => {
if (!this.hasReceivedNotification) {
this.latestNotification = {message: this.t.translate('shared.liveNotification.defaultMessage')};
}
});
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
getSeverityColor(severity?: string): 'red' | 'amber' | 'green' | 'gray' {
@@ -132,6 +132,12 @@ export class AppTopBarComponent implements OnDestroy {
.subscribe(() => {
this.initializeStatsMenu();
});
this.translocoService.langChanges$
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.initializeStatsMenu();
});
}
ngOnDestroy(): void {