Laravel use translator in a translation string

1.8k views Asked by At

Would it be possible to use trans() in a lang file?

Eg: the line is Please fill in your :attribute Let's say :attribute is password.

Would be possible to put password in the english lang file

and then use wachtwoord in the dutch lang file for :attribute?

1

There are 1 answers

2
Koen van den Heuvel On BEST ANSWER

You can use language specific attributes for this inside of your language validation file lang/nl/validation.php in the attributes array for example:

'attributes' => [
    'name' => 'naam'
    'password' => 'wachtwoord'
],

This will translate those attributes globably on all forms.

for a broader explanation check: Laravel validation attributes "nice names"