Ad

Laravel Get Translated Validation Errors

- 1 answer

I use Laravel 5.1, I want to return translated validation error in this request class. Please any help how to return translated data.

class ContactRequest extends Request
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'name' => 'required',
            'g-recaptcha-response' => 'required|captcha',
            'email' => 'required|email',
            'message' => 'required',
            'phone' => 'required'
        ];
    }
}
Ad

Answer

First install this package : laravel langs (Copy languages folders you wish integrate into resources/lang)

Change locale variable in config/app to 'ru' for example, and that's all :)

Ad
source: stackoverflow.com
Ad