Sha256: 1bd4f925fed26cd0ef43b96abb1daea30ce7d86237754ef2971b10f3d7d5267f

Contents?: true

Size: 701 Bytes

Versions: 24

Compression:

Stored size: 701 Bytes

Contents

# String Extension
module StringExtension
  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
  alias l localize
end
String.send :include, StringExtension

# Symbol Extension
module SymbolExtensionCustom
  def localize_with_debugging(*args)
    localized_sym = I18n.translate(self, *args)
    localized_sym.is_a?(String) ? localized_sym.html_safe : localized_sym
  end
  alias l localize_with_debugging
  def l_with_args(*args)
    l(*args).html_safe
  end
end
Symbol.send :include, SymbolExtensionCustom

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
message_train-0.7.6 lib/message_train/localization.rb
message_train-0.7.5 lib/message_train/localization.rb
message_train-0.7.3 lib/message_train/localization.rb
message_train-0.7.2 lib/message_train/localization.rb
message_train-0.7.1 lib/message_train/localization.rb
message_train-0.6.17 lib/message_train/localization.rb
message_train-0.6.16 lib/message_train/localization.rb
message_train-0.6.15 lib/message_train/localization.rb
message_train-0.6.14 lib/message_train/localization.rb
message_train-0.6.13 lib/message_train/localization.rb
message_train-0.6.12 lib/message_train/localization.rb
message_train-0.6.11 lib/message_train/localization.rb
message_train-0.6.10 lib/message_train/localization.rb
message_train-0.6.9 lib/message_train/localization.rb
message_train-0.6.8 lib/message_train/localization.rb
message_train-0.6.7 lib/message_train/localization.rb
message_train-0.6.6 lib/message_train/localization.rb
message_train-0.6.5 lib/message_train/localization.rb
message_train-0.6.4 lib/message_train/localization.rb
message_train-0.6.3 lib/message_train/localization.rb