module I18n

def interpolate_hash(string, values)

Experimental RBS support (using type sampling data from the type_fusion project).

def interpolate_hash: (String string, Hash values) -> untyped

This signature was generated using 3 samples from 1 application.

def interpolate_hash(string, values)
  pattern = INTERPOLATION_PATTERNS_CACHE[config.interpolation_patterns]
  interpolated = false
  interpolated_string = string.gsub(pattern) do |match|
    interpolated = true
    if match == '%%'
      '%'
    else
      key = ($1 || $2 || match.tr("%{}", "")).to_sym
      value = if values.key?(key)
                values[key]
              else
                config.missing_interpolation_argument_handler.call(key, values, string)
              end
      value = value.call(values) if value.respond_to?(:call)
      $3 ? sprintf("%#{$3}", value) : value
    end
  end
  interpolated ? interpolated_string : string
end