会议/消息选择在游戏中!+ 斯卡拉



我在play 2.2 "comuputer-database-jpa"中运行示例代码

Conf/Messages

# Messages
computers.list.title={0,choice,0#No computers|1#One computer|1<{0,number,integer} computers} found

我想在错误消息中使用此条件消息,以使我的错误消息尽可能动态。在我的代码中,假设我正在传递 2 个参数,其中 1 个是消息 ID。

@Messages(messageId,errors(1).getOrElse(""),errors(2).getOrElse(""))

相当于

@Messages(error.format,FIRST NAME)

也可以

@Messages(error.format,EMAIL)

如何在代码中使用条件 conf/messages? 我使用示例尝试了一些,但发生了错误。法典:

error.format = Enter {0,choice,FIRST NAME#{0} in half-width alphanumeric|EMAIL#{0} in valid format.}

我做错了什么?

下面的代码将产生你要找的东西

//html<br/>
@Messages("error.format",2, "name error","email error")

上面示例中的数字 2 将显示消息"有效格式的电子邮件"。 如果将其更改为 1,它将显示消息"半角字母数字中的名字"

//messages<br/>
error.format = Enter {0,choice,1#FIRST NAME in half-width alphanumeric|2#EMAIL in valid format.}

相关内容

最新更新