Home> PHP Framework> Laravel> body text

How to display the error message of laravel form validation in Chinese?

藏色散人
Release: 2023-03-16 15:41:37
forward
1232 people have browsed it

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.

How to display the error message of laravel form validation in Chinese?

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
Copy after login

(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
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!