Search code examples
javascriptjqueryjspdatapicker

Datepicker missing with English locale. What is may be wrong?


I have datepicker, on jsp page here:

$.datepicker.setDefaults($.datepicker.regional['<%=response.getLocale().getLanguage()%>']);

$("#dateinputOne, #dateinputTwo").datepicker({
    dateFormat: "yy-mm-dd",
    beforeShowDay: beforeShowDayHandler,
    showOn: 'both',
    onClose: function (dateText, inst) {
        $(this).attr("disabled", false);
    },
    beforeShow: function (input, inst) {
        $(this).attr("disabled", true);
    }
});

I use three languages: Russian, English, Chinese to change locale. Everything works fine until I change to english. Russian and Chinese works fine, but when I change on English, instead English I see Chinese. What may be a problem with it???

I check this code: '<%=response.getLocale().getLanguage()%>' and it returns en like and ru or cn for Chinese. Getting to hear from you folks. Thank you.


Solution

  • Use empty string "" instead of "en" as index of $.datepicker.regional.

    It should look like this:

    $.datepicker.regional['<%=response.getLocale().getLanguage() == "en" ? "" : response.getLocale().getLanguage()%>']