dre
dre

Reputation: 1037

Grails: Change contents of message.properties (i18n) in production

Is is possible to modify text in message.properties when in production without a redeploy/restart.

Upvotes: 3

Views: 1691

Answers (2)

Dónal
Dónal

Reputation: 187529

This is not possible if you use the default messageSource bean. If you want to do this, one option is to store the messages in the database rather than properties files. Here are a couple of plugins that support this (I've never used either of them myself)

Alternatively, replace the default messageSource bean with one that supports reloading, e.g. ReloadableResourceBundleMessageSource.

Upvotes: 2

Joshua Moore
Joshua Moore

Reputation: 24776

It's quite possible, but you need to replace the default messageSource bean with a ReloadableResourceBundleMessageSource. You can do this by configuring a new messageSource bean definition in your grails-app/conf/spring/resources.groovy as follows:

beans = {
      messageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) {
        basenames = ["classpath:grails-app/i18n/myApp", "file:grails-app/i18n/messages", "WEB-INF/grails-app/i18n/messages"]
    }
}

The above will work in both development and production. You may also want to research other options available to you using the ReloadableResourceBundleMessageSource.

Upvotes: 3

Related Questions