There is yet another poorly documented feature that can drive you crazy when using i18n on a system not set to English, and I suppose this issue is a good place to spread that, too:
As this ...
http://www.groovy-forum.de/read.php?3,2931,3636#msg-3636
... Geman message explains, when switching to a language without an according message_<cc>.properties file, like English
, grails usually falls back to the locale of the operation system environment, not to the language-less messages.properties file as one might expect.
This can be changed in grails-app/conf/Bootstrap.groovy by setting the bean messageSource's property fallbackToSystemLocale to false, like this:
def init = { servletContext ->
def appContext = ServletContextHolder.getServletContext().getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)
def messageSource = appContext.getBean("messageSource")
messageSource.fallbackToSystemLocale = false
}
To avoid just another trap: Do not forget the imports:
import org.codehaus.groovy.grails.web.context.ServletContextHolder
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
Forgetting imports in Bootstrap.groovy stops the app from a full start but and leaves process and TCP LISTENer alive, which makes the problem difficult to understand and solve especially when one is not used to "decrypt" java stacktraces in logfiles
)
It looks like the lang param works if a request is made to a controller but not otherwise. For example, if I surf to the root of my app which renders web-app/index.gsp, it doesn't look like it works there.