From 217c01734d8c0cbb4c61144ec33a3fd6db2a677e Mon Sep 17 00:00:00 2001 From: Domizio Demichelis Date: Fri, 8 May 2020 18:37:18 +0700 Subject: [PATCH] added conditional definition of pagy_t_with_i18n to avoid ruby 2.7 "last argument as keyword parameters" deprecation warning (closes #241) --- lib/pagy/extras/i18n.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pagy/extras/i18n.rb b/lib/pagy/extras/i18n.rb index 086b1688d..25eefd229 100644 --- a/lib/pagy/extras/i18n.rb +++ b/lib/pagy/extras/i18n.rb @@ -11,7 +11,11 @@ module Frontend Pagy::I18n.clear.instance_eval { undef :load; undef :t } # unload the pagy default constant for efficiency alias_method :pagy_without_i18n, :pagy_t - def pagy_t_with_i18n(*args) ::I18n.t(*args) end + if Gem::Version.new(::I18n::VERSION) < Gem::Version.new('1.6.0') + def pagy_t_with_i18n(*args) ::I18n.t(*args) end + else + def pagy_t_with_i18n(key, **opts) ::I18n.t(key, **opts) end + end alias_method :pagy_t, :pagy_t_with_i18n end