0

I would like to change the language of the bootstrap date paginator: http://jondmiles.com/bootstrap-datepaginator/

Right now my paginator looks like this: https://i.stack.imgur.com/X7gwW.png

I would like to change the language of the weekdays and the months. I do not know if this is possible, because i could not find anything in the documentation or in the code. I am using the default setup for the paginator:

f.defaults = {
    fillWidth: !0,
    highlightSelectedDate: !0,
    highlightToday: !0,
    hint: "dddd, Do MMMM YYYY",
    injectStyle: !0,
    itemWidth: 35,
    navItemWidth: 20,
    offDays: "Sat,Sun",
    offDaysFormat: "ddd",
    onSelectedDateChanged: null,
    selectedDate: moment().clone().startOf("day"),
    selectedDateFormat: "YYYY-MM-DD",
    selectedItemWidth: 140,
    showCalendar: !0,
    showOffDays: !0,
    showStartOfWeek: !0,
    size: d,
    startOfWeek: "Mon",
    startOfWeekFormat: "ddd",
    squareEdges: !1,
    text: "ddd<br/>Do",
    textSelected: "dddd<br/>Do, MMMM YYYY",
    useBootstrap2: !1,
    width: 0
}
1
  • As it depends upon moment.js, you may want to try fiddling with moment locale and see if that works.
    – Patel
    Jul 9, 2015 at 9:15

3 Answers 3

1

The solution was: moment.locale('da', {..} - http://momentjs.com/docs/#/customization/

0

as example you can insert

this string - 
moment.locale("YOUR LOCALE");

before

f.defaults = {
fillWidth: !0
....

it will work

0

I had to solve the same problem but the language needed to be changed dynamically. Arthur Enokyan's answer was a good starting point, but the language remained the one set initially.

What made it work for me was changing it inside the _buildDate method:

for (var m = start; m.isBefore(end); m.add('days', 1)) {
                // MY CODE BELOW 
                if (this.options.language) {
                    if (typeof m.lang === 'function') {
                        m.lang(this.options.language);
                    } else if (typeof m.locale === 'function') {
                        m.locale(this.options.language);
                    }
                }

The plugin used originally an older version of Moment, where you had to change the language with moment.lang so the code above supports both cases.

Just specify the language in the initialisation code's options like this:

var options = {
        language: 'en',
        selectedDateFormat: 'YYYY-MM-DD'
    }
$('#paginator').datepaginator(options);

You can test the changes here, there are three different languages that you can choose from. Disclaimer, I made that demo page for a blog post where I explained in detail how I solved this exact problem with Bootstrap Date Paginator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.