Sha256: 7b27362cd7cb1b73569b2d5e9c30dd76ea57f4929a84847d4f0a21c61c8968ae

Contents?: true

Size: 802 Bytes

Versions: 18

Compression:

Stored size: 802 Bytes

Contents

# See https://ddnexus.github.io/pagy/api/frontend#i18n
# frozen_string_literal: true

# this file returns the I18n hash used as default alternative to the i18n gem

Hash.new{|h,_| h.first[1]}.tap do |i18n_hash|   # first loaded locale used as default
  i18n_hash.define_singleton_method(:load) do |*load_args|
    # eval: we don't need to keep the loader proc in memory
    eval(Pagy.root.join('locales', 'utils', 'loader.rb').read).call(i18n_hash, *load_args)   #rubocop:disable Security/Eval
  end
  i18n_hash.define_singleton_method(:t) do |locale, key, **opts|
    data, pluralize = self[locale]
    translate = data[key] || opts[:count] && data[key+=".#{pluralize.call(opts[:count])}"] or return %([translation missing: "#{key}"])
    translate.call(opts)
  end
  i18n_hash.load(locale: 'en')
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/locales/utils/i18n.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/locales/utils/i18n.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/locales/utils/i18n.rb
pagy-4.11.0 lib/locales/utils/i18n.rb
pagy-4.10.2 lib/locales/utils/i18n.rb
pagy-4.10.1 lib/locales/utils/i18n.rb
pagy-4.10.0 lib/locales/utils/i18n.rb
pagy-4.9.0 lib/locales/utils/i18n.rb
pagy-4.8.1 lib/locales/utils/i18n.rb
pagy-4.8.0 lib/locales/utils/i18n.rb
pagy-4.7.1 lib/locales/utils/i18n.rb
pagy-4.7.0 lib/locales/utils/i18n.rb
pagy-4.6.0 lib/locales/utils/i18n.rb
pagy-4.5.1 lib/locales/utils/i18n.rb
pagy-4.5.0 lib/locales/utils/i18n.rb
pagy-4.4.0 lib/locales/utils/i18n.rb
pagy-4.3.0 lib/locales/utils/i18n.rb
pagy-4.2.0 lib/locales/utils/i18n.rb