class Middleman::CoreExtensions::Internationalization

def url_for(path_or_resource, options={})

def url_for(path_or_resource, options={})
  locale = options.delete(:locale) || ::I18n.locale
  opts = options.dup
  should_relativize = opts.key?(:relative) ? opts[:relative] : config[:relative_links]
  anchor = opts[:anchor]
  # The first call to `super()` is only to find the correct URL. The next
  # call will relativize and add the anchor.
  opts[:relative] = false
  opts[:anchor] = nil
  href = super(path_or_resource, opts)
  final_path = if result = extensions[:i18n].localized_path(href, locale)
    result
  else
    # Should we log the missing file?
    href
  end
  opts[:relative] = should_relativize
  opts[:anchor] = anchor
  begin
    super(final_path, opts)
  rescue RuntimeError
    super(path_or_resource, options)
  end
end