Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #102 from spastorino/master

translate with default value should check all the fallbacks
  • Loading branch information...
commit 94f6aa1f6eb62406ae564f0377c1490d036a6298 2 parents 2778870 + 3746542
José Valim josevalim authored
2  lib/i18n/backend/fallbacks.rb
View
@@ -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
5 test/backend/fallbacks_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.