From 8c957fe69406173612602eb39e2a103ea76a3a6b Mon Sep 17 00:00:00 2001 From: Florian THIERRY Date: Sat, 21 Sep 2024 11:12:07 +0200 Subject: [PATCH] i18n for home page. --- .../publication-list.component.html | 4 ++-- .../src/app/pages/home/home.component.html | 11 ++++++++- .../src/app/pages/home/home.component.spec.ts | 23 ------------------- frontend/src/app/pages/home/home.component.ts | 15 +++++++----- frontend/src/app/pages/home/home.service.ts | 5 ++-- frontend/src/locale/messages-fr.json | 7 +++++- frontend/src/locale/messages.json | 7 +++++- 7 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 frontend/src/app/pages/home/home.component.spec.ts diff --git a/frontend/src/app/components/publication-list/publication-list.component.html b/frontend/src/app/components/publication-list/publication-list.component.html index f6a0597..f1d3598 100644 --- a/frontend/src/app/components/publication-list/publication-list.component.html +++ b/frontend/src/app/components/publication-list/publication-list.component.html @@ -7,9 +7,9 @@ diff --git a/frontend/src/app/pages/home/home.component.html b/frontend/src/app/pages/home/home.component.html index ba05ecd..d5922ca 100644 --- a/frontend/src/app/pages/home/home.component.html +++ b/frontend/src/app/pages/home/home.component.html @@ -1,2 +1,11 @@

Last publications

- \ No newline at end of file +@if ((isLoading$ | async) === true) { +

Publications loading...

+ +} @else { + @if ((publications$ | async) != []) { + + } @else { +

No any publication.

+ } +} diff --git a/frontend/src/app/pages/home/home.component.spec.ts b/frontend/src/app/pages/home/home.component.spec.ts deleted file mode 100644 index 60c47c4..0000000 --- a/frontend/src/app/pages/home/home.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HomeComponent } from './home.component'; - -describe('HomeComponent', () => { - let component: HomeComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [HomeComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(HomeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/pages/home/home.component.ts b/frontend/src/app/pages/home/home.component.ts index 799b659..0f8710d 100644 --- a/frontend/src/app/pages/home/home.component.ts +++ b/frontend/src/app/pages/home/home.component.ts @@ -1,16 +1,19 @@ import { Component, OnInit, inject } from '@angular/core'; -import { HomeService } from './home.service'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { Observable } from 'rxjs'; -import { Publication } from '../../core/rest-services/publications/model/publication'; -import { RouterModule } from '@angular/router'; -import { MatTooltipModule } from '@angular/material/tooltip'; -import { CommonModule } from '@angular/common'; import { PublicationListComponent } from '../../components/publication-list/publication-list.component'; +import { Publication } from '../../core/rest-services/publications/model/publication'; +import { HomeService } from './home.service'; +import { CommonModule } from '@angular/common'; @Component({ selector: 'app-home', standalone: true, - imports: [PublicationListComponent], + imports: [ + CommonModule, + MatProgressSpinnerModule, + PublicationListComponent + ], templateUrl: './home.component.html', styleUrl: './home.component.scss', providers: [HomeService] diff --git a/frontend/src/app/pages/home/home.service.ts b/frontend/src/app/pages/home/home.service.ts index 84d0ea5..b3cd9bb 100644 --- a/frontend/src/app/pages/home/home.service.ts +++ b/frontend/src/app/pages/home/home.service.ts @@ -26,8 +26,9 @@ export class HomeService { this.publicationRestService.getLatest() .then(publications => this.publicationsSubject.next(publications)) .catch(error => { - this.snackBar.open('An error occurred while retrieving latest publications...'); - console.error('An error occurred while retrieving latest publications...', error); + const errorMessage = $localize`An error occurred while retrieving latest publications...`; + this.snackBar.open(errorMessage, $localize`Close`, { duration: 5000 }); + console.error(errorMessage, error); }) .finally(() => this.isLoadingSubject.next(false)); } diff --git a/frontend/src/locale/messages-fr.json b/frontend/src/locale/messages-fr.json index afc5170..311ca06 100644 --- a/frontend/src/locale/messages-fr.json +++ b/frontend/src/locale/messages-fr.json @@ -1,6 +1,11 @@ { "locale": "fr-FR", "translations": { - "4869473828758837325": "Dernières publications" + "2578598149846191609": "Publication postée par {$INTERPOLATION}", + "4869473828758837325": "Dernières publications", + "5148998676057880041": "Chargement des publications...", + "3688381096110057852": "Il n'y a aucune publication.", + "8393632007890629197": "Une erreur est survenue lors du chargement des dernières publications...", + "7819314041543176992": "Fermer" } } \ No newline at end of file diff --git a/frontend/src/locale/messages.json b/frontend/src/locale/messages.json index a5dcd47..dd25376 100644 --- a/frontend/src/locale/messages.json +++ b/frontend/src/locale/messages.json @@ -1,6 +1,11 @@ { "locale": "en-UK", "translations": { - "4869473828758837325": "Last publications" + "2578598149846191609": "Publication posted by {$INTERPOLATION}", + "4869473828758837325": "Last publications", + "5148998676057880041": "Publications loading...", + "3688381096110057852": "No any publication.", + "8393632007890629197": "An error occurred while retrieving latest publications...", + "7819314041543176992": "Close" } } \ No newline at end of file