将 i18n 消息作为参数传递给 Grails 模板

Passing an i18n message as a parameter to a Grails template

我有一个在多个 .gsp 视图中使用的 Grails 模板文件,被这样调用:

<g:render template="/template/mail/notification/notification_email" model="[
    title: 'A string',
    text: 'Another string',
]"/>

但是,我想将 A stringAnother string 移动到 messages.properties 文件。

鉴于我无法在 <g:render> 标签内使用 <g:message>,我如何将模板模型值设置为正确的值?

以下对我有用:

<g:render template="/template/mail/notification/notification_email" model="[
    title: g.message( code: 'your.title' ),
    text: g.message( code: 'your.text' ),
]"/>