« Return to Thread: When exactly is the locale changed when using the lang parameter?

When exactly is the locale changed when using the lang parameter?

by Jean-Noël Rivasseau-3 :: Rate this Message:

Reply to Author | View in Thread

Hello, on my web-application I would like to setup a custom URL
mapping that contains the locale to be used in the URL. Eg,
www.example.com/en/, www.example.com/fr for French, etc.

That way the URL contains the locale information which is nice for
bookmarking etc.

I made up the following URL mapping:

          "/$lang?/about"
                          {
               
                  controller= "main"
                  constraints
                        {
                                lang(matches:/[a-z]{2}/)
                        }
                  action = "about"
               
         }

Unfortunately, it is not working, the locale is not changed (on
www.example.com/fr/about/ ). If I manually specify the ?lang parameter
at the end of the URL it works though. This had led me to believe that
the "locale switching", based on the lang parameter, is maybe ran
before the URL mapping, or it does not use the lang parameter as set
by the URL mapping code in params.

How should I proceed then to achieve what I want? In a Filter maybe?

On a sidenote, the Grails guide says that forcing the locale via the
lang parameter sets up a cookie that remembers the choice. I sniffed
requests with Firebug and found no trace of such a cookie, so I guess
it is stored within the session? Can someone confirm?

As I will be essentially forcing the lang parameter every time with my
approach, I hope that the locale switching code is not heavy - does
someone know about this?

Thanks

Jean-Noel

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: When exactly is the locale changed when using the lang parameter?

LightInTheBox - Buy quality products at wholesale price