Sha256: 47b80a9dce37a00ad834e838b934e936805a0b332083c8b2ccc4448048e03f54

Contents?: true

Size: 736 Bytes

Versions: 30

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

# 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 Extensions
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

30 entries across 30 versions & 2 rubygems

Version Path
paid_up-0.13.22 lib/paid_up/localization.rb
paid_up-0.13.21 lib/paid_up/localization.rb
paid_up-0.13.17 lib/paid_up/localization.rb
paid_up-0.13.16 lib/paid_up/localization.rb
paid_up-0.13.14 lib/paid_up/localization.rb
paid_up-0.13.13 lib/paid_up/localization.rb
paid_up-0.13.12 lib/paid_up/localization.rb
paid_up-0.13.11 lib/paid_up/localization.rb
paid_up-0.13.10 lib/paid_up/localization.rb
paid_up-0.13.9 lib/paid_up/localization.rb
paid_up-0.13.8 lib/paid_up/localization.rb
paid_up-0.13.7 lib/paid_up/localization.rb
paid_up-0.13.6 lib/paid_up/localization.rb
paid_up-0.13.5 lib/paid_up/localization.rb
paid_up-0.13.4 lib/paid_up/localization.rb
paid_up-0.13.3 lib/paid_up/localization.rb
paid_up-0.13.2 lib/paid_up/localization.rb
paid_up-0.13.1 lib/paid_up/localization.rb
paid_up-0.13.0 lib/paid_up/localization.rb
paid_up-0.12.4 lib/paid_up/localization.rb