Reputation: 1455
I have an internazionalised application with language selection, based on Grails and the kickstarter plugin. As per the configuration in its UrlMappings, there are some pages without controller. On these, only the default locale is applied no matter what a user has actually selected. Further, on them changing the language does not work. g:message tags output with the default locale; I tried
<g:set var="locale"
value="${session.'org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE' ?: org.springframework.web.servlet.support.RequestContextUtils.getLocale(request)}"/>
(forgot where I found that) .. but following that nothing changes.
Upvotes: 0
Views: 3336
Reputation: 1455
Apparently this is a bug in grails versions prior to 2.4.4
I worked around it by retrieving the locale at the top of the gsp in question like so:
<g:set var="lang" value="${session.'org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'}"/>
(from this blog post) and then adding the locale to the messages I want to appear translated in the page, using a solution by @ SergeiShushkevich like so:
<g:message code="text.label" locale="${lang}"/>
${message([code:'text.label', locale:lang])}
Upvotes: 1