Create a new resource in Grails?

I would like to create another set of resources to organize my Grails application. Grails provides a "message" resource package, and I need to create a "myApp" resource package.

How to create a new resource package and read its properties using the GSP "g: message" tag?

+4
source share
3 answers

You need to create a bean in grails-app / conf / spring / resources.groovy, which will override the standard 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 configure Grails, the only advice I can give you is to familiarize yourself with the Spring framework (and, in particular, Spring-MVC) with the following links:

+9
source

Grails (starting with version 1.0.3) will automatically add all the properties files found in the grails-app/i18n directory to the resource package. No need to add them manually :)

+7
source

Starting with Grails 1.3.4, any property files added to the grails-app/i18n directory will be added to messageSource .

Also, if you try to manually add a bean (and base names under it) when you go into the production environment, it will not load them. It will work in development mode (tested when starting IDEA 9.0.3 and the tomcat v1.3.4 plugin), but not in production mode.

This happened to me after the answer provided by @rochb (I checked the answer and implemented it before the simplest way), and I had to remove the messageSource bean configuration in order to fix it.

+4
source

All Articles