如何使流明使用默认验证消息?

nan*_*eri 1 lumen

我在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"
}
Run Code Online (Sandbox Code Playgroud)

kri*_*lfa 6

基本上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'),
Run Code Online (Sandbox Code Playgroud)