Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix translate with default: [false] #399

Merged
merged 1 commit into from Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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