From dcda31cc1bc367496cfa52f706b5e8c7b7fd26ff Mon Sep 17 00:00:00 2001 From: Tietew Date: Fri, 7 Jun 2019 14:48:58 +0900 Subject: [PATCH] Exclude :count option on retrieve link --- lib/i18n/backend/base.rb | 2 +- lib/i18n/tests/link.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index 497f69b9..d149081d 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -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)) diff --git a/lib/i18n/tests/link.rb b/lib/i18n/tests/link.rb index da84a2c8..d2f20e80 100644 --- a/lib/i18n/tests/link.rb +++ b/lib/i18n/tests/link.rb @@ -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" }, @@ -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