Where I find the declaration of messageSource?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Where I find the declaration of messageSource?

sergiomichels
This post was updated on .
Background: we have some legacy internationalization for field labels that
are stored in the database, so I tried to make a "merged" messageSource. If
the code exists in database, return, if not,
use PluginAwareResourceBundleMessageSource to look in the i18n.

Problem: for some reason the cachedMergedPluginProperties is caching the
wrong file for the locale. For example, if I search for en_US, I receive
pt_BR messages (the key of the Map is en_US, but the properties are pt_BR).

I declared my messageSource as follows:

messageSource(DatabaseMessageSource) {
  messageBundleMessageSource = {
org.codehaus.groovy.grails.context.support.PluginAwareResourceBundleMessageSource
m ->
  basenames = "WEB-INF/grails-app/i18n/messages"
}
    }

The inner bean is beacause of Grails won't let me have two beans of type
MessageSource.

Am I declaring PluginAwareResourceBundleMessageSource different from the
default of Grails? In which file of Grails I can see this bean declaration?

--
Sérgio Michels
Reply | Threaded
Open this post in threaded view
|

Re: Where I find the declaration of messageSource?

sergiomichels
This post was updated on .
Found it! It's in the I18nGrailsPlugin, and the declaration is
different. Unfortunately I had to copy the code since Grails don't let you
have two beans of type MessageSource.

--
Sérgio Michels



On Wed, Nov 21, 2012 at 2:34 PM, Sergio Michels <sergiomichelss@gmail.com>wrote:

> Background: we have some legacy internationalization for field labels that
> are stored in the database, so I tried to make a "merged" messageSource. If
> the code exists in database, return, if not,
> use PluginAwareResourceBundleMessageSource to look in the i18n.
>
> Problem: for some reason the cachedMergedPluginProperties is caching the
> wrong file for the locale. For example, if I search for en_US, I receive
> pt_BR messages (the key of the Map is en_US, but the properties are pt_BR).
>
> I declared my messageSource as follows:
>
> messageSource(DatabaseMessageSource) {
>   messageBundleMessageSource = {
> org.codehaus.groovy.grails.context.support.PluginAwareResourceBundleMessageSource
> m ->
>   basenames = "WEB-INF/grails-app/i18n/messages"
> }
>     }
>
> The inner bean is beacause of Grails won't let me have two beans of type
> MessageSource.
>
> Am I declaring PluginAwareResourceBundleMessageSource different from the
> default of Grails? In which file of Grails I can see this bean declaration?
>
> --
> Sérgio Michels
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Where I find the declaration of messageSource?

Lari Hotari -
This is a Grails performance issue:
"Performance problems in PluginAwareResourceBundleMessageSource in development mode or when GSP reloading is enabled and grails.i18n.cache.seconds default or > 0"
http://jira.grails.org/browse/GRAILS-10852

Lari