[[+content_image]]
A
A
Alexander Ivanov2015-06-10 17:42:01
Yii
Alexander Ivanov, 2015-06-10 17:42:01

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' => 'Подтвердите что вы не робот:',
        ];
    }

Maybe you need to set the values ​​as in the captcha 'verifyCode' => 'Verify that you are not a robot:' ?
If yes, please provide an example.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
V
vyachin, 2015-06-11
@cimonlebedev

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 question

Ask a Question

731 491 924 answers to any question