Sha256: 3624eb2f176dabcad57f9a1c6f910955f92e896b1800f0fe46c4e9cf07616007

Contents?: true

Size: 785 Bytes

Versions: 28

Compression:

Stored size: 785 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 FrontendOverride
      def pagy_t(key, **opts)
        ::I18n.t(key, **opts)
      end
    end
    Frontend.prepend I18nExtra::FrontendOverride

    # Calendar overriding for localization (see also the block in the calendar section of the config/pagy.rb initializer)
    module CalendarOverride
      def localize(time, opts)
        ::I18n.l(time, **opts)
      end
    end
  end
  Calendar.prepend I18nExtra::CalendarOverride 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

28 entries across 28 versions & 1 rubygems

Version Path
pagy-8.4.5 lib/pagy/extras/i18n.rb
pagy-8.4.4 lib/pagy/extras/i18n.rb
pagy-8.4.3 lib/pagy/extras/i18n.rb
pagy-8.4.2 lib/pagy/extras/i18n.rb
pagy-8.4.1 lib/pagy/extras/i18n.rb
pagy-8.4.0 lib/pagy/extras/i18n.rb
pagy-8.3.0 lib/pagy/extras/i18n.rb
pagy-8.2.2 lib/pagy/extras/i18n.rb
pagy-8.2.1 lib/pagy/extras/i18n.rb
pagy-8.2.0 lib/pagy/extras/i18n.rb
pagy-8.1.2 lib/pagy/extras/i18n.rb
pagy-8.1.1 lib/pagy/extras/i18n.rb
pagy-8.1.0 lib/pagy/extras/i18n.rb
pagy-8.0.2 lib/pagy/extras/i18n.rb
pagy-8.0.1 gem/lib/pagy/extras/i18n.rb
pagy-8.0.0 lib/pagy/extras/i18n.rb
pagy-7.0.11 lib/pagy/extras/i18n.rb
pagy-7.0.10 lib/pagy/extras/i18n.rb
pagy-7.0.9 lib/pagy/extras/i18n.rb
pagy-7.0.8 lib/pagy/extras/i18n.rb