user3035874
user3035874

Reputation:

Show datepicker based on culture?

I am continuing this question, since I didn't get full answer.

Questions:

  1. Based on the culture, do the day of first week can change?

  2. If it's so, how to show the datepicker based on the culture?

I"m using Twitter Bootstrap datepicker.

Upvotes: 1

Views: 686

Answers (1)

Ilia Ross
Ilia Ross

Reputation: 13412

To show the week number you should use calendarWeeks option and set it to true as by default it's false. To set the start day of the week, refer to option weekStart:

$(document).ready(function () {
  $('#date').datepicker({
     calendarWeeks: true; // Whether or not to show week numbers
     weekStart: 0; // Day of the week start. 0 for Sunday; 1 for Monday
   });
});

Read more about options and settings in Bootstrap-Datepicker Documentation

Localization

The plugin supports i18n for the month and weekday names and the weekStart option. The default is English (“en”); other available translations are available in the js/locales/ directory, simply include your desired locale after the plugin. To add more languages, simply add a key to $.fn.datepicker.dates, before calling .datepicker().

Example:

$.fn.datepicker.dates['en'] = {
    days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
    daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
    months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    today: "Today",
    clear: "Clear"
};

Right-to-left languages may also include rtl: true to make the calendar display appropriately.

Upvotes: 1

Related Questions