module TranslationHelper::ClassMethods

Public Instance Methods

translation_helper_method(*helper_names) click to toggle source
# File lib/translation_helper.rb, line 5
def translation_helper_method(*helper_names)
  helper_names.each do |helper_name|
    helper_name = helper_name.to_sym
    define_method helper_name, ->(name, options ={}) {
      options[:scope] ||= []
      options[:scope].insert(0, helper_name.to_s.pluralize.to_sym)
      I18n.t(name, options)
    }
    private helper_name
    helper_method helper_name
  end
end