Joakim Carlsson
Joakim Carlsson

Reputation: 1580

bootstrap DatePicker can't display on swedish

I'm using this DatePicker from bootstrap https://bootstrap-datepicker.readthedocs.org/en/latest/

But I want my months / dates in sweden so I went into the Javascript and I did change the following line: language: 'en',too language: 'sv',

but than my DatePicker looks like this:

enter image description here

DatePicker settings:

    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'
};

My DatePicker(s) in my View:

    $(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));
            }
        });

    });
});

Upvotes: 2

Views: 1414

Answers (1)

Guruprasad J Rao
Guruprasad J Rao

Reputation: 29683

You have changed language from en to sv fine but you also need to include external js to support swedish language and you can get it here

Swedish JS

Now you just add script src to that js after adding bootstrap-datepicker.js as below

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

Working DEMO

Upvotes: 4

Related Questions