Reputation: 325
I searched a lot before asking this question but found nothing to help me.
I started using Laravel as a PHP framework. As I started to do form validation, I used the Validator
class to manage all my validation and error messages. But I'd like to know how I can customize the error messages (I'd like to put them in another language for example).
Upvotes: 8
Views: 9196
Reputation: 29241
The documentation says:
Language strings are stored in files within the
resources/lang
directory. Within this directory there should be a subdirectory for each language supported by the application.
Just create a directory with the supported language code, and add a validation.php
file (it is wise to just copy the one provided in English then start translating).
An example for Spanish translation would be created at resources/lang/es/validation.php
. And it will look as follow:
<?php
return array(
"required" => "El campo :attribute es requerido.",
);
After that, you will need to change the default language.
The default language for your application is stored in the
app/config/app.php
configuration file. You may change the active language at any time using theApp::setLocale
method.
Example of changing the default language at runtime:
App::setLocale('es');
Upvotes: 12
Reputation: 567
in laravel 5 the validation.php file comes under the folder resources.
resources/lang/en/validation.php
Upvotes: 5