Module: StringExtension

Defined in:
lib/message_train/localization.rb

Overview

String Extension

Instance Method Summary collapse

Instance Method Details

#localize(*args) ⇒ Object Also known as: l



3
4
5
6
7
8
9
10
11
# File 'lib/message_train/localization.rb', line 3

def localize(*args)
  sym = if args.first.is_a? Symbol
          args.shift
        else
          underscore.tr(' ', '_').gsub(/[^a-z0-9_]+/i, '').to_sym
        end
  args << { default: self }
  I18n.t(sym, *args).html_safe
end