I am using Symfony to build a form with a datepicker. I have found the day to have a datepicker but I don’t know how to have it in french.
This is the code in my base.html.twig file :
{# Date picker #}
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.js"></script>
<script>
{% if app.request.locale == 'en' %}
$(document).ready(function() {
$('.js-datepicker').datepicker({
format: 'DD MM d yyyy'
});
});
{% elseif app.request.locale == 'fr' %}
$(document).ready(function() {
$('.js-datepicker').datepicker({
format: 'DD d MM yyyy'
});
});
{% endif %}
</script>
2
Answers
Here, you can try this to change the language.
If you want to change language of datepicker (english to french), you’ll need to use
$.datepicker.setDefaults