feat: translate audit trail actions and entities across languages (#2903)
save account keys have been cleaned up and replaced by the single, consistent SAVINGSACCOUNT key in every translation file.
This commit is contained in:
@@ -1,11 +1,28 @@
|
||||
import { Pipe, PipeTransform, inject } from '@angular/core';
|
||||
import { Pipe, PipeTransform, inject, OnDestroy } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Pipe({ name: 'translateKey', standalone: true })
|
||||
export class TranslatePipe implements PipeTransform {
|
||||
@Pipe({ name: 'translateKey', standalone: true, pure: false })
|
||||
export class TranslatePipe implements PipeTransform, OnDestroy {
|
||||
private translateService = inject(TranslateService);
|
||||
private onLangChange: Subscription;
|
||||
|
||||
constructor() {
|
||||
this.onLangChange = this.translateService.onLangChange.subscribe(() => {
|
||||
// Trigger change detection when language changes
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.onLangChange) {
|
||||
this.onLangChange.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
transform(attributeValue: any, group: string, prefix: string = 'labels'): string {
|
||||
if (!attributeValue) {
|
||||
return attributeValue;
|
||||
}
|
||||
const translationKey = `${prefix}.${group}.${attributeValue}`;
|
||||
return this.translateService.instant(translationKey);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user