Skip to content

Commit

Permalink
Pass options to along to exists? super calls
Browse files Browse the repository at this point in the history
Fixes #670
  • Loading branch information
radar committed Jun 21, 2023
1 parent 395aa5e commit 62f0053
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/backend/fallbacks.rb
Expand Up @@ -95,7 +95,7 @@ def exists?(locale, key, options = EMPTY_HASH)
return super unless options.fetch(:fallback, true)
I18n.fallbacks[locale].each do |fallback|
begin
return true if super(fallback, key)
return true if super(fallback, key, options)
rescue I18n::InvalidLocale
# we do nothing when the locale is invalid, as this is a fallback anyways.
end
Expand Down
6 changes: 5 additions & 1 deletion test/backend/fallbacks_test.rb
Expand Up @@ -312,7 +312,7 @@ class Chain < I18n::Backend::Chain
def setup
super
backend = Backend.new
backend.store_translations(:de, :foo => 'FOO')
backend.store_translations(:de, :foo => 'FOO', :nested => { key: "value" })
backend.store_translations(:'pt-BR', :foo => 'Baz in :pt-BR')
I18n.backend = Chain.new(I18n::Backend::Simple.new, backend)
end
Expand All @@ -325,6 +325,10 @@ def setup
assert_equal true, I18n.exists?(:foo, :locale => :'de-DE')
end

test "exists? passes along the scope option" do
assert_equal true, I18n.exists?(:key, :locale => :'de-DE', scope: :nested)
end

test "exists? should return false when fallback disabled given a key missing from the given locale" do
assert_equal false, I18n.exists?(:foo, :locale => :'de-DE', fallback: false)
end
Expand Down

0 comments on commit 62f0053

Please sign in to comment.