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