Grails how to change the current locale

Viewed 25966

How can I change the current locale ?

  • I tried to put controller/action?lang=de but my locale is still en_US
  • I tried to override the value using this piece of code:

    def key = "org.springframework.web.servlet.DispatcherServlet.LOCALE_RESOLVER"
    def localeResolver = request.getAttribute(key)
    localeResolver.setLocale(request, response, new Locale("de","DE"))
    

Nothing changed.

  • I tried to override the value using this piece of code:

    import org.springframework.web.servlet.support.RequestContextUtils as RCU;
    RCU.getLocaleResolver(request).setLocale(request, response, new Locale("de","DE"))
    

And... nothing happened. i still got my locale set to en_US.

Any idea to change the locale ?

6 Answers
Related