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:
@@ -12,6 +12,7 @@ import { ServiceError } from '../Items/ServiceError';
|
|||||||
import { ResourceService } from '../Resource/ResourceService';
|
import { ResourceService } from '../Resource/ResourceService';
|
||||||
import { getExportableService } from './decorators/ExportableModel.decorator';
|
import { getExportableService } from './decorators/ExportableModel.decorator';
|
||||||
import { ContextIdFactory, ModuleRef } from '@nestjs/core';
|
import { ContextIdFactory, ModuleRef } from '@nestjs/core';
|
||||||
|
import { I18nService } from 'nestjs-i18n';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ExportResourceService {
|
export class ExportResourceService {
|
||||||
@@ -20,6 +21,7 @@ export class ExportResourceService {
|
|||||||
private readonly exportPdf: ExportPdf,
|
private readonly exportPdf: ExportPdf,
|
||||||
private readonly resourceService: ResourceService,
|
private readonly resourceService: ResourceService,
|
||||||
private readonly moduleRef: ModuleRef,
|
private readonly moduleRef: ModuleRef,
|
||||||
|
private readonly i18nService: I18nService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +149,7 @@ export class ExportResourceService {
|
|||||||
const group = parent;
|
const group = parent;
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: value.name,
|
name: this.i18nService.t(value.name, { defaultValue: value.name }),
|
||||||
type: value.type || 'text',
|
type: value.type || 'text',
|
||||||
accessor: value.accessor || key,
|
accessor: value.accessor || key,
|
||||||
group,
|
group,
|
||||||
@@ -174,7 +176,7 @@ export class ExportResourceService {
|
|||||||
const group = parent;
|
const group = parent;
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: value.name,
|
name: this.i18nService.t(value.name, { defaultValue: value.name }),
|
||||||
type: value.type || 'text',
|
type: value.type || 'text',
|
||||||
accessor: value.accessor || key,
|
accessor: value.accessor || key,
|
||||||
group,
|
group,
|
||||||
|
|||||||
Reference in New Issue
Block a user