I store, in a session variable, which language does user wants to translate but I don't know to pass it DataTables
I found this explanation on the datatables website but that didn't really help, where do I set language param ?
u can try other language "oLanguage": { "sUrl": "//cdn.datatables.net/plug-ins/1.10.7/i18n/<LANGUAGE>. json" } a open datatables.net/plug-ins/i18n and look translation is click ur language later take CDN links :) This does not seem to work any more in 1.10.
Use page. len() API function to change page length dynamically. This method changes the number of rows shown, but the number in the Show x Entries select box remains the same.
You have to either create a language file and then set it using :
"oLanguage": {
"sUrl": "media/language/your_file.txt"
}
Im not sure what server language you are using but something like this would work in PHP :
"oLanguage": {
"sUrl": "media/language/custom_lang_<?php echo $language ?>.txt"
}
Where language
matches the file name for a specific language.
or change individual settings :
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Showing 0 to 0 of 0 records",
"sInfoFiltered": "(filtered from _MAX_ total records)"
}
For more details read this : http://datatables.net/plug-ins/i18n
//Spanish
$('#TableName').DataTable({
"language": {
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ registros",
"sZeroRecords": "No se encontraron resultados",
"sEmptyTable": "Ningún dato disponible en esta tabla",
"sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
"sInfoPostFix": "",
"sSearch": "Buscar:",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Cargando...",
"oPaginate": {
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria": {
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
}
}
});
Also using a cdn:
//cdn.datatables.net/plug-ins/a5734b29083/i18n/Spanish.json
More options: http://www.datatables.net/plug-ins/i18n/English [| Spanish | etc]
for Arabic language
var table = $('#my_table')
.DataTable({
"columns":{//......}
"language":
{
"sProcessing": "جارٍ التحميل...",
"sLengthMenu": "أظهر _MENU_ مدخلات",
"sZeroRecords": "لم يعثر على أية سجلات",
"sInfo": "إظهار _START_ إلى _END_ من أصل _TOTAL_ مدخل",
"sInfoEmpty": "يعرض 0 إلى 0 من أصل 0 سجل",
"sInfoFiltered": "(منتقاة من مجموع _MAX_ مُدخل)",
"sInfoPostFix": "",
"sSearch": "ابحث:",
"sUrl": "",
"oPaginate": {
"sFirst": "الأول",
"sPrevious": "السابق",
"sNext": "التالي",
"sLast": "الأخير"
}
}
});
Ref: https://datatables.net/plug-ins/i18n/Arabic
Author: Ossama Khayat
French translations:
$('#my_table').DataTable({
"language": {
"sProcessing": "Traitement en cours ...",
"sLengthMenu": "Afficher _MENU_ lignes",
"sZeroRecords": "Aucun résultat trouvé",
"sEmptyTable": "Aucune donnée disponible",
"sInfo": "Lignes _START_ à _END_ sur _TOTAL_",
"sInfoEmpty": "Aucune ligne affichée",
"sInfoFiltered": "(Filtrer un maximum de_MAX_)",
"sInfoPostFix": "",
"sSearch": "Chercher:",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Chargement...",
"oPaginate": {
"sFirst": "Premier", "sLast": "Dernier", "sNext": "Suivant", "sPrevious": "Précédent"
},
"oAria": {
"sSortAscending": ": Trier par ordre croissant", "sSortDescending": ": Trier par ordre décroissant"
}
}
});
});
sorry to revive this thread, i know there is the solution, but it is easy to change the language with the datatables. Here, i leave you with my own datatable example.
$(document).ready(function ()
// DataTable
var table = $('#tblUsuarios').DataTable({
aoColumnDefs: [
{"aTargets": [0], "bSortable": true},
{"aTargets": [2], "asSorting": ["asc"], "bSortable": true},
],
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
}
});
The language you get from the following link:
http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n
Just replace the URL value in the language option with the one you like. Remember to always use the comma
Worked for me, hope it will work for anyone.
Best regards!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With