Sha256: d4cecd8b8ec2e064df89a4bc515c750468939d0ca229fa7d7e2152bf8cc5fd5f

Contents?: true

Size: 790 Bytes

Versions: 24

Compression:

Stored size: 790 Bytes

Contents

# See https://ddnexus.github.io/pagy/api/frontend#i18n
# encoding: utf-8
# 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|   # first loaded locale used as default
  i18n.define_singleton_method(:load) do |*args|
    # eval: we don't need to keep the loader proc in memory
    eval(Pagy.root.join('locales', 'utils', 'loader.rb').read).call(i18n, *args)   #rubocop:disable Security/Eval
  end
  i18n.define_singleton_method(:t) do |locale, path, vars={}|
    data, pluralize = self[locale]
    translate = data[path] || vars[:count] && data[path+=".#{pluralize.call(vars[:count])}"] or return %([translation missing: "#{path}"])
    translate.call(vars)
  end
  i18n.load(locale: 'en')
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pagy-3.7.3 lib/locales/utils/i18n.rb
pagy-3.7.2 lib/locales/utils/i18n.rb
pagy-3.7.1 lib/locales/utils/i18n.rb
pagy-3.7.0 lib/locales/utils/i18n.rb
pagy-3.6.0 lib/locales/utils/i18n.rb
pagy-3.5.1 lib/locales/utils/i18n.rb
pagy-3.5.0 lib/locales/utils/i18n.rb
pagy-3.4.1 lib/locales/utils/i18n.rb
pagy-3.4.0 lib/locales/utils/i18n.rb
pagy-3.3.2 lib/locales/utils/i18n.rb
pagy-3.3.1 lib/locales/utils/i18n.rb
pagy-3.3.0 lib/locales/utils/i18n.rb
pagy-3.2.1 lib/locales/utils/i18n.rb
pagy-3.2.0 lib/locales/utils/i18n.rb
pagy-3.1.0 lib/locales/utils/i18n.rb
pagy-3.0.0 lib/locales/utils/i18n.rb
pagy-2.1.5 lib/locales/utils/i18n.rb
pagy-2.1.4 lib/locales/utils/i18n.rb
pagy-2.1.3 lib/locales/utils/i18n.rb
pagy-2.1.2 lib/locales/utils/i18n.rb