jcasimir / locale_setter

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

Does not work when available locale names are in upper case #1

Closed lagartoflojo closed 11 years ago

lagartoflojo commented 11 years ago

It's common to have locale names with upper case letters. For example, in Rails you might have an en-US.yml file. LocaleSetter downcases the requested locales and assumes that available locales are also in lower case. I've fixed this by generating a hash as a lookup table where the key is the locale name in lower case, and the value is the original locale name. I don't like it very much, because it generates the loopup table every time, but it works.

Here's the commit, test included: https://github.com/familink/locale_setter/commit/23785d25b6ed2013eec74b8327a70761bb254088

steveklabnik commented 11 years ago

Locales are case insensitive, downcasing them all is the Right Thing To Do.

lagartoflojo commented 11 years ago

Ok, but as the gem works right now, when a user requests the locale "es-CL", and I have an "es-CL.yml" file in my app, it does not pick it up, and instead falls back to default_locale.

steveklabnik commented 11 years ago

I've pulled your fix in, that's totally correct. Thanks!