更改DatePicker语言Yii2

时间:2018-12-20 14:26:31

标签: datepicker yii2 bootstrap-4

如何在Yii2中更改DatePicker的默认语言(英语)?

示例代码:

<?= $form->field($model, 'birthday')->widget(DatePicker::classname(), [
    'options' => ['placeholder' => 'Enter birth date ...'],
    'pluginOptions' => [
        'format' => 'dd-mm-yyyy',
        'autoclose'=>true
    ]
]); ?>

1 个答案:

答案 0 :(得分:1)

您可以通过添加如下语言字段来实现:

<?= $form->field($model, 'birthday')->widget(DatePicker::classname(), [
    'language' => 'it',
    'options' => ['placeholder' => 'Enter birth date ...'],
    'pluginOptions' => [
        'format' => 'dd-mm-yyyy',
        'autoclose'=>true
    ]
]); ?>

截断的代码:

'language' => 'it'

例如,在这里我将语言更改为 Italian