Internationalisation
Internationalisation
Hi,
Firstly, thanks for the great tool, Allan! We have a multi-language MVC application where we currently have 8 different pages using a DataTable. It is possible to change language at any point in the app. My question is: How is it best to handle the changing of language without having to implement in all 8 instances? For example, the language for our JQuery DatePicker is handled like this in our site.master:
$(".DatePicker").datepicker($.datepicker.regional['<%= ViewContext.RouteData.Values["language"] %>']);
Is something like this possible with DataTables? We have stored each language settings in their own .txt file as recommend in the documentation, but I'm just having trouble grasping the correct way of switching between files.
Cheers,
Michal
Firstly, thanks for the great tool, Allan! We have a multi-language MVC application where we currently have 8 different pages using a DataTable. It is possible to change language at any point in the app. My question is: How is it best to handle the changing of language without having to implement in all 8 instances? For example, the language for our JQuery DatePicker is handled like this in our site.master:
$(".DatePicker").datepicker($.datepicker.regional['<%= ViewContext.RouteData.Values["language"] %>']);
Is something like this possible with DataTables? We have stored each language settings in their own .txt file as recommend in the documentation, but I'm just having trouble grasping the correct way of switching between files.
Cheers,
Michal
This discussion has been closed.
Replies
I think you've already got most of your answer in your post :-). Perhaps something like this:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"oLanguage": {
"sUrl": "media/language/<%= ViewContext.RouteData.Values["language"] %>"
}
} );
} );
[/code]
Demo of loading from a language file: http://datatables.net/examples/advanced_init/language_file.html
If you don't want to load a file using Ajax on each page load, then you could store each of the 8 languages in a Javascript object and switch which one you want to use based on the language. Example of using an object with language information: http://datatables.net/examples/basic_init/language.html . Just needs pulled out into an object variable.
Regards,
Allan