diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index ca12c227..70b93717 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -66,7 +66,7 @@ def translate(locale, key, options = EMPTY_HASH) end def exists?(locale, key, options = EMPTY_HASH) - lookup(locale, key) != nil + lookup(locale, key, options[:scope]) != nil end # Acts the same as +strftime+, but uses a localized version of the diff --git a/test/i18n_test.rb b/test/i18n_test.rb index 7b4d6757..28becfc6 100644 --- a/test/i18n_test.rb +++ b/test/i18n_test.rb @@ -303,6 +303,10 @@ def setup assert_equal true, I18n.exists?(:currency, :nl) end + test "exists? given an existing key and a scope will return true" do + assert_equal true, I18n.exists?(:delimiter, scope: [:currency, :format]) + end + test "exists? given a non-existing key and an existing locale will return false" do assert_equal false, I18n.exists?(:bogus, :nl) end