Permalink
Browse files

Merge pull request #102 from spastorino/master

translate with default value should check all the fallbacks
  • Loading branch information...
2 parents 2778870 + 3746542 commit 94f6aa1f6eb62406ae564f0377c1490d036a6298 @josevalim josevalim committed Jul 9, 2011
Showing with 6 additions and 1 deletion.
  1. +1 −1 lib/i18n/backend/fallbacks.rb
  2. +5 −0 test/backend/fallbacks_test.rb
View
2 lib/i18n/backend/fallbacks.rb
@@ -60,7 +60,7 @@ def extract_string_or_lambda_default!(options)
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 if default && !default.is_a?(Symbol) }
nil
end
end
View
5 test/backend/fallbacks_test.rb
@@ -48,6 +48,11 @@ def setup
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

0 comments on commit 94f6aa1

Please sign in to comment.