Re: Change i18n locale from a controller before calling the view
Hello guys,
I found the answer myself.
I want to post it here in case someone else has the same need in the future.
The controller code would look like this:
import org.springframework.web.servlet.support.RequestContextUtils as RCU
class myController {
def index = {
'Let's change the Locale to, let's say... 'es_ES'
def newLocale = new Locale('es', 'ES')
RCU.getLocaleResolver(request).setLocale(request, response, newLocale)
'DONE! Now when the view is rendered, it'll be done using the new locale
}
}