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);
|
||||
}
|
||||
|
||||
@@ -186,11 +186,11 @@
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="actionName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Action' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let auditTrail">{{ auditTrail.actionName }}</td>
|
||||
<td mat-cell *matCellDef="let auditTrail">{{ auditTrail.actionName | translateKey: 'auditTrail.actions' }}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="entityName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Entity' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let auditTrail">{{ auditTrail.entityName }}</td>
|
||||
<td mat-cell *matCellDef="let auditTrail">{{ auditTrail.entityName | translateKey: 'auditTrail.entities' }}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="officeName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'labels.inputs.Office' | translate }}</th>
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
MatRow
|
||||
} from '@angular/material/table';
|
||||
import { DatetimeFormatPipe } from '../../pipes/datetime-format.pipe';
|
||||
import { TranslatePipe } from '../../pipes/translate.pipe';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
{{ auditTrailData.actionName }}
|
||||
{{ auditTrailData.actionName | translateKey: 'auditTrail.actions' }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong">
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex-50">
|
||||
{{ auditTrailData.entityName }}
|
||||
{{ auditTrailData.entityName | translateKey: 'auditTrail.entities' }}
|
||||
</div>
|
||||
|
||||
<div class="flex-50 mat-body-strong">
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
MatRow
|
||||
} from '@angular/material/table';
|
||||
import { DatetimeFormatPipe } from '../../../pipes/datetime-format.pipe';
|
||||
import { TranslatePipe } from '../../../pipes/translate.pipe';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,8 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
MatHeaderRow,
|
||||
MatRowDef,
|
||||
MatRow,
|
||||
DatetimeFormatPipe
|
||||
DatetimeFormatPipe,
|
||||
TranslatePipe
|
||||
]
|
||||
})
|
||||
export class ViewAuditComponent implements OnInit {
|
||||
|
||||
Reference in New Issue
Block a user