引导程序DatePicker无法在瑞典语上显示

时间:2015-09-30 08:01:51

标签: twitter-bootstrap datepicker

我在bootstrap https://bootstrap-datepicker.readthedocs.org/en/latest/

中使用此DatePicker

但我希望我的月份/日期在瑞典,所以我进入了Javascript,我确实更改了以下行:language: 'en', language: 'sv',

但是我的DatePicker看起来像这样:

enter image description here

DatePicker设置:

    var defaults = $.fn.datepicker.defaults = {
    autoclose: true,
    beforeShowDay: $.noop,
    beforeShowMonth: $.noop,
    calendarWeeks: false,
    clearBtn: false,
    toggleActive: false,
    daysOfWeekDisabled: [],
    datesDisabled: [],
    endDate: Infinity,
    forceParse: true,
    format: 'yyyy-mm-dd',
    keyboardNavigation: true,
    language: 'sv',
    minViewMode: 0,
    multidate: false,
    multidateSeparator: ',',
    orientation: "auto",
    rtl: false,
    startDate: -Infinity,
    startView: 0,
    todayBtn: false,
    todayHighlight: false,
    weekStart: 1,
    disableTouchKeyboard: false,
    enableOnReadonly: true,
    container: 'body'
};

我的视图中的我的DatePicker:

    $(function () {
    $(function () {
        $('#fromDate').datepicker({
            showButtonPanel: true,
            changeMonth: true,
            changeYear: true,
            dateFormat: "yy-mm-dd",
            firstDay: 1,
            onSelect: function (dateText) {
                $('#EndDate').datepicker('option', 'minDate', new Date(dateText));
            }
        });

        $('#toDate').datepicker({
            showButtonPanel: true,
            changeMonth: true,
            changeYear: true,
            dateFormat: "yy-mm-dd",
            firstDay: 1,
            onSelect: function (dateText) {
                $('#EndDate').datepicker('option', 'minDate', new Date(dateText));
            }
        });

    });
});

1 个答案:

答案 0 :(得分:3)

您已将languageen更改为sv,但您还需要包含外部js以支持瑞典语,您可以得到它

<强> Swedish JS

现在,您只需在script src添加js之后添加bootstrap-datepicker.js

<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/locales/bootstrap-datepicker.sv.min.js"></script>

<强> Working DEMO