admin管理员组

文章数量:1318973

I've been stuck on changing the language of a calendar from English which is the default to French on Bootstrap 4 and I can't do it, it's driving me mad!

<script src="js/jquery.min.js"></script>
<script type="text/javascript" src=".11.3.min.js"></script>
<script type="text/javascript" src=".4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href=".4.1/css/bootstrap-datepicker3.css"/>
<script src="./js/main.js"></script>
<script>
$(document).ready(function() {
    var date_input = $('input[name="date"]');
    var container = $('.input-group').length > 0 ? $('.input-group').parent() :
        'body';
    var options = {
        format: 'dd/mm/yyyy',
        container: container,
        todayHighlight: true,
        autoclose: true,
        daysOfWeekDisabled: [0, 6],
        weekStart: [1]
    };
    date_input.datepicker(options);
});
</script>

Thanks

I've been stuck on changing the language of a calendar from English which is the default to French on Bootstrap 4 and I can't do it, it's driving me mad!

<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="https://code.jquery./jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare./ajax/libs/bootstrapdatepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare./ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
<script src="./js/main.js"></script>
<script>
$(document).ready(function() {
    var date_input = $('input[name="date"]');
    var container = $('.input-group').length > 0 ? $('.input-group').parent() :
        'body';
    var options = {
        format: 'dd/mm/yyyy',
        container: container,
        todayHighlight: true,
        autoclose: true,
        daysOfWeekDisabled: [0, 6],
        weekStart: [1]
    };
    date_input.datepicker(options);
});
</script>

Thanks

Share Improve this question edited Dec 4, 2018 at 11:36 SayJeyHi 1,8414 gold badges25 silver badges48 bronze badges asked Dec 4, 2018 at 10:57 HafidevHafidev 211 silver badge5 bronze badges 2
  • Can you add the link to the package datepicker ? So we can help you – Djamel Commented Dec 4, 2018 at 11:00
  • 3 Possible duplicate of Change language for bootstrap DateTimePicker – Ali Heikal Commented Dec 4, 2018 at 11:01
Add a ment  | 

3 Answers 3

Reset to default 4

<script src="https://cdnjs.cloudflare./ajax/libs/bootstrap-datepicker/1.8.0/locales/bootstrap-datepicker.fr.min.js"></script>

Use this tag after bootstrap-datepicker. and this

$('.datepicker').datepicker({
      language: 'fr'})

It will work.

It's because you haven't passed the language key to options.

Try adding this keys as options:

 var options = {
    language: 'fr'
};

All locales are available under js/locales. Be sure to include it after plugin initialization.

References:
1- https://bootstrap-datepicker.readthedocs.io/en/latest/i18n.html
2- https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#language
3- Change language for bootstrap DateTimePicker

You can use translation i18n of lang and call it, theres no needed to call language specific. Like this.

this.$i18n.t("fixed_pickups.weekdays.monday") }

本文标签: javascriptHow to change language on bootstrap 4 datepickerStack Overflow