jcasimir / locale_setter

A simple library to set request locale based on a hierarchy of factors
MIT License
118 stars 18 forks source link

Get locale from cookie? #3

Closed lagartoflojo closed 11 years ago

lagartoflojo commented 11 years ago

I prefer not polluting the URL with GET parameters, so I made LocaleSetter read the cookies if available. Setting the cookie is the application's job though, not LocaleSetter's.

https://github.com/familink/locale_setter/commit/9ba80c5407dbdd50935922a6ea7b32b381caba9b (This code fails the tests, because it gets rid of default_url_options.)

steveklabnik commented 11 years ago

The point of 'polluting the url' is that when it's shared with others, they get the same language.

lagartoflojo commented 11 years ago

I understand. I thought it's best if each user sees the page in their own preferred language. I think that's the common case in most web apps -- if I share with you a link to a tweet, you'll see the Twitter interface in your own language, not mine.

steveklabnik commented 11 years ago

This is one of the tensions between all these options. The point of giving things in the URL priority is that you can override this if you want to; it doesn't mean including the locale in the URL is always the correct thing to do.

lagartoflojo commented 11 years ago

Right, I agree with you in giving the URL params priority.

it doesn't mean including the locale in the URL is always the correct thing to do

That's precisely why I got rid of the code that automatically sets default_url_options for me; maybe that's a decision to be left to each developer...

steveklabnik commented 11 years ago

Okay! Nobody else has chimed in, so I'm leaving this behavior as-is. Thanks!