Hello
I'd like your suggestions about how to deal with translations including scripts.
For instance I have an html field which triggers an url to do an action with a js warning.
In order to translate the field I set the whole in a translation string like this :
Code:
'CHATS_DELETE_ALL_CHATS' => '<form id="deleteForm" action="index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=340&Itemid=9515" method="post"><div class="mb-3"><label class="form-label">Éléments à supprimer:</label><div class="form-check"><input class="form-check-input" type="checkbox" value="chat" id="chat" name="folders[]"> <label class="form-check-label" for="chat">Affichage des conversations</label></div><div class="form-check"><input class="form-check-input" type="checkbox" value="memory" id="memory" name="folders[]"> <label class="form-check-label" for="memory">Mémoire des conversations</label></div></div><input type="submit" class="btn btn-primary" value="Supprimer tous les éléments"></form><script>
jQuery(document).ready(function($) {
$(`#deleteForm`).submit(function() {
var isChecked = $(`input[type=checkbox]:checked`).length > 0;
if (!isChecked) {
alert(`Veuillez sélectionner au moins un dossier à supprimer.`);
return false;
} else {
return confirm(`Voulez-vous vraiment supprimer toutes ces conversations et ces dossiers ? Attention, cette action est définitive et vos éléments ne pourront plus être récupérés !`);
}
});
});</script>',
Is there any other way to do it ?
Is it safe to add scripts in the override files ?
Thanks for your input