Override the oLanguage option in one place
Override the oLanguage option in one place
jpgravel
Posts: 2Questions: 0Answers: 0
Hi,
I use DataTables in my project and I coded everything in english at first to introduce the internationalization later. I'm using dataTable on a lot of tables in my web application and I don't want to change my code for every dataTable calls to add the oLanguage option parameter. This maybe a question more related to JavaScript and how jQuery extension works but it would be nice if I could just do someting like I did with jQuery-ui datePicker:
[code]
$.datepicker.regional['fr'] = { /* language definition object */ };
$.datepicker.regional['it'] = { /* language definition object */ };
$.datepicker.regional['de'] = { /* language definition object */ };
$.datepicker.regional['en'] = { /* language definition object */ };
// Sets the language depending on the user's settings
$.datepicker.setDefaults($.datepicker.regional[localStorage["settings.language"]]);
[/code]
The solution I seek should be done in my javascript files and leaves the original jquery.datatables.js file untouched. I'm sure there is an easy way to do that. It may be that I don't understand the datatable object structure yet.
Thanks
I use DataTables in my project and I coded everything in english at first to introduce the internationalization later. I'm using dataTable on a lot of tables in my web application and I don't want to change my code for every dataTable calls to add the oLanguage option parameter. This maybe a question more related to JavaScript and how jQuery extension works but it would be nice if I could just do someting like I did with jQuery-ui datePicker:
[code]
$.datepicker.regional['fr'] = { /* language definition object */ };
$.datepicker.regional['it'] = { /* language definition object */ };
$.datepicker.regional['de'] = { /* language definition object */ };
$.datepicker.regional['en'] = { /* language definition object */ };
// Sets the language depending on the user's settings
$.datepicker.setDefaults($.datepicker.regional[localStorage["settings.language"]]);
[/code]
The solution I seek should be done in my javascript files and leaves the original jquery.datatables.js file untouched. I'm sure there is an easy way to do that. It may be that I don't understand the datatable object structure yet.
Thanks
This discussion has been closed.
Replies
[code]
$.extend( true, $.fn.dataTable.defaults.oLanguage, {
... // language options
} );
[/code]
See: http://datatables.net/release-datatables/examples/advanced_init/defaults.html
Allan