You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a gem/Rails engine author that is using with_locale to step as lightly as possible within the parent Rails application. I've found an unexpected problem: 18n.with_locale will raise an exception if the current locale is not an available locale and available locales are enforced. (bensheldon/good_job#549). Thank you for the help!
An alternative way to describe this problem is: I18n's locale/default_locale can be initialized with invalid/unavailable values (I'm not sure if this is originating with this gem or with Rails, but it results in I18n to be in what appears to be an invalid state).
[1]pry(main)> I18n.available_locales=>[:nl,:fr][2]pry(main)> I18n.default_locale=>:en[3]pry(main)> I18n.locale=>:en[4]pry(main)> I18n.with_locale(:fr){puts"temporary locale is #{I18n.locale}"}temporarylocaleisfrI18n::InvalidLocale: :enis not avalidlocalefrom/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!'
The exceptions is raised within line 330 of with_locale, when the current locale is reassigned/reset after the block.
I'm a gem/Rails engine author that is using
with_locale
to step as lightly as possible within the parent Rails application. I've found an unexpected problem:18n.with_locale
will raise an exception if the current locale is not an available locale and available locales are enforced. (bensheldon/good_job#549). Thank you for the help!An alternative way to describe this problem is: I18n's
locale
/default_locale
can be initialized with invalid/unavailable values (I'm not sure if this is originating with this gem or with Rails, but it results in I18n to be in what appears to be an invalid state).The exceptions is raised within line 330 of
with_locale
, when the current locale is reassigned/reset after the block.i18n/lib/i18n.rb
Lines 321 to 333 in 00fc810
Potential solutions
locale
to be initialized in an invalid state in the first placewith_locale
ignoreenforce_available_locales
when re-assigning the current localeThe text was updated successfully, but these errors were encountered: