class Gem1::Trans_1

Public Instance Methods

i18n_tran(key) click to toggle source
# File lib/gem_1.rb, line 23
def i18n_tran(key)
    str= "faker.#{key}"
    i_tran(str)
end
i_tran( *args) click to toggle source
# File lib/gem_1.rb, line 28
def i_tran( *args)
    opts= args.last.is_a?(Hash) ? args.pop : {}
    opts[:locale] ="en"
    opts[:raise] = true
    I18n.translate(*(args.push(opts)))
end
method_missing(m, *args, &block) click to toggle source
# File lib/gem_1.rb, line 44
def method_missing(m, *args, &block)
    puts "=========="
    puts m
    puts args
    puts block
  "in method_missing=======#{m}===#{args}====#{block}==="
end
to_param(id) click to toggle source
# File lib/gem_1.rb, line 19
def to_param(id)
        "params_#{id}"
end
tran( key) click to toggle source
# File lib/gem_1.rb, line 35
def tran( key)
    #i18n_tran(key).sample.scan(/#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map{|a, b, c|
    #  "|#{a}|#{b}|#{c}|"
    #}
    i18n_tran(key).sample.scan(/#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map{|a,b,c|
      b+= c.to_s
    }.join
end