Answer the question
In order to leave comments, you need to log in
How to translate error labels into JS on the client, activeForm?
Why or how to make the translation work?
Now I have this:
Config:
'sourceLanguage' => 'en-EN',
'language' => 'ru-RU',
'components' => [
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
'sourceLanguage' => 'en-EN',
'fileMap' => [
'app' => 'app.php',
'app/error' => 'error.php',
],
],
],
],
]
./messages/
└── ru-RU
├── app.php
└── error.php
return [
'First Name' => 'Имя',
'Name' => 'Имя',
'Last Name' => 'Фамилия',
'Middle Name' => 'Отчество',
'Password' => 'Пароль',
'Title' => 'Заголовок',
'Tags ID' => 'Тэги',
'Content' => 'Содержание',
'Body' => 'Содержание',
'Save' => 'Сохранить',
'Send' => 'Отправить',
'Comment' => 'Комментарий'
];
<? $form = \yii\widgets\ActiveForm::begin(['id' => 'b-contacts__form']) ?>
<?= $form->field($model, 'name')->textInput()->label(Yii::t('app', 'Name')); ?>
<?= $form->field($model, 'email')->textInput(['type' => 'email'])->label(Yii::t('app', 'Email')); ?>
<?= $form->field($model, 'body')->textarea(['rows' => 5])->label(Yii::t('app', 'Content')); ?>
<?= \yii\helpers\Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-success pull-right']); ?>
<? \yii\widgets\ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question