Laravel 6.9.0 validation.php 翻译的消息不显示,如果它们不以变量/属性开头 [英] Laravel 6.9.0 validation.php translated messages not showing if they do not start with a variable / property

查看:6
本文介绍了Laravel 6.9.0 validation.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 开头的翻译消息将正确显示,但如果它以西里尔文开头,则不会.这是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.

推荐答案

所以经过几天的摸索,发现当一个表单提交一个巨大的 textarea 内容时,比如像 2 段文本,表单输入被发送到 cookie,以便在验证失败时闪烁错误.但是由于textarea包含大量文本,验证失败,但是error flash也失败,静默,$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-fill-with-lots-of-text?

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

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

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

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