Laravel 更改验证语言
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31573655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel change validation language
提问by Jamie
How can I change the validator language messages. For example if I want to change the 'required' text 'The kilometerszakelijk field is required.' to something else?
如何更改验证器语言消息。例如,如果我想更改“必需”文本“需要kmszakelijk 字段”。到别的东西?
回答by jedrzej.kurylo
All language specific content is stored in your resources/lang//folder. One of the files you'll find in this folder is validation.phpthat holds validation messages for given language, so if you want to change the translations, you'll need to edit that file.
所有特定于语言的内容都存储在您的resources/lang//文件夹中。您将在此文件夹中找到的文件之一是validation.php,它保存给定语言的验证消息,因此如果您想更改翻译,您需要编辑该文件。
Depending on the language that is used by the application, messages will be read from different folders in resources/lang/. You can set language/locale using
根据应用程序使用的语言,将从resources/lang/ 中的不同文件夹读取消息。您可以使用设置语言/区域设置
App::setLocale('en');
You can also set fallback locale (that is used when there are no translations for current language) by setting it in your config/app.phpfile, e.g.:
您还可以通过在config/app.php文件中进行设置来设置回退区域设置(当当前语言没有翻译时使用),例如:
'fallback_locale' => 'en',
See more details in the docs: http://laravel.com/docs/5.0/localization
在文档中查看更多详细信息:http: //laravel.com/docs/5.0/localization
回答by baao
回答by ceejayoz
For the default messages, you can adjust the translations in resources/lang/<language>/validation.php
.
对于默认消息,您可以调整resources/lang/<language>/validation.php
.
You can also pass entirely custom messagesto the validator.
您还可以将完全自定义的消息传递给验证器。