@@ -26,17 +26,24 @@ export class UmbDeleteEntityAction extends UmbEntityActionBase<MetaEntityActionD
26
26
if ( ! item ) throw new Error ( 'Item not found.' ) ;
27
27
28
28
const headline = this . args . meta . confirm ?. headline ?? '#actions_delete' ;
29
- const content = this . args . meta . confirm ?. message ?? '#defaultdialogs_confirmdelete' ;
30
- const keysFromString = this . #localize. getKeysFromString ( content ) ;
31
- const argsMap : UmbLocalizeStringArgsMap = keysFromString . reduce ( ( acc : UmbLocalizeStringArgsMap , key ) => {
29
+ const message = this . args . meta . confirm ?. message ?? '#defaultdialogs_confirmdelete' ;
30
+
31
+ /* We need to replace the token in a translation with the item name.
32
+ A string can potentially consist of multiple translation keys.
33
+ First we find all the translation keys in message. */
34
+ const keysFromMessageString = this . #localize. getKeysFromString ( message ) ;
35
+
36
+ // Second we create a map of the translation keys found in the message and the arguments that should replace the tokens.
37
+ // This will enable the localize service to pass and replace the tokens in the all the translations with the item name.
38
+ const argsMap : UmbLocalizeStringArgsMap = keysFromMessageString . reduce ( ( acc : UmbLocalizeStringArgsMap , key ) => {
32
39
acc [ key ] = [ item . name ] ;
33
40
return acc ;
34
41
} , { } ) ;
35
42
36
43
// TODO: handle items with variants
37
44
await umbConfirmModal ( this . _host , {
38
45
headline : this . #localize. string ( headline ) ,
39
- content : this . #localize. string ( content , argsMap ) ,
46
+ content : this . #localize. string ( message , argsMap ) ,
40
47
color : 'danger' ,
41
48
confirmLabel : '#general_delete' ,
42
49
} ) ;
0 commit comments