Skip to content

Commit

Permalink
fix(aggregation): add translate for claims count
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Feb 21, 2024
1 parent 20bb625 commit c872dc6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions projects/admin/src/app/service/bucket-name.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2021-2023 RERO
* Copyright (C) 2021-2024 RERO
* Copyright (C) 2021-2023 UCLouvain
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Injectable } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { TranslateService } from '@ngx-translate/core';
import { IBucketNameService } from '@rero/ng-core';
import { Observable, of } from 'rxjs';
Expand Down Expand Up @@ -47,10 +48,13 @@ export class BucketNameService implements IBucketNameService {
*/
transform(aggregationKey: string, value: string): Observable<string> {
switch (aggregationKey) {
case 'claims_count':
const label = Number(value) < 2 ? _('{{count}} claim') : _('{{count}} claims');
return of(this.translateService.instant(label, { count: value }));
case 'language': return of(this.translateService.instant(`lang_${value}`));
case 'library': return this.libraryApiService.getByPid(value).pipe(map(record => record.name));
case 'organisation': return this.organisationApiService.getByPid(value).pipe(map(record => record.name));
default: return of(value);
default: return of(this.translateService.instant(value));
}
}
}

0 comments on commit c872dc6

Please sign in to comment.