Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/MotionLocalize/android/string.rb
Instance Method Summary collapse
- #translate(opts = {}) ⇒ Object (also: #_)
Instance Method Details
#translate(opts = {}) ⇒ Object Also known as: _
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/MotionLocalize/android/string.rb', line 3 def translate(opts={}) context = MotionLocalize.context raise ArgumentError.new 'MotionLocalize on android require that you init MotionLocalize.context' unless context str = context.getString(self) unless str return self end str = str.dup opts.each do |key, value| puts "replace #{key} with #{value}" str.gsub!("%{#{key}}", value.respond_to?(:to_s) ? value.to_s : value) end str end |