@@ -14,6 +14,7 @@ import {
1414 RedirectionSideEffect ,
1515 useGetRecordRepresentation ,
1616 useGetResourceLabel ,
17+ useResourceTranslation ,
1718} from 'ra-core' ;
1819
1920import { Confirm } from '../layout' ;
@@ -68,8 +69,6 @@ export const DeleteWithConfirmButton = <RecordType extends RaRecord = any>(
6869 const getResourceLabel = useGetResourceLabel ( ) ;
6970 const getRecordRepresentation = useGetRecordRepresentation ( resource ) ;
7071 let recordRepresentation = getRecordRepresentation ( record ) ;
71- const confirmTitle = `resources.${ resource } .message.delete_title` ;
72- const confirmContent = `resources.${ resource } .message.delete_content` ;
7372 const resourceName = translate ( `resources.${ resource } .forcedCaseName` , {
7473 smart_count : 1 ,
7574 _ : humanize (
@@ -84,15 +83,37 @@ export const DeleteWithConfirmButton = <RecordType extends RaRecord = any>(
8483 if ( isValidElement ( recordRepresentation ) ) {
8584 recordRepresentation = `#${ record ?. id } ` ;
8685 }
87- const label =
88- labelProp ??
89- translate ( `resources.${ resource } .action.delete` , {
86+ const label = useResourceTranslation ( {
87+ resourceI18nKey : `resources.${ resource } .action.delete` ,
88+ baseI18nKey : 'ra.action.delete' ,
89+ options : {
90+ name : getResourceLabel ( resource , 1 ) ,
9091 recordRepresentation,
91- _ : translate ( `ra.action.delete` , {
92- name : getResourceLabel ( resource , 1 ) ,
93- recordRepresentation,
94- } ) ,
95- } ) ;
92+ } ,
93+ userText : labelProp ,
94+ } ) ;
95+ const confirmTitle = useResourceTranslation ( {
96+ resourceI18nKey : `resources.${ resource } .message.delete_title` ,
97+ baseI18nKey : 'ra.message.delete_title' ,
98+ options : {
99+ recordRepresentation,
100+ name : resourceName ,
101+ id : record ?. id ,
102+ ...titleTranslateOptions ,
103+ } ,
104+ userText : confirmTitleProp ,
105+ } ) ;
106+ const confirmContent = useResourceTranslation ( {
107+ resourceI18nKey : `resources.${ resource } .message.delete_content` ,
108+ baseI18nKey : 'ra.message.delete_content' ,
109+ options : {
110+ recordRepresentation,
111+ name : resourceName ,
112+ id : record ?. id ,
113+ ...contentTranslateOptions ,
114+ } ,
115+ userText : confirmContentProp ,
116+ } ) ;
96117
97118 return (
98119 < Fragment >
@@ -112,35 +133,9 @@ export const DeleteWithConfirmButton = <RecordType extends RaRecord = any>(
112133 < Confirm
113134 isOpen = { open }
114135 loading = { isPending }
115- title = { confirmTitleProp ?? confirmTitle }
116- content = { confirmContentProp ?? confirmContent }
136+ title = { confirmTitle }
137+ content = { confirmContent }
117138 confirmColor = { confirmColor }
118- titleTranslateOptions = { {
119- recordRepresentation,
120- name : resourceName ,
121- id : record ?. id ,
122- _ :
123- confirmTitleProp ??
124- translate ( 'ra.message.delete_title' , {
125- recordRepresentation,
126- name : resourceName ,
127- id : record ?. id ,
128- } ) ,
129- ...titleTranslateOptions ,
130- } }
131- contentTranslateOptions = { {
132- recordRepresentation,
133- name : resourceName ,
134- id : record ?. id ,
135- _ :
136- confirmContentProp ??
137- translate ( 'ra.message.delete_content' , {
138- recordRepresentation,
139- name : resourceName ,
140- id : record ?. id ,
141- } ) ,
142- ...contentTranslateOptions ,
143- } }
144139 onConfirm = { handleDelete }
145140 onClose = { handleDialogClose }
146141 />
0 commit comments