Modify the BootStrap Datepicker plug-in to the default Chinese implementation method, bootstrapdatepicker

Source: Internet
Author: User

Modify the BootStrap Datepicker plug-in to the default Chinese implementation method, bootstrapdatepicker

Bootstrap-datepicker is a very good time selection plug-in. By default, it displays dates in English. You can use the following several small changes to support default Chinese characters:

1. First save the bootstrap-datepicker.js as UTF-8 format

2. added the cn language option.

Var dates = $. 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", "l", "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"}, cn: {days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Saturday ", "Sunday"], daysShort: ["day", "one", "two", "three", "four", "five", "Six ", "7"], daysMin: ["day", "1", "2", "3", "4", "5", "6 ", "7"], months: ["August ", "August", "August", "August"], monthsShort: ["August ", "August", "August"], today: "today", clear: "clear "}};

The red part is the added language option.

3. Modify the default parameters. The default language is cn.

 var defaults = $.fn.datepicker.defaults = {    autoclose: false,    beforeShowDay: $.noop,    calendarWeeks: false,    clearBtn: false,    daysOfWeekDisabled: [],    endDate: Infinity,    forceParse: true,    format: 'mm/dd/yyyy',    keyboardNavigation: true,    language: 'cn',    minViewMode: 0,    orientation: "auto",    rtl: false,    startDate: -Infinity,    startView: 0,    todayBtn: false,    todayHighlight: false,    weekStart: 0  };

The red part indicates the modified default language.

Now, the default Chinese version is modified. The effect is as follows:

The above section describes how to modify the BootStrap Datepicker plug-in to the default Chinese language. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.