字段信息和错误的i18n消息ID是什么? [英] What are the i18n message ids for field infos and errors?

查看:127
本文介绍了字段信息和错误的i18n消息ID是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为views.html.helpers._输入生成的标记转换默认约束和错误消息.我在文档中找不到它,并且已经开始浏览代码,但是如果有人比我快,请回答并获得奖励.

I'd like to translate the default constraints and error messages for markup generated by the views.html.helpers._ inputs. I couldn't find it in the documentation, and have already started browsing the code, but if anyone is faster than me please answer and be awarded.

这是示例模板代码:

@inputText(regForm("Login"), 'id-> "username", 'placeholder -> "Login", 'required -> "yes", 'autofocus -> "yes")

这是生成的HTML:

<div id="username_field" class="error clearfix">
<div class="input">

<input type="text" id="username" name="Login" value="" id="username" placeholder="Login" required="yes" autofocus="yes">

  <span class="help-inline">This field is required</span>
  <span class="help-block">Required</span>
</div>

我想翻译最后两个跨度中出现的文本.

I'd like to translate the texts appearing in the two last spans.

修改: 我已经从文档中 知道了翻译的工作方式.未说明的是针对未满足字段约束的显示消息(错误消息)和常规信息的默认消息ID.

I already know how the translation works from the documentation. What is not stated there are the default message IDs for the messages shown where a field constraint isn't fulfilled (the error messages) and for general info.

推荐答案

您必须覆盖

You have to override labels from the source messages file in your own messages.xy files.

还要查看其他答案前一段时间,如果默认语言的文件没有lang扩展名,就会出现问题. AFAIK,该问题已得到解决,但是如果您检查它并确认评论中的当前状态,那将是很酷的.

Also take a look at the other answer some time ago there was a problem if file for default language hasn't the lang extension. AFAIK it was fixed after that answer, however it would be cool if you'll check it and confirm the current state in the comment.

这篇关于字段信息和错误的i18n消息ID是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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