Sha256: 7fc0b8f72b6d116ce87acf8e8a797beb55bbfca336ba99b7a3aee33c0aa5e5ac

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 Bytes

Contents

module Mwkrom
  module Localize


    def mkt_debug_loc?
      !! (defined?(MKT_DEBUG_LOC) && (MKT_DEBUG_LOC)  )
    end

    def mkt_with_scope(scope_name, &block)
      @mkt_scope_names ||= []
      @mkt_scope_names.push(scope_name)
      r = yield
      @mkt_scope_names.pop
      r
    end

    def mkt(*args)
      xtras = ((sc = (@mkt_scope_names && @mkt_scope_names.last)) ? {:scope => sc} : {})
      r = I18n.t(args[0], (args[1] || {}).merge(xtras))
      if mkt_debug_loc?
        mkt_as_debug(r)
      else
        r
      end
    end

    def mkt_as_debug(x)
      "★#{x}★"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mwk-ruby-utils-0.5.0 lib/mwkrom/localize.rb
mwk-ruby-utils-0.4.0 lib/mwkrom/localize.rb