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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:00:50  来源:igfitidea点击:

Laravel change validation language

phplaravellaravel-5

提问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

Create a folder named like your language code in

创建一个文件夹,命名为您的语言代码

resources/lang

then create a file in this folder called validation.phpand in there, write something like

然后在这个文件夹中创建一个名为的文件validation.php,在那里写下类似的东西

return [

    'required'    => 'Das Feld :attribute ist ein Pflichtfeld.',

]

enter image description here

在此处输入图片说明

回答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.

您还可以将完全自定义的消息传递给验证器。

回答by Amir Kaftari

Laravel-lang

Laravel-lang

In this repository, you can find the lang files for the framework PHP, Laravel 4&5.

在此存储库中,您可以找到 PHP 框架 Laravel 4&5 的 lang 文件。

you can see herefor use that.

你可以在这里看到使用它。