Integrate confirm message for remove and update into language defaults
Integrate confirm message for remove and update into language defaults
I have been trying to do my language settings in case the user's language is not English. I am almost done, but I don't know how to set the confirm message for deletion or update of rows.
So far I have only been able to set this individually for the specific table which is a nuisance because of so much code redundancy. As you can see I tried to integrate something i18n based. This code works when used within the individual Editor definition but not here. Any ideal how to resolve this please?
function dataTablesInit() {
//Data tables default new button labels
var showAllLabel = 'Show all';
//Data tables language settings
if (lang === 'de') {
showAllLabel = 'Alles anzeigen';
$.extend( true, $.fn.dataTable.defaults, {
// "i18n": {
// remove: {
// confirm: {
// _: 'Sind Sie sicher, dass Sie %d Zeilen löschen wollen?',
// 1: 'Sind Sie sicher, dass Sie eine Zeile löschen wollen?'
// }
// }
// },
"language": {
"decimal": ",",
"thousands": ".",
"info": "Anzeige _START_ bis _END_ von _TOTAL_ Einträgen",
"infoEmpty": "Keine Einträge",
"infoPostFix": "",
"infoFiltered": " - gefiltert aus insgesamt _MAX_ Einträgen",
"loadingRecords": "Bitte warten Sie - Daten werden geladen ...",
"paginate": {
"first": "Erste",
"last": "Letzte",
"next": "Nächste",
"previous": "Zurück"
},
"processing": "Verarbeitung läuft ...",
"search": "Suche:",
"searchPlaceholder": "Suchbegriff",
"zeroRecords": "Keine Daten! Bitte ändern Sie Ihren Suchbegriff.",
"emptyTable": "Keine Daten vorhanden",
"aria": {
"sortAscending": ": aktivieren, um Spalte aufsteigend zu sortieren",
"sortDescending": ": aktivieren, um Spalte absteigend zu sortieren"
},
//only works for built-in buttons, not for custom buttons
"buttons": {
"create": "Neu",
"edit": "Ändern",
"remove": "Löschen",
"copy": "Kopieren",
"csv": "CSV-Datei",
"excel": "Excel-Tabelle",
"pdf": "PDF-Dokument",
"print": "Drucken",
"colvis": "Spalten Auswahl",
"collection": "Auswahl"
},
select: {
rows: {
_: '%d Zeilen ausgewählt',
0: 'Zeile anklicken um auszuwählen',
1: 'Eine Zeile ausgewählt'
}
}
}
} );
}
//custom button added with language specific label
$.fn.dataTable.ext.buttons.showAll = {
text: showAllLabel
};
}
This question has an accepted answers - jump to answer
Answers
The principle of your commented out lines are correct, but they are being extended on the wrong object. The Editor defaults should be set on the
$.fn.dataTable.Editor.defaults
object.Those are Editor initialisation options, not DataTables.
Allan
Thanks a lot, Allan. In the meantime I had figured it out myself, but it took me really long ...