How to add Datatables buttons with language file?
How to add Datatables buttons with language file?
Loulou90
Posts: 11Questions: 4Answers: 0
Hello,
I try, but without success, to use my translation file with extraction buttons
Here is my code:
$(document).ready(function(){
var table = $('#table').DataTable({
"columnDefs": [{"orderable": false, "targets": 5}],
"order": [1, "desc"],
"oLanguage": { "sUrl": "/public/us.txt" },
buttons: [{
extend: 'csv',
text: '<i class="fa fa-download"></i> Export to CSV',
title: 'Data export - <?= date("YmdHi") ?>',
className: 'btn-sm',
exportOptions: { columns: [0, 1, 2, 3, 4, 5] }
},{
extend: 'excel',
text: '<i class="fa fa-download"></i> Export to Excel',
title: 'Data export - <?= date("YmdHi") ?>',
className: 'btn-sm',
exportOptions: { columns: [0, 1, 2, 3, 4, 5] }
}]
});
table.buttons().container().appendTo( '.button-container' );
});
The problem is when I add the line "oLanguage": { "sUrl": "/public/us.txt" }
the buttons do not appear and I have no errors in the google console
So How to add Datatables buttons with language file?
Thank you
This discussion has been closed.
Answers
us.txt :
Hi @Loulou90 ,
That does look right, the same (more or less) as this example. If you could link to a running test case showing the issue we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
How do you reference the buttons from the language file, what are the identifiers?
The documentation for each Button states where it will read the language information from - for example for
copyHtml5
you use thelanguage.buttons.copy
property for that button in the language file:We're going to work on a central repository of all translatable strings we use at some point (not sure of the time frame yet).
Allan