grails i18n错误定制:各种不一致 [英] grails i18n error customization: various inconsistencies

查看:84
本文介绍了grails i18n错误定制:各种不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,在message.properties中,空白字段的默认i18n消息为:

As an example, the default i18n message in message.properties for blank fields is:

default.blank.message=Property [{0}] of class [{1}] cannot be blank

如果要使用给定的类(例如,用户)和字段(例如,登录名)自定义此内容,

If one wants to customize this with a given class (e.g. user) and field (e.g. login), one does

user.login.blank=Your login name must be specified

,后缀为".message".这让我有点失望(因为我在那里放了它,但是它没有用),所以我想知道在"message"后缀中如何使用/不使用".message"后缀是否有特定的目的. ?

with the ".message" suffix left-off. This threw me off for a bit (as I had it in there and it didn't work), so I'm wondering if there is a specific purpose to how the ".message" suffix is used / not used in message.properties?

推荐答案

消息定制的使用似乎存在很多不匹配的地方,而不仅仅是".message"的使用.请参阅下面的示例*.

There seem to be quite a bit of mismatches in the use of message customization, beyond just the use of ".message". See example below*.

我相信grails软件开发人员可能会在message.properties文件的顶部添加注释,以指导用户在正确的位置定义自定义错误消息,例如在约束"快速参考列表中, http://www.grails.org/doc/latest/ref/Constraints/matches.html .快速参考中的顶级约束"部分不包含错误代码字段名称,但在此添加可能会很有用.

I believe the grails software developers might include a comment at the top of the message.properties file, guiding the user to look at the right place for defining the custom error messages, e.g. in the Constraints quick reference list, http://www.grails.org/doc/latest/ref/Constraints/matches.html. The top level Contraints section in the quick reference does not include the error code field names, but might it be useful to add there.

*例如,默认的匹配失败是"default.doesnt.match.message",但是特定的错误是例如"user.login.matches.invalid".

*For example, the default match failure is "default.doesnt.match.message", but the specific error is, for example, "user.login.matches.invalid".

这篇关于grails i18n错误定制:各种不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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