Sha256: fe926f8a4e637be646e6394919e202b7e4dfd71bd88898124398431bfedefadf
Contents?: true
Size: 641 Bytes
Versions: 40
Compression:
Stored size: 641 Bytes
Contents
# frozen_string_literal: true require 'avm/patches/i18n' class Class TRANSLATE_LOCALE_KEY = :__locale def translate(entry_suffix, values = {}) on_i18n_locale(values.delete(TRANSLATE_LOCALE_KEY)) do ::I18n.translate(translate_entry_full(entry_suffix), values) end end def translate_entry_full(entry_suffix) "#{translate_entry_self_prefix}.#{entry_suffix}" end def translate_entry_self_prefix name.underscore.gsub('/', '.') end def on_i18n_locale(locale) old_locale = ::I18n.locale begin ::I18n.locale = locale yield ensure ::I18n.locale = old_locale end end end
Version data entries
40 entries across 40 versions & 1 rubygems