Search code examples
grailsinternationalizationgsp

Passing an i18n message as a parameter to a Grails template


I have a Grails template file that i use in multiple .gsp views, being called like this:

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

However, I'd like to move A string and Another string to a messages.properties file.

How can I set the template model values to the proper values, given that I cannot use <g:message> inside the <g:render> tag?


Solution

  • The following works for me:

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