From e607fa5f204bdaac281a3f435ae3ece3a1d1d9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Zaninotto?= Date: Wed, 20 Nov 2024 23:48:23 +0100 Subject: [PATCH] Fix SortButton default translation --- packages/ra-ui-materialui/src/button/SortButton.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/ra-ui-materialui/src/button/SortButton.tsx b/packages/ra-ui-materialui/src/button/SortButton.tsx index 74a3dfd269a..97b0799aaa5 100644 --- a/packages/ra-ui-materialui/src/button/SortButton.tsx +++ b/packages/ra-ui-materialui/src/button/SortButton.tsx @@ -91,11 +91,16 @@ const SortButton = (props: SortButtonProps) => { setAnchorEl(null); }; + const fieldLabel = translateLabel({ + resource, + source: sort.field, + }); const buttonLabel = translate(label, { - field: translateLabel({ - resource, - source: sort.field, - }), + field: fieldLabel, + field_lower_first: + typeof fieldLabel === 'string' + ? fieldLabel.charAt(0).toLowerCase() + fieldLabel.slice(1) + : undefined, order: translate(`ra.sort.${sort.order}`), _: label, });