Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 translate validation attribute

How can i translate the attribute, now the output is: companyname is verplicht. (dutch)

Validation.php

'required'             => ':attribute is verplicht.',

Controller:

$rules = array(
    'companyname'       => 'required'
;

View:

{{ Form::text( 'companyname' , null, array( 'class' => 'form-control' ) ) ) }}
like image 523
Bas Avatar asked Feb 25 '16 14:02

Bas


People also ask

What is {{ __ }} In Laravel?

Laravel 5 Translation Using the Double Underscore (__) Helper Function. The __ helper function can be used to retrieve lines of text from language files.

What is @lang in Laravel?

Laravel-lang is a collection of over 68 language translations for Laravel by developer Fred Delrieu (caouecs), including authentication, pagination, passwords, and validation rules. This package also includes JSON files for many languages.

What is bail in Laravel validation?

The bail validation rule applies to a "multi-rule" attribute. It does not stop running validation for other attributes. From the documentation: $request->validate([ 'title' => 'bail|required|unique:posts|max:255', 'body' => 'required', ]);


1 Answers

You need to edit the app/resources/lang/your-language/validation.php and at the bottom you will see an attribute array.

Following your example just add:

'attributes' => [
'companyname' => 'Your Custom Name'
],

Hope this helps!

like image 79
Diego Vidal Avatar answered Sep 28 '22 00:09

Diego Vidal