Module: I18n::Tasks::StringInterpolation

Defined in:
lib/i18n/tasks/string_interpolation.rb

Class Method Summary collapse

Class Method Details

.interpolate_soft(s, t = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/i18n/tasks/string_interpolation.rb', line 7

def interpolate_soft(s, t = {})
  return s unless s

  t.each do |k, v|
    pat = "%{#{k}}"
    s = s.gsub pat, v.to_s if s.include?(pat)
  end
  s
end