[[+content_image]]
A
A
alex4answ2019-04-17 18:58:12
Yii
alex4answ, 2019-04-17 18:58:12

How to translate the validation error message?

Good afternoon, I'm trying to Russify the validation error message:

Модель:
    public function rules()
    {
        return [
            ...
            [['username', 'email'], 'unique', 'message' => Yii::t('app/error', 'User with {value} already exists')],

Displays, substitutes the value.
I add to messages/ru-RU/error.php:
'User with {value} already exists' => 'Пользователь с {value} уже существует.',

It doesn’t translate, in general the translation works on the site, but with the substitution of variables, the trouble is, I’m sure that I look in the book I see a fig, but I can’t find the reason (
Please tell me please

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim Timofeev, 2019-04-17
@alex4answ

Checked. Everything is working. Most likely the matter is in https://www.yiiframework.com/doc/api/2.0/yii-i18n-...
specify in the config

'sourceLanguage' => 'en',
'forceTranslation' => true,

Apparently you the key deduces.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question