Answer the question
In order to leave comments, you need to log in
[[+content_image]]
Where can I translate the existing feedback form to YII2?
I tried it in the ContactForm.php model, but only the captcha was translated.
public function rules()
{
return [
// name, email, subject and body are required
[['вываываы', 'email', 'subject', 'body'], 'required'],
// email has to be a valid email address
['email', 'email'],
// verifyCode needs to be entered correctly
['verifyCode', 'captcha'],
];
}
//'Имя:', 'Email:', 'Тема:', 'Сообщение:'
/**
* @return array customized attribute labels
*/
public function attributeLabels()
{
return [
'verifyCode' => 'Подтвердите что вы не робот:',
];
}
Answer the question
In order to leave comments, you need to log in
1. in the config, set the language parameter to ru-RU
return [
..............
'language'=>'ru-RU',
........ .........
];
2. add name label for fields name, email, subject, body
public function attributeLabels()
{
return [
'verifyCode' => 'Verify that you are not a robot:',
'name' => 'Name',
'subject' => 'Theme'
...............................................
];
}
3. in the views/site/contact.php template we do text translation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question