Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a new resource bundle in Grails?

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?

like image 714
Benoit Wickramarachi Avatar asked Nov 29 '22 06:11

Benoit Wickramarachi


2 Answers

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:

  • Customize Message source within Spring
  • Configure beans within Grails
like image 156
rochb Avatar answered Dec 01 '22 20:12

rochb


Grails (as of version 1.0.3) will add all property files found in the grails-app/i18n directory to the resource bundle automatically. No need to add them manually :)

like image 43
lunohodov Avatar answered Dec 01 '22 20:12

lunohodov