views:

200

answers:

2

Hi, I am starting with Grails and want to have one page with multilanguage content.

I started using the tag which works fine. But here is what I want to do:

I want to include the default text of the default language right in the text, to avoid switching back and forth in between files.

<g:message code="homepage.feature.headline1" default="This is an english text" />

The above works.

But now I a have a message which should include a link like this:

<g:message code="homepage.feature.headline1" default="This is an english text with <a href='somefile.html'>a link</a>" />

This gives me an exception:

org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Grails tags were not closed! [[<g:message>]] in GSP 

How can I achieve that I can include a link there? I have tried escaping the <> brackets but still no luck. I really would like to avoid splitting up this one sentence into multiple smaller sentences.

Thanks Christoph

+2  A: 

You have two possible ways:

<g:message code="homepage.feature.headline1" default="This is an english text with ${'<a href=\'somefile.html\'>a link</a>'}" />

or

<% def link = "<a href='somefile.html'>a link</a>"%>
<g:message code="homepage.feature.headline1" default="This is an english text with $link" />
fabien7474
Thanks Fabien. I go with Option1. The advantage is, that the template developer can already see the default text without looking into the message.properties. Option2 is good as well but too much code for this purpose.ThanksChristoph
Christoph
A: 
Marcello de Sales