Sha256: 1c0afd1800e51d2346d55a628799de9fb5cb964841c828ff7d5fdc06400e2266

Contents?: true

Size: 751 Bytes

Versions: 13

Compression:

Stored size: 751 Bytes

Contents

# See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/i18n
# frozen_string_literal: true

class Pagy # :nodoc:
  # Use ::I18n gem
  module I18nExtra
    # Frontend overriding for translation
    module Frontend
      def pagy_t(key, **opts)
        ::I18n.t(key, **opts)
      end
    end

    # Calendar overriding for localization (see also the block in the calendar section of the config/pagy.rb initializer)
    module Calendar
      def localize(time, opts)
        ::I18n.l(time, **opts)
      end
    end
  end
  Frontend.prepend I18nExtra::Frontend
  Calendar.prepend I18nExtra::Calendar if defined?(Calendar)

  # Add the pagy locales to the I18n.load_path
  ::I18n.load_path += Dir[Pagy.root.join('locales', '*.yml')]
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pagy-6.5.0 lib/pagy/extras/i18n.rb
pagy-6.4.4 lib/pagy/extras/i18n.rb
pagy-6.4.3 lib/pagy/extras/i18n.rb
pagy-6.4.2 lib/pagy/extras/i18n.rb
pagy-6.4.1 lib/pagy/extras/i18n.rb
pagy-6.4.0 lib/pagy/extras/i18n.rb
pagy-6.3.0 lib/pagy/extras/i18n.rb
pagy-6.2.0 lib/pagy/extras/i18n.rb
pagy-6.1.0 lib/pagy/extras/i18n.rb
pagy-6.0.4 lib/pagy/extras/i18n.rb
pagy-6.0.3 lib/pagy/extras/i18n.rb
pagy-6.0.2 lib/pagy/extras/i18n.rb
pagy-6.0.1 lib/pagy/extras/i18n.rb