Skip to content

Commit 0c6bef0

Browse files
committed
add comment
1 parent 42dbfbe commit 0c6bef0

File tree

1 file changed

+11
-4
lines changed
  • src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/delete

1 file changed

+11
-4
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/delete/delete.action.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,24 @@ export class UmbDeleteEntityAction extends UmbEntityActionBase<MetaEntityActionD
2626
if (!item) throw new Error('Item not found.');
2727

2828
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) => {
3239
acc[key] = [item.name];
3340
return acc;
3441
}, {});
3542

3643
// TODO: handle items with variants
3744
await umbConfirmModal(this._host, {
3845
headline: this.#localize.string(headline),
39-
content: this.#localize.string(content, argsMap),
46+
content: this.#localize.string(message, argsMap),
4047
color: 'danger',
4148
confirmLabel: '#general_delete',
4249
});

0 commit comments

Comments
 (0)