nkd, on 27 October 2012 - 04:48 AM, said:
Antonio, first of all thank you for your wonderful extension!
I have a question for you (or anyone who has the answer), how can I change the language of the TbDateRangePicker according to the language settings of my yii app?
Right now I had to hard code the name of the days in spanish into
bootstrap-daterangepicker.js, and the name of the months (that for some reason are not taken from that same file), into
date.js. But I need to do this dynamically depending on the language setting of the yii application (English/Spanish). How can I do this?
I am using the date picker as a filter for a grid like this:
...
array(
'name'=>'date_created',
'filter'=>$this->widget('bootstrap.widgets.TbDateRangePicker', array(
'model'=>$model,
'attribute'=>'date_created'),
true),
),
...
In order to use internationalization for DateRangePicker you will have to provide the
locale object to its options, so I recommend you to create a different locale for the different languages you use.
For example, for spanish:
$this->widget('bootstrap.widgets.TbDateRangePicker', array(
'model'=>$model,
'attribute'=>'date_created',
'options'=>array('locale'=>array(
'applyLabel'=>'Aplicar',
'fromLabel'=>'Desde',
'toLabel'=>'Hasta',
'customRangeLabel'=>'Personalizado',
'daysOfWeek'=>array('Do','Lu','Ma','Mi','Ju','Vi',Sa'),
'monthNames'=>array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'),
'firstDay'=>1
)),
true,
),
Check bootstrap.daterangepicker.js file in asssets/js folder
Totally, untested!!!