Skip to content

Commit

Permalink
Merge pull request #399 from fatkodima/fix-t-with-false
Browse files Browse the repository at this point in the history
Fix translate with default: [false]
  • Loading branch information
radar committed Jan 11, 2018
2 parents 6dc0102 + 1365d49 commit 8bb7749
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/i18n/backend/base.rb
Expand Up @@ -103,7 +103,8 @@ def default(locale, object, subject, options = {})
case subject
when Array
subject.each do |item|
result = resolve(locale, object, item, options) and return result
result = resolve(locale, object, item, options)
return result unless result.nil?
end and nil
else
resolve(locale, object, subject, options)
Expand Down
4 changes: 4 additions & 0 deletions lib/i18n/tests/defaults.rb
Expand Up @@ -24,6 +24,10 @@ def setup
assert_equal 'bar', I18n.t(:does_not_exist, :default => [:does_not_exist_2, :'foo.bar'])
end

test "defaults: given an array as a default with false it returns false" do
assert_equal false, I18n.t(:does_not_exist, :default => [false])
end

test "defaults: given false it returns false" do
assert_equal false, I18n.t(:does_not_exist, :default => false)
end
Expand Down

0 comments on commit 8bb7749

Please sign in to comment.