Geoffroy, sessions are not restful by the definition of rest :)
Storing a locale in the session of a client means that state is stored on the clientside. The simple test for this aspect of rest probably is: if you can copy and paste the URL to an email, send it off to a buddy and be sure that your buddy will see the same page as you're looking at ... then that's ok. If he sees a different page, it's not. To me displaying a page in an entirely different language means that it's a "different" page, so I agree with Karel that we definitely should not advise peopel to use the session for this. Instead, use subdomains, parts of the path or even query params for that. Even though it's more work or might look ugly, it does not break the internet ;) As for the "more work" part, when it comes to locales as path segments: that's a question of better support in Rails. Raul already plugged his solution, so lemme add mine: <shameless-self-promotion> http://github.com/svenfuchs/routing-filter </shameless-self-promotion> On 05.10.2008, at 12:58, Geoffroy Gomet wrote: > > Hello Redd, > > Could you please explain how using the session to store the preferred > language is going against 'RESTfullnes'. > Someone copying and pasting an url would just see the page in the > default language, not really a problem there, except choosing the > right language. > If you advise to pass the language in the url everytime, I think it > would be against the clean url Rails produces. > > I think in the long time, you could find yourself with very cluttered > urls full of parameters, which would be a big step back. > > Geoffroy Gomet > > > On Oct 4, 1:20 pm, "Redd Vinylene" <[EMAIL PROTECTED]> wrote: >> On Fri, Oct 3, 2008 at 2:51 PM, Karel Minarik >> <[EMAIL PROTECTED]> wrote: >> >>> Hello Iain, >> >>> *please* don't advise people to use `session` for setting locale! >>> That >>> is an unfortunate choice by the official i18n demo app and >>> completely >>> breaks RESTfullnes of anything. (ie. completely breaks even such >>> simple thing like sending someone a URL and expecting that she'll >>> see >>> the same thing.) >> >>> One should set locale from params, hostname, accepted-language >>> header, >>> whatever, just *not* session. >> >> How? Like this? >> >> def set_locale >> I18n.locale = params[:locale] if params[:locale] >> end >> >> --http://www.home.no/reddvinylene > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "rails-i18n" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rails-i18n?hl=en -~----------~----~----~----~------~----~------~--~---
