This article brings you relevant knowledge about Laravel, which mainly introduces how to display the error prompts of laravel's form validation in Chinese? For those who are interested, take a look below, I hope it will be helpful to you.
laravel form validation Chinese prompt
Requirements
Hope laravel framework form The verification error message is in Chinese, not English.
I currently use laravel 8.0, but this class library supports various versions of laravel, including the latest one.
Implementation:
1. Execute composer to install
composer require laravel-lang/common
(Included note: Official website address: laravel-lang.com / )
There is no need to bring a specific lang version number, just let composer automatically identify your current larave version number.
If you encounter an error, there are two options:
Try first
composer remove laravel-lang/publisher laravel-lang/lang laravel-lang/attributes laravel-lang/http-statuses
If it fails, try to delete the composer.lock file first, and then continue to execute the required require.
2. Publish language files
php artisan lang:add zh_CN
At this time, there will be an additional zh_CN folder under resources/lang in your framework directory.
3. Modify the configuration
config / app.php
'locale' => 'zh_CN', // 把 en 改成 zh_CN
Summary
It smells great!
Recommended learning: "laravel video tutorial"
The above is the detailed content of How to display the error message of laravel form validation in Chinese?. For more information, please follow other related articles on the PHP Chinese website!