Created
July 9, 2011 23:03
-
-
Save spastorino/1074032 to your computer and use it in GitHub Desktop.
i18n.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/i18n/backend/fallbacks.rb b/lib/i18n/backend/fallbacks.rb | |
| index 70c2c04..f50e92e 100644 | |
| --- a/lib/i18n/backend/fallbacks.rb | |
| +++ b/lib/i18n/backend/fallbacks.rb | |
| @@ -60,7 +60,7 @@ module I18n | |
| end | |
| def find_first_string_or_lambda_default(defaults) | |
| - defaults.each_with_index { |default, ix| return ix if String === default || Proc === default } | |
| + defaults.each_with_index { |default, ix| return ix unless default.is_a? Symbol } | |
| nil | |
| end | |
| end | |
| diff --git a/test/backend/fallbacks_test.rb b/test/backend/fallbacks_test.rb | |
| index e743639..2b17da9 100644 | |
| --- a/test/backend/fallbacks_test.rb | |
| +++ b/test/backend/fallbacks_test.rb | |
| @@ -48,6 +48,11 @@ class I18nBackendFallbacksTranslateTest < Test::Unit::TestCase | |
| assert_equal "Default Bar", I18n.t(:missing_bar, :locale => :'de-DE', :default => Proc.new { "Default Bar" }) | |
| end | |
| + test "returns the :de translation for a missing :'de-DE' when :default is a Hash" do | |
| + assert_equal 'Bar in :de', I18n.t(:bar, :locale => :'de-DE', :default => {}) | |
| + assert_equal({}, I18n.t(:missing_bar, :locale => :'de-DE', :default => {})) | |
| + end | |
| + | |
| test "returns the :'de-DE' default :baz translation for a missing :'de-DE' when defaults contains Symbol" do | |
| assert_equal 'Baz in :de-DE', I18n.t(:missing_foo, :locale => :'de-DE', :default => [:baz, "Default Bar"]) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment