diff --git a/lib/i18n/backend/fallbacks.rb b/lib/i18n/backend/fallbacks.rb index 7688c13d..1acdbd68 100644 --- a/lib/i18n/backend/fallbacks.rb +++ b/lib/i18n/backend/fallbacks.rb @@ -49,7 +49,7 @@ def translate(locale, key, options = EMPTY_HASH) catch(:exception) do result = super(fallback, key, fallback_options) unless result.nil? - on_fallback(locale, fallback, key, options) if locale != fallback + on_fallback(locale, fallback, key, options) if locale.to_s != fallback.to_s return result end end diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb index a3b0dcd0..d2c9ad36 100644 --- a/test/backend/fallbacks_test.rb +++ b/test/backend/fallbacks_test.rb @@ -342,4 +342,9 @@ def setup assert_equal [:'de-DE', :de, :bar, {}], I18n.backend.fallback_collector[0] assert_equal [:'de-DE', :en, :foo, {}], I18n.backend.fallback_collector[1] end + + test "on_fallback should not be called when use a String locale" do + assert_equal 'Bar in :de', I18n.t("bar", locale: "de") + assert I18n.backend.fallback_collector.nil? + end end