0

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'

cedric
  • 223
  • 5
  • 12
  • I tried downgrading i18n to version 0.6.4, but it actually makes things worse, since the application doesn't want to start at all, as I get a "undefined method `enforce_available_locales=' for I18n:Module (NoMethodError)" error message. – cedric Feb 18 '16 at 17:58
  • It's hilarious, because I upgraded i18n back to version 0.7.0, because I prefer my app to work in one single language rather than not at all, and guess what : it now works! Go figure! I also realized that the application.rb parameters : default_local, available_locales and enforce_available_locales are completely useless in my case. I'm still not entirely satisfied with the result, since I cannot currently predict what happens if a client uses a language for which there is no locale in my app. Sometimes it chooses :en, sometimes :de. I would prefer to default to :de, in this case. – cedric Feb 18 '16 at 18:12

1 Answers1

0

Downgrading i18n version to 0.6.4 and upgrading it again to 0.7.0 did the trick. I have no idea why.

I'm still not entirely satisfied with the result, though, since I cannot currently predict what happens if a client uses a language for which there is no locale in my app. Sometimes it picks :en, sometimes :de. I would prefer to be able to control the default language.

cedric
  • 223
  • 5
  • 12