Bootstrap Datepicker Locale with MomentJS

Jason picture Jason · Mar 3, 2016 · Viewed 17.3k times · Source

I am using a Bootstrap Datepicker available here and everything is working fine. However, I want to localize the calendar given a user's preferred language. I've set the following when I initialize the datepicker:

locale: 'fr'

However, I get a console error that reads:

Uncaught TypeError: locale() locale fr is not loaded from moment locales!

I am including MomentJS in my project:

<script src="/vendors/moment/min/moment.min.js"></script>

This is my first implementation so I feel like I'm missing something simple but just can't figure it out.

Answer

Salim Hamidi picture Salim Hamidi · Aug 23, 2016

Replace

/moment/min/moment.min.js

by

/moment/min/moment-with-locales.js

and it will work