Files
cbsnexora/src/app/pipes/translate.pipe.ts
T
Ralph HopmanandAdam Saghy cac1d11ad7 build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
2025-01-15 11:59:30 +00:00

15 lines
476 B
TypeScript

import { Pipe, PipeTransform } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
@Pipe({
name: 'translateKey'
})
export class TranslatePipe implements PipeTransform {
constructor(private translateService: TranslateService) {}
transform(attributeValue: any, group: string, prefix: string = 'labels'): string {
const translationKey = `${prefix}.${group}.${attributeValue}`;
return this.translateService.instant(translationKey);
}
}