简体   繁体   English

Laravel 5.2登录消息自定义

[英]Laravel 5.2 login message custom

I am kind of new to Laravel framework, working on 5.2. 对于5.2来说,我是Laravel框架的新手。 I run 我跑

php artisan make:auth()

Now I am trying to custom the error message on the login form "these credentials do not match our records" 现在,我尝试在登录表单上自定义错误消息“这些凭据与我们的记录不匹配”

I tried to override the failLoginMessage() method in AuthController.php but it's not working. 我试图覆盖AuthController.php中的failLoginMessage()方法,但是它不起作用。 One more thing the password field error message is not working at all even though I enter the right email but wrong password the validation runs on email field but not on password field. 还有一件事,即使我输入正确的电子邮件,但密码字段错误消息根本不起作用,但密码验证错误却在电子邮件字段上运行,而不是在密码字段上运行。

As I can't see your code, check this out: https://github.com/laravel/laravel/blob/5.2/resources/lang/en/auth.php , this is on branch 5.2 in Github, that is the lang file, you can define a new folder inside of lang directory named es and make inside it an auth.php , if you feel good and warm in terminal cd <your_proy_dir> && mkdir -p resources/lang/es/ && touch resources/lang/es/auth.php , and define a fundamentals key inside that file: 由于看不到您的代码,请查看以下代码: https : //github.com/laravel/laravel/blob/5.2/resources/lang/zh-cn/auth.php ,它位于Github的5.2分支上,即lang文件,如果您在终端cd <your_proy_dir> && mkdir -p resources/lang/es/ && touch resources/lang/es/auth.php感觉良好,则可以在lang目录中定义一个名为es的新文件夹,并在其中创建auth.phpcd <your_proy_dir> && mkdir -p resources/lang/es/ && touch resources/lang/es/auth.php ,并在该文件内定义一个基本密钥:

'failed' => 'Estos credenciales no coinciden con ninguno almacenado.',

That would be for spanish, but is the same principle for every language, then, to change your application language, you just have to go to the config/app.php and change this: 那将是西班牙语,但是每种语言都具有相同的原理,然后,要更改您的应用程序语言,您只需转到config/app.php并进行以下更改:

 'locale' => 'en',

for this: 为了这:

 'locale' => 'es',

Once again, this is for spanish, but is the same principle. 再一次,这是西班牙语,但原理相同。

Good luck. 祝好运。 Cheers! 干杯! ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM