Error with the language using Bootstrap DatePicker

1

I have a form and I am using DatePicker with Bootstrap to select dates. I do not know why the calendar does not appear in Spanish. This is my code, the calendar appears in English, but I want it in Spanish:

<head>
  <link rel="stylesheet" href="<?php echo base_url(); ?>css/datepicker.css" media="screen" />
  <script src="<?php echo base_url(); ?>js/bootstrap-datepicker.js"></script>   
  <script src="<?php echo base_url(); ?>js/locales/bootstrap-datepicker.es.js"></script>   
</head>
<script type="text/javascript">
  $(document).ready(function() {

    $('.calendario').datepicker({
      pickTime: false,
      autoclose: true,
      language: 'es'
    });
  });
</script>
<div class="form-group">                
  <div class="col-xs-3">
    <div class='input-group date'>
      <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
      </span> 
      <input type='text' name="fechainicio" id="fechainicio" class="form-control calendario" value="<?php echo Fechautil::format(date("Y-m-d")); ?>" placeholder="Fecha de Inicio" data-date-format="dd/mm/yyyy" required=""/>
    </div>
  </div> 
</div>
    
asked by mer 23.02.2016 в 02:15
source

1 answer

1

With your same code, just changing the file paths to online versions on GitHub or CDN, the calendar is seen in Spanish :

<head>
  <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
  <link rel="stylesheet" href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css"/>
  <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>   
  <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/locales/bootstrap-datepicker.es.js"></script>   
</head>
<script type="text/javascript">
  $(document).ready(function() {

    $('.calendario').datepicker({
      pickTime: false,
      autoclose: true,
      language: 'es'
    });
  });
</script>
<div class="form-group">                
  <div class="col-xs-3">
    <div class='input-group date'>
      <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
      </span> 
      <input type='text' name="fechainicio" id="fechainicio" class="form-control calendario" value="22/02/2016" placeholder="Fecha de Inicio" data-date-format="dd/mm/yyyy" required="" style="width:150px;"/>
    </div>
  </div> 
</div>

Keeping that in mind, you're probably not including the language file correctly . Make sure the route is correct (look in the console to see if there is a 404 error when loading the file).

    
answered by 23.02.2016 в 04:02