how to change language for DataTable how to change language for DataTable jquery jquery

how to change language for DataTable


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]


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!