Skip to content

Commit

Permalink
Exclude :count option on retrieve link
Browse files Browse the repository at this point in the history
  • Loading branch information
Tietew committed Jun 7, 2019
1 parent 0c5dab4 commit a068ef2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/backend/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def resolve(locale, object, subject, options = EMPTY_HASH)
result = catch(:exception) do
case subject
when Symbol
I18n.translate(subject, options.merge(:locale => locale, :throw => true))
I18n.translate(subject, options.merge(:locale => locale, :throw => true).except(:count))
when Proc
date_or_time = options.delete(:object) || object
resolve(locale, object, subject.call(date_or_time, options))
Expand Down
12 changes: 11 additions & 1 deletion lib/i18n/tests/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Link
}
assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
end

test "linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do
I18n.backend.store_translations 'en', {
:foo => { :link => :"bar.linked" },
Expand All @@ -51,6 +51,16 @@ module Link
assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
end

test "linked lookup: a link can resolve with option :count" do
I18n.backend.store_translations 'en', {
:counter => :counted,
:counted => { :foo => { :one => "one", :other => "other" }, :bar => "bar" }
}
assert_equal "one", I18n.t(:'counter.foo', count: 1)
assert_equal "other", I18n.t(:'counter.foo', count: 2)
assert_equal "bar", I18n.t(:'counter.bar', count: 3)
end
end
end
end

0 comments on commit a068ef2

Please sign in to comment.