-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I18n::InvalidLocale (:en is not a valid locale): #549
Comments
I guess GJ should use The language switch was added to ensure consistent UI, vide #407 |
Interesting! Maybe |
I think this has been fixed via #497 and released in |
I get the same error
I might be doing something wrong, but my
adding I could have some time to try fix this on the weekend if you like? |
Are you setting a default_locale? I think I assumed that there would be a default locale. I guess maybe in the absence of a default locale it should default to the first of available_locales. Does that seem right? |
I don't think I am setting a In my case - yes the first locale in I didn't actually code the locale specific stuff in my app - not that experienced with it. - but am digging into it now. |
From my poking at it, here's what I think is happening: If the application doesn't set a GoodJob is using original_locale = I18n.locale #=> :en, which is not in available_locales
I18n.locale = tmp_locale
block.call
I18n.locale = original_locale #=> raises I18n::InvalidLocale because :en is not an available locale You can see that happening here: [1] pry(main)> I18n.default_locale
=> :en
[2] pry(main)> I18n.locale
=> :en
[3] pry(main)> I18n.available_locales
=> [:nl, :fr]
[4] pry(main)> I18n.with_locale(:fr) { puts "current locale is #{I18n.locale}" }
current locale is fr
I18n::InvalidLocale: :en is not a valid locale
from /Users/bensheldon/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/i18n-1.10.0/lib/i18n.rb:357:in `enforce_available_locales!' My conclusion is I think you should be setting an available |
Thanks - I will do that. - thanks for putting time into this - I thought it must be somewhere in your code. |
We have an application with
config.i18n.available_locales = [:fr, :nl]
Crazy but we dont support English - as important as it is in the world :)
I might have some time to hack on this if you want me to try?
The text was updated successfully, but these errors were encountered: