Sha256: 623609f152da852c2ec69d2e5813e85bb573f4c122a32ddfbfaf6eb90cc45f85

Contents?: true

Size: 387 Bytes

Versions: 7

Compression:

Stored size: 387 Bytes

Contents

# frozen_string_literal: true

# extension of I18n
class O18n
  ENV_REGEX = /\$ENV\{(\w*)\}/.freeze

  def self.t(*args, **kwargs)
    value = I18n.t(*args, **kwargs)
    value.gsub(ENV_REGEX) do
      envar = ENV[Regexp.last_match(1)]
      if envar.blank?
        Regexp.last_match(1).titleize
      else
        I18n.exists?(envar) ? I18n.t(envar) : envar
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
five-two-nw-olivander-0.2.0.40 lib/o18n.rb
five-two-nw-olivander-0.2.0.39 lib/o18n.rb
five-two-nw-olivander-0.2.0.38 lib/o18n.rb
five-two-nw-olivander-0.2.0.37 lib/o18n.rb
five-two-nw-olivander-0.2.0.36 lib/o18n.rb
five-two-nw-olivander-0.2.0.35 lib/o18n.rb
five-two-nw-olivander-0.2.0.34 lib/o18n.rb