Laravel 6.9.0validation.php转换后的消息是否不以变量/属性开头而不显示 [英] Laravel 6.9.0 validation.php translated messages not showing if they do not start with a variable / property

查看:44
本文介绍了Laravel 6.9.0validation.php转换后的消息是否不以变量/属性开头而不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我手动翻译了/en/语言环境的validation.php文件中的错误消息,因为该站点快要完成了,而且我认为由于它只需要一种语言(而不是英语),所以不值得将所有内容重构为一个新的相反,只需翻译EN即可.

So I translated by hand the error messages in the validation.php file for the /en/ locale since the site is almost finished and I figured since it needs only one language (not English) it's not worth refactoring everything to a new locale, instead, just translate the EN one.

但是,我当前面临的问题是,以:attribute或任何其他:variable开头的翻译后的消息将正确显示,但是如果以Cyrillic开头则不会.这是来自validation.php的示例-

But, I am currently facing the issue where a translated message, which starts with :attribute or any other :variable will get displayed properly, but if it starts with Cyrillic it does not. Here is an example from the validation.php -

'accepted' => 'Трябва да приемете :attribute.', // DOES NOT WORK
'confirmed' => ':attribute не съвпада със стойността за потвърждение.', // WORKS

如果一条消息不起作用,我所要做的就是将:attribute或可能被称为的任何内容放在字符串的开头,并且现在可以正常工作...

If a message isn't working, all I have to do is put the :attribute or whatever it might be called called, at the beginning of the string and it works now...

这真的很奇怪,我不确定这是否与/en/lang文件夹下或其他内容有关.我已经尝试了几个小时的解决方案,但找不到与我的案子有关的任何内容,因此希望在这里寻求帮助.

This is really weird and I am not sure if it has anything to do with the fact that this is under the /en/ lang folder or something else. I tried to find a solution for a couple of hours now but I cant find anything related to my case so I am hoping for some help here.

推荐答案

因此,经过数天的挖掘,事实证明,当表单提交大量文本区域内容(例如两段文本)时,将发送表单输入到Cookie,以便在验证失败时刷新错误.但是由于textarea包含很多文本,因此验证失败,但错误提示信息也同样失败,无提示,并且$ errors为空.

So after days of digging around, it turns out that when a form submits a huge textarea content, such as like 2 paragraphs of text, the form input is sent to a cookie in order to flash the errors when the validation fails. But since the textarea contains a lot of text, the validation fails, but the error flash also fails, silently,and $errors is left empty.

https://laracasts.com/index.php/discuss/channels/general-discussion/laravel-5-not-showing-validation-errors-when-textarea-is充满文本?

一种可能的解决方案是使用FILE作为session.php中的会话驱动程序,如上面所链接的问题所述.

A possible solution is to use FILE for the session driver in session.php, as mentioned in the issue linked above.

这篇关于Laravel 6.9.0validation.php转换后的消息是否不以变量/属性开头而不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆