如何让 Lumen 使用默认验证消息?
How do I make Lumen to use default validation messages?
我在 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 中有一个标准的错误消息文件夹,类似于 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'),