gpt4 book ai didi

lumen - 如何让 Lumen 使用默认验证消息?

转载 作者:行者123 更新时间:2023-12-03 23:14:03 26 4
gpt4 key购买 nike

我在 Lumen 中有一个类似于 Laravel 的错误消息标准文件夹。问题是没有使用来自那里的消息。如何让 Lumen 使用我的翻译来格式化消息?

现在,当我转储 $validator->errors() 时,它不会格式化消息。

MessageBag {#223
#messages: array:4 [
"surname" => array:1 [
0 => "validation.required"
]
"mobile" => array:1 [
0 => "validation.required"
]
"password" => array:1 [
0 => "validation.min.string"
]
"email" => array:1 [
0 => "validation.email"
]
]
#format: ":message"
}

最佳答案

基本上translator缺少应该在此实例解析之前配置的语言环境配置。将此添加到您的:config/app.php

/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => env('APP_LOCALE', 'en'),

关于lumen - 如何让 Lumen 使用默认验证消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44197608/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com