diff --git a/lib/pagy/extras/i18n.rb b/lib/pagy/extras/i18n.rb index 2a16f3717..d125855a7 100644 --- a/lib/pagy/extras/i18n.rb +++ b/lib/pagy/extras/i18n.rb @@ -10,10 +10,10 @@ module Frontend Pagy::I18n.clear.instance_eval { undef :load; undef :t } # unload the pagy default constant for efficiency - module I18n + module UseI18nGem def pagy_t(key, **opts) = ::I18n.t(key, **opts) end - prepend I18n + prepend UseI18nGem end end diff --git a/test/mock_helpers/application_helper.rb b/test/mock_helpers/application_helper.rb new file mode 100644 index 000000000..b742b8505 --- /dev/null +++ b/test/mock_helpers/application_helper.rb @@ -0,0 +1,8 @@ +module ApplicationHelper + include Pagy::Frontend + + def any_method_name() + I18n.t("test") + end + +end \ No newline at end of file diff --git a/test/pagy/extras/i18n_test.rb b/test/pagy/extras/i18n_test.rb index e507d69f6..4975a362d 100644 --- a/test/pagy/extras/i18n_test.rb +++ b/test/pagy/extras/i18n_test.rb @@ -7,11 +7,17 @@ SimpleCov.command_name 'i18n' if ENV['RUN_SIMPLECOV'] == 'true' +require_relative '../../mock_helpers/application_helper' +include ApplicationHelper + describe Pagy::Frontend do let(:view) { MockView.new } describe "#pagy_t with I18n" do + it 'works with an included Module' do + ApplicationHelper.any_method_name() + end it 'pluralizes' do _(view.pagy_t('pagy.nav.prev')).must_equal "‹ Prev"