php_learn
php_learn

Reputation: 23

why doesn't change message error validation laravel

hi guys i have a problem in change message error in validation i wanna change it to french but i don't know how can i do it this my code :

public function rules() {
    return [
        'name' => ['required', 'string'],
        'group_id' => 'nullable|integer|exists:groups,id',
    ];
}


public function attributes() {
    return [
        'name' => 'nom',
        'group_id'  => "ID de group"
    ];
}

but in response show me "group id " Not "ID de group"

Upvotes: 0

Views: 79

Answers (1)

NoOorZ24
NoOorZ24

Reputation: 3222

Is rest of the text translated?

If so then I think what you need is to specify name of translations file:

public function attributes()
{
    return [
        'name' => '[FILE_NAME].name',
        'group_id'  => '[FILE_NAME].group_id'
    ];
}

and in your resources / lang / fr / [FILE_NAME].php you need:

<?php

return [
    // Other translations
    'name' => 'nom',
    'group_id'  => 'ID de group',
    // Other translations
];

Upvotes: 1

Related Questions