根据文化显示datepicker?

时间:2013-11-27 08:04:38

标签: jquery twitter-bootstrap datepicker

我正在继续this question,因为我没有得到完整答案。

问题:

  1. 根据文化,第一周的日子可以改变吗?

  2. 如果是这样,如何根据文化显示日期选择器?

  3. 我正在使用Twitter Bootstrap datepicker

1 个答案:

答案 0 :(得分:1)

要显示周数,您应使用calendarWeeks选项并将其设置为true,因为默认情况下为false。要设置一周的开始日期,请参阅选项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
   });
});

详细了解Bootstrap-Datepicker Documentation

中的选项和设置

Localization

该插件支持月份和工作日名称的 i18n weekStart选项。默认值为英语(“en”); js/locales/目录中提供了其他可用的翻译,只需在插件后包含所需的语言环境即可。要添加更多语言,只需在调用$.fn.datepicker.dates之前向.datepicker()添加密钥即可。

示例:

$.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"
};

从右到左的语言也可能包含rtl: true,以便正确显示日历。