laravel - 翻译“给定的数据无效。” 在 Laravel 5.6 中
问题描述
如何翻译“给定的数据无效”。到 Laravel 5.6?谢谢
解决方案
在中查找并替换该消息resources/lang/{lang_code}/validation
'exists' => 'The selected :attribute is invalid.',
在此处更改为您的语言而不是:attribute
或者
在文件的 render() 方法中添加以下行app\Exceptions\Handler.php
if ($exception instanceof ValidationException)
return response()->json(['message' => 'Your error message here', 'errors' => $exception->validator->getMessageBag()], 422); //type your error code.
编码愉快~!:)
推荐阅读
- recaptcha - 当新版本发布时,当前版本的 Google reCaptcha 是否可以使用?
- android - 在 Android Studio 中加载 GitHub 项目的过时版本
- amazon-web-services - AWS CloudFront 在欧盟与美国的 S3 表现不同(错误?)
- sql - 在 Postgresql 中以逗号分隔值提取子字符串
- java - 如何使用 WebFluxConfigurer 完全禁用 Swagger 3.0.0 的身份验证?
- centos - Google VM 实例升级后停止工作
- google-cloud-platform - 禁用 Cloud Build API 后,Google Cloud Platform 中的云功能构建失败
- checkstyle - 为什么 Checkstyle 不在 Maven 中心?
- jmeter - 如何让 Jmeter 每次登录只使用一次
- ringcentral - 如何满足 RingCentral 应用毕业过程中的“media/message-store”API 调用要求?