Class: NSString
- Inherits:
-
Object
- Object
- NSString
- Defined in:
- lib/MotionLocalize/cocoa/ns_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 |
# File 'lib/MotionLocalize/cocoa/ns_string.rb', line 3 def translate(opts={}) str = NSBundle.mainBundle.localizedStringForKey(self, value: nil, table: nil) 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 |