jQuery(document).ready(function ($) {
$.datepicker.setDefaults($.datepicker.regional[""]);
var lng = $(".language").text().substr(0, 2);
$("#dtFrom").datepicker({ dateFormat: 'mm-dd-yy' },
$.datepicker.regional[lng]
);
$("#dtTo").datepicker({ dateFormat: 'mm-dd-yy' },
$.datepicker.regional[lng]
);
});
My issue: as the code is above, if ‘lng’ equals ‘fr’ my datepicker is still english, if I comment out the first line ($.datepicker.setDefaults($.datepicker.regional[“”]);) my datepicker always renders french (regardless of the value of ‘lng’). Figure I’m missing something simple. Any ideas how to get this datepicker to render it’s contents in the proper language (french or english based on the value of ‘lng’)?
This is very well explained in the jQuery UI Docs.
Here’s the demo:
To make your code mimic the demo, this is what i would change: