Translate not working in file config


(htxuanthanh) #1

I use Yii::t() to define param in config/params.php

config/params.php:

return array(
‘daterangepicker’ => array(
‘options’ => array(
‘startDate’ => ‘js:moment().startOf(‘month’)’,
‘endDate’ => ‘js:moment().endOf(‘month’)’,
‘minDate’ => ‘js:‘01/01/2012’’,
‘maxDate’ => false,
// ‘dateLimit’ => array(
// ‘days’ => 60
// ),
‘showDropdowns’ => true,
‘showWeekNumbers’ => true,
‘timePicker’ => false,
‘timePickerIncrement’ => 1,
‘timePicker12Hour’ => true,
‘ranges’ => array(
Yii::t(‘web/label’,‘Today’) => [‘js:moment()’, ‘js:moment()’],
Yii::t(‘web/label’,‘Yesterday’) => [‘js:moment().subtract(1, ‘days’)’, ‘js:moment().subtract(1, ‘days’)’],
Yii::t(‘web/label’,‘Last {days} Days’, array(’{days}’=> 7)) => [‘js:moment().subtract(6, ‘days’)’, ‘js:moment()’],
Yii::t(‘web/label’,‘Last {days} Days’, array(’{days}’=> 30)) => [‘js:moment().subtract(29, ‘days’)’, ‘js:moment()’],
Yii::t(‘web/label’,‘This Month’) => [‘js:moment().startOf(‘month’)’, ‘js:moment().endOf(‘month’)’],
Yii::t(‘web/label’,‘Last Month’) => [‘js:moment().subtract(1, ‘month’).startOf(‘month’)’, ‘js:moment().subtract(1, ‘month’).endOf(‘month’)’]
),
‘open’ => ‘left’,
‘format’ => ‘MM/DD/YYYY’,
‘buttonClasses’ => [‘btn btn-default’],
‘applyClass’ => ‘btn-sm btn-primary’,
‘cancelClass’ => ‘btn-sm’,
‘locale’ => array(
‘fromLabel’ => Yii::t(‘web/label’,‘From’),
‘toLabel’ => Yii::t(‘web/label’,‘To’),
‘customRangeLabel’ => Yii::t(‘web/label’,‘Custom’),
‘firstDay’ => 1,
),
),
)
);

message/vi/web/label.php:

return array(
‘From’ => ‘Từ’,
‘To’ => ‘Đến’,
‘Custom’ => ‘Tùy chọn’,
‘Today’ => ‘Hôm nay’,
‘Yesterday’ => ‘Hôm qua’,
‘Last {days} Days’ => ‘{days} ngày trước’,
‘This Month’ => ‘Tháng này’,
‘Last Month’ => ‘Tháng trước’,
‘Apply’ => ‘Áp dụng’,
‘Cancel’ => ‘Hủy’,
);

view:

<?php $this->widget(‘booster.widgets.TbDateRangePicker’, array(
‘id’ => ‘abc’,
‘name’ => ‘abc’,
‘options’ => Yii::app()->params->daterangepicker[‘options’],
‘callback’ => ‘js:function(start, end){
console.log("A new date selection was made: " + start.format(‘YYYY-MM-DD’) + ’ to ’ + end.format(‘YYYY-MM-DD’));
}’,
‘htmlOptions’ => array(
‘class’ => ‘form-control’,
‘placeholder’ => ‘dd/mm/yyyy - dd/mm-yyyy’,
)
)); ?>

result:

it show the key, not the translated one.
Does anyone have solutions for this?
Thanks