简体   繁体   English

如何在grails GSP标记属性中获取本地化消息?

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

In a grails GSP, I want a toolTip to be localized: 在Grails GSP中,我想要一个toolTip本地化:

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

As the toolTip is written in the attribute title, I can't use <g:message> here. 由于toolTip是在属性标题中写的,所以我不能在这里使用<g:message> 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. 实际上我已经有了本地化消息的服务,但是当我从GSP调用它时,服务的messageSource为null,所以让它工作也是一个解决方案。

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')}">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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