简体   繁体   中英

How can I get a localized message in a grails GSP tag attribute?

In a grails GSP, I want a toolTip to be localized:

<a href="..." title="localizedMessage">

As the toolTip is written in the attribute title, I can't use <g:message> here. Actually I already have a service for localized messages, but when I call it from the GSP, the service's messageSource is null, so getting that to work would be a solution as well.

You can invoke the tag directly:

<a href="..." title="${message(code:'your.localized.message.code')}">

I think this should work too:

<a href="..." title="${g.message(code:'your.localized.message.code')}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM