在Grails中创建一个新的资源包? [英] Create a new resource bundle in Grails?

查看:122
本文介绍了在Grails中创建一个新的资源包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建另一个资源包来组织我的Grails应用程序。 Grails提供了一个'messages'资源包,我需要创建一个'myApp'资源包。



如何创建一个新的资源包并使用' g:message'GSP tag?

解决方案

您必须在 grails-app / conf / spring / resources.groovy ,它将覆盖默认的MessageSource。

  //将您的Spring DSL代码放在这里
beans = {
messageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource){
asename =classpath:grails-app / i18n / myApp
}
}

注意:
如果您需要自定义Grails,我可以给你的唯一建议是熟悉与Spring框架(特别是Spring-MVC)和以下链接: .ORG /弹簧/文档/ 2.5.X /参考/ beans.html#上下文功能-messagesourc erel =noreferrer>在Spring中定制消息源 在Grails中配置Bean

I'd like to create another resource bundle to organize my Grails app. Grails provides a 'messages' resource bundle and I need to create a 'myApp' resource bundle.

How can I create a new resource bundle and read its properties with the 'g:message' GSP tag?

解决方案

You have to create a bean in grails-app/conf/spring/resources.groovy which will override the default MessageSource.

// Place your Spring DSL code here
beans = {
      messageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) {
        basename = "classpath:grails-app/i18n/myApp"
    }
}

Note: If you need to customize Grails, the only advise I can give you is to get familiar with the Spring framework (and specifically Spring-MVC) with the following links:

这篇关于在Grails中创建一个新的资源包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆