Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/cli/src/utils/i18n-coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ function walkMetadataFormField(field: any, type: string, parentPath: string, out
const name = typeof field.field === 'string' ? field.field : undefined;
const path = name ? (parentPath ? `${parentPath}.${name}` : name) : parentPath;
if (path) {
if (typeof field.label === 'string' && field.label.length > 0) {
pushKey(out, ['metadataForms', type, 'fields', path, 'label'], 'metadataForm', `Metadata form ${type}.fields.${path} label`);
}
pushKey(out, ['metadataForms', type, 'fields', path, 'label'], 'metadataForm', `Metadata form ${type}.fields.${path} label`);
if (typeof field.helpText === 'string' && field.helpText.length > 0) {
pushKey(out, ['metadataForms', type, 'fields', path, 'helpText'], 'metadataForm', `Metadata form ${type}.fields.${path} helpText`);
}
Expand Down
16 changes: 13 additions & 3 deletions packages/cli/src/utils/i18n-extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,10 @@ function walkFormField(field: any, type: string, parentPath: string, out: Expect
const name = typeof field.field === 'string' ? field.field : undefined;
const path = name ? (parentPath ? `${parentPath}.${name}` : name) : parentPath;
if (path) {
if (typeof field.label === 'string' && field.label.length > 0) {
pushEntry(out, ['metadataForms', type, 'fields', path, 'label'], field.label, 'metadataFormField', { metadataType: type });
}
const label = typeof field.label === 'string' && field.label.length > 0
? field.label
: humanizeFieldPath(path);
pushEntry(out, ['metadataForms', type, 'fields', path, 'label'], label, 'metadataFormField', { metadataType: type });
if (typeof field.helpText === 'string' && field.helpText.length > 0) {
pushEntry(out, ['metadataForms', type, 'fields', path, 'helpText'], field.helpText, 'metadataFormField', { metadataType: type });
}
Expand All @@ -371,6 +372,15 @@ function walkFormField(field: any, type: string, parentPath: string, out: Expect
}
}

/** Match the metadata form renderer's fallback label for fields without an explicit label. */
function humanizeFieldPath(path: string): string {
const leaf = path.split('.').pop() ?? path;
return leaf
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
.replace(/[_-]+/g, ' ')
.replace(/\b\w/g, (c) => c.toUpperCase());
}

/**
* Section-name derivation mirroring `resolveMetadataFormLabels` so the
* extractor emits keys at the exact same paths the resolver looks them up.
Expand Down
1 change: 1 addition & 0 deletions packages/cli/test/i18n-coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ describe('computeI18nCoverage', () => {
const objectSources = new Set(['object', 'field', 'option', 'view', 'action', 'globalAction']);
expect(report.issues.filter((i) => objectSources.has(i.source))).toEqual([]);
expect(report.totals.expectedKeys).toBeGreaterThan(0); // metadataForms baseline
expect(report.issues.some((i) => i.key === 'metadataForms.flow.fields.name.label')).toBe(true);
});

it('treats data.object as fallback for view objectName', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/test/i18n-extract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('collectExpectedEntries', () => {
expect(paths).toContain('objects.sys_role._actions.merge.successMessage');
expect(paths).toContain('globalActions.export_csv.label');
expect(paths).toContain('globalActions.export_csv.successMessage');
expect(paths).toContain('metadataForms.flow.fields.name.label');
});

it('carries source values from the schema', () => {
Expand All @@ -89,6 +90,7 @@ describe('collectExpectedEntries', () => {
expect(byPath['objects.sys_role.fields.status.options.on']).toBe('On');
expect(byPath['objects.sys_role.fields.kind.options.internal']).toBe('Internal');
expect(byPath['objects.sys_role._actions.merge.label']).toBe('Merge');
expect(byPath['metadataForms.flow.fields.name.label']).toBe('Name');
});
});

Expand Down
Loading
Loading