|
This is a known issue, been like that for a while. The solution is to root your view through a controller like: "/"(controller:"foo") and def index = { render view:"/index" } Why is this a Won'f Fix? If there are no immediate plans to fix this, at least the i18n documentation should mention this feature, with a single sentence in the according chapter: To make it easier for the next Grails newby here are the details to get i18n working at /: 1. grails create-controller Home 2. in grails-app/conf/UrlMappings.groovy change ... 3. in grails-app/controllers/HomeController.groovy change the index method to ... 4. put locale changing links in grails-app/views/index.gsp or grails-app/views/layouts/main.gsp or whereever, like this: Hope this helps somebody ... 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 ... 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: 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 As far as using the messages.properties file. I simply copied it to messages_en.properties and then used ?lang=en |
|||||||||||||||||||||||||||||||||||||||||
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.