Reputation: 617
I installed and configure the jQuery dataTables plugin in this way:
where $locale = 'Italian'; from the official dataTables site
$( document ).ready(function() {
$(function () {
$('.data-table').dataTable({
"language": {
"url": '<?php echo asset_path("js/datatables/i18n/{$locale}.lang") ?>'
},
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
filter: true,
sort: true,
info: true,
autoWidth: true,
order: [[ 0, "desc" ]],
aoColumnDefs: [
{ bSortable: false, "aTargets": [ -1 ] }
]
});
});
});
I tried substituting "language" param with "oLanguage" and "sUrl", but no matter what I do, I still see my dataTables messages in English.
....
"oLanguage": {
"sUrl": '<?php echo asset_path("js/datatables/i18n/{$locale}.lang") ?>'
},
....
I think I am doing something wrong, maybe I need first initialize table and only after that call the language, or vice versa before get the language translations and after set the dataTables ... I'm really new with this plugin, if someone can help me, it'd be fantastic!
Upvotes: 2
Views: 6004
Reputation: 2108
Is this what you're looking for?
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Italian.json"
}
Demo http://jsfiddle.net/mke35Lrk/.
Upvotes: 6