1
0

fix(server): localize i18n column headers in export (CSV/XLSX/PDF)

Export column headers displayed raw i18n keys like
`expense.field.payment_account` instead of translated names like
"Payment Account" because ExportResourceService never resolved the
i18n keys before rendering.

Inject I18nService and translate column names in both
getExportableColumns() (CSV/XLSX) and getPrintableColumns() (PDF).

Closes #1073

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ahmed Bouhuolia
2026-04-13 18:32:24 +02:00
parent 5944aa3972
commit 3db9061c60
@@ -12,6 +12,7 @@ import { ServiceError } from '../Items/ServiceError';
import { ResourceService } from '../Resource/ResourceService';
import { getExportableService } from './decorators/ExportableModel.decorator';
import { ContextIdFactory, ModuleRef } from '@nestjs/core';
import { I18nService } from 'nestjs-i18n';
@Injectable()
export class ExportResourceService {
@@ -20,6 +21,7 @@ export class ExportResourceService {
private readonly exportPdf: ExportPdf,
private readonly resourceService: ResourceService,
private readonly moduleRef: ModuleRef,
private readonly i18nService: I18nService,
) {}
/**
@@ -147,7 +149,7 @@ export class ExportResourceService {
const group = parent;
return [
{
name: value.name,
name: this.i18nService.t(value.name, { defaultValue: value.name }),
type: value.type || 'text',
accessor: value.accessor || key,
group,
@@ -174,7 +176,7 @@ export class ExportResourceService {
const group = parent;
return [
{
name: value.name,
name: this.i18nService.t(value.name, { defaultValue: value.name }),
type: value.type || 'text',
accessor: value.accessor || key,
group,