Reputation: 33
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.sstatic.net/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
}
Upvotes: 0
Views: 1671
Reputation: 3650
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.
Upvotes: 0
Reputation: 1
as example you can insert
this string -
moment.locale("YOUR LOCALE");
before
f.defaults = {
fillWidth: !0
....
it will work
Upvotes: 0
Reputation: 33
The solution was: moment.locale('da', {..}
- http://momentjs.com/docs/#/customization/
Upvotes: 1