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

时间:2017-12-27 16:02:42

标签: grails internationalization gsp

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

A string

但是,我想将Another string<g:message>移至messages.properties文件。

如果我无法在<g:render>标记内使用package remoting.programatic.demo import akka.actor.{ActorSystem, Props} import com.typesafe.config.ConfigFactory import remoting.config.demo.RemoteActor object RemoteActorApp extends App { val system = ActorSystem("RemoteNodeApp", ConfigFactory.load().getConfig("RemoteProgrammatically")) val remoteActor = system.actorOf(Props[RemoteActor], name = "remoteActorAddr") remoteActor ! "Hello!" val actorSelection = system.actorSelection("akka.tcp://RemoteNodeApp@localhost:2553/user/remoteActorAddr") Thread.sleep(4000L) actorSelection ! "Hello!" } ,如何将模板模型值设置为正确的值?

1 个答案:

答案 0 :(得分:1)

以下适用于我:

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