【发布时间】:2019-01-04 19:13:30
【问题描述】:
在我的 Grails 2.4.4 应用程序中,我使用 messages.properties 进行国际化,具有以下值:
my.app.thing.allowance(s)={0} Allowance(s)
它正在像这样的 gsp 中使用:
<g:message code="my.app.thing.allowance(s)" args="${item.allowances.size()}"/>
对于任何大于 0 的值,消息都会正确显示,例如如果 item.allowances.size() == 4,则显示的消息是 4 Allowances(s)
问题是如果item.allowances.size() == 0 则显示的消息是{0} Allowance(s)
我尝试了几种不同的方式来编写参数,例如:
<g:message code="my.app.thing.allowance(s)" args="${item.allowances.isEmpty() ? 0.intValue() : item.allowances.size()}"/>
我已经调试了一些东西,我确信 item.allowances.size() == 0 但由于某种原因它无法正确处理 0 的值。将 int 值为 0 的参数传递给 messages.properties 的正确方法是什么?
【问题讨论】: