jeudi 18 février 2016

unable to get the locale from client after Rails & Ruby update

formerly, I used Rails 3.2.13 with Ruby 2.0.0 and this worked fine :

In my application.rb, I had:

    def set_locale
    I18n.locale = http_accept_language.compatible_language_from([:en, :de])
end

I use 2 locales, de.yml and en.yml

Now that I upgraded to Rails 3.2.22 and Ruby 2.2.4, I was forced to also upgrade gem i18n to version 0.7.0, and I get the error message "I18n::InvalidLocale (:en is not a valid locale)" if I choose a client in 'en' or another language. 'de' works.

I tried various combinations of parameters in application.rb

config.i18n.enforce_available_locales = true
config.i18n.available_locales = ["en", "de"]
config.i18n.default_locale = :'de'

but to no avail... If I use a client in 'de', it works, but if I use a client in 'en' or another language, I get the above error message. Formerly, if I chose another client language, it would default to 'de'

Aucun commentaire:

Enregistrer un commentaire