diff --git a/lib/i18n/locale/fallbacks.rb b/lib/i18n/locale/fallbacks.rb index 83f2a5e9..0a791c65 100644 --- a/lib/i18n/locale/fallbacks.rb +++ b/lib/i18n/locale/fallbacks.rb @@ -66,6 +66,7 @@ def defaults=(defaults) def [](locale) raise InvalidLocale.new(locale) if locale.nil? + raise Disabled.new('fallback#[]') if locale == false locale = locale.to_sym super || store(locale, compute(locale)) end diff --git a/test/locale/fallbacks_test.rb b/test/locale/fallbacks_test.rb index 78ee140a..a2b1c5b2 100644 --- a/test/locale/fallbacks_test.rb +++ b/test/locale/fallbacks_test.rb @@ -130,4 +130,12 @@ def setup @fallbacks.map(:no => :nb, :nb => :no) assert_equal [:nb, :no, :"en-US", :en], @fallbacks[:nb] end + + # Test I18n::Disabled is raised correctly when locale is false during fallback + + test "with locale equals false" do + assert_raise I18n::Disabled do + @fallbacks[false] + end + end end