Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

user_preferred_languages does not work as expected #2

runar opened this Issue Jun 11, 2010 · 4 comments


None yet
4 participants

runar commented Jun 11, 2010


According to the comments for user_preferred_languages in http_accept_language.rb, this function should ignore regions and return languages compatible with available locales.

It is my understanding that if the user requests en-US while only en is available, en will be used instead of nothing.

Here are my results, tested in several browsers with one and multiple languages:

# => ["en-US"]

# => [:en, :no, :de]

# => nil

Have I misunderstood something?


tomhughes commented Jun 11, 2010

That isn't how RFC 2616 says language selection should work. Section 14.4 describes the algorithm and says that the requested language must either exactly match the available language or must exactly match a prefix of the available language.

So you can use a more specific language than the user asked for, but not a less specific language.

Most browsers automatically add the more generic version though - so if you configure your browser to send "en-US" it will probably add "en" as a second choice.

runar commented Jun 11, 2010

Thank you! Now I understand why it's done this way.

Thou, I have not been able to make my browsers (Safari and Firefox, Google Chrome wouldn't even let me change the languages) automatically send a more generic version of a language.

But I guess it'll do.

pencil commented Mar 19, 2013

Same problem on my iPhone... It sends just de-de and no less specific version. There is no way to configure this.

@DouweM DouweM closed this Sep 6, 2013


DouweM commented Sep 6, 2013

See the discussion at #6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment