Skip to content

Commit 2b7c86f

Browse files
committed
fix: add translation support for field group names
1 parent 4904c01 commit 2b7c86f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

adminforth/modules/restApi.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
458458
}
459459
});
460460

461+
if (resource.options.fieldGroups) {
462+
resource.options.fieldGroups.forEach((group, i) => {
463+
if (group.groupName) {
464+
translateRoutines[`fieldGroup${i}`] = tr(group.groupName, `resource.${resource.resourceId}.fieldGroup`);
465+
}
466+
});
467+
}
468+
461469
const translated: Record<string, string> = {};
462470
await Promise.all(
463471
Object.entries(translateRoutines).map(async ([key, value]) => {
@@ -531,6 +539,10 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
531539
),
532540
options: {
533541
...resource.options,
542+
fieldGroups: resource.options.fieldGroups?.map((group, i) => ({
543+
...group,
544+
groupName: translated[`fieldGroup${i}`] || group.groupName,
545+
})),
534546
bulkActions: allowedBulkActions.map(
535547
(action, i) => ({
536548
...action,

0 commit comments

Comments
 (0)