How do I show the total number of votes for "Rating" option in Fivestar? When using the Fivestar module, I can show the result in three ways:

1) "Stars" - This has an additional setting called "Text to display under the stars". For example, it'll look like the following if I choose "Average vote":

*****
Average: 4.1 (235 votes)


2) "Rating" - There is no additional option whatsoever, so the above example will just look like the following:

4.1/5


3) "Percentage" - I don't use this, so let's just ignore it.

Is there a way to make the "Rating" option show the total number of votes like the following?

4.1/5 (235 votes)


UPDATE 1:

I have to overwrite the function theme_fivestar_summary on line 126, and add lines 279-301 right before return $output;:

function theme_fivestar_formatter_rating($variables) {
  $element = $variables['element'];

  if (empty($element['#item']['average'])) {
    $element['#item']['average'] = 0;
  }
  // Get number of stars.
  $stars = (empty($element['#instance_settings']['stars'])) ? 5 : $element['#instance_settings']['stars'];
  $average = $element['#item']['average'];
  // Rating is X out of Y stars.
  $rating = round(($average/100) * $stars, 1);
  $output = $rating . '/' . $stars;

  $votes = 235;
  if (isset($votes)) {
    if (!isset($user_rating) &amp;&amp; !isset($average_rating)) {
      $div_class = 'count';
    }
    if ($votes === 0) {
      $output = '&lt;span class="empty"&gt;'. t('No votes yet') .'&lt;/span&gt;';
    }
    else {
      if (!empty($microdata['rating_count']['#attributes'])) {
        $rating_count_microdata = drupal_attributes($microdata['rating_count']['#attributes']);
      }
      // We don't directly substitute $votes (i.e. use '@count') in format_plural,
      // because it has a span around it which is not translatable.
      $votes_str = format_plural($votes, '!cnt vote', '!cnt votes', array(
        '!cnt' =&gt; '&lt;span ' . $rating_count_microdata . '&gt;' . intval($votes) . '&lt;/span&gt;'));
      if (isset($user_rating) || isset($average_rating)) {
        $output .= ' &lt;span class="total-votes"&gt;(' . $votes_str . ')&lt;/span&gt;';
      }
      else {
        $output .= ' &lt;span class="total-votes"&gt;' . $votes_str . '&lt;/span&gt;';
      }
    }
  }

  return $output;
}


But the big problem is that I have no idea how to pass the $votes variable, so I hardcoded $votes = 235; right above if (isset($votes)) {, just to see if the code works so far, which it does:

4.1/5 235 votes


I know where to add the parentheses (line 298), but I'm having trouble figuring out how to pass $votes. Any help is greatly appreciated.

UPDATE 2:

The code above is far from perfect, as it produces minor error messages regarding the $microdata &amp; $rating_count_microdata variables. Using the code from Jeroen, I was able to come up with better code that I posted as the final answer below.
The output for average votes is set in the fivestar.theme.inc file, which is located at fivestar/includes. You have to overwrite the function theme_fivestar_summary on line 248 (version 7.x-2.1). In order to do this, simply copy the whole function to your theme's template.php file and make the necessary adjustments. I've already done that for you in the code underneath:

function YOURTHEME_fivestar_summary($variables) {
  $microdata = $variables['microdata'];
  extract($variables, EXTR_SKIP);
  $output = '';
  $div_class = '';
  $average_rating_microdata = '';
  $rating_count_microdata = '';
  if (isset($user_rating)) {
    $div_class = isset($votes) ? 'user-count' : 'user';
    $user_stars = round(($user_rating * $stars) / 100, 1);
    $output .= '&lt;span class="user-rating"&gt;' . t('Your rating: &lt;span&gt;!stars&lt;/span&gt;', array('!stars' =&gt; $user_rating ? $user_stars : t('None'))) . '&lt;/span&gt;';
  }
  if (isset($user_rating) &amp;&amp; isset($average_rating)) {
    $output .= ' ';
  }
  if (isset($average_rating)) {
    if (isset($user_rating)) {
      $div_class = 'combo';
    }
    else {
      $div_class = isset($votes) ? 'average-count' : 'average';
    }

    $average_stars = round(($average_rating * $stars) / 100, 1);
    if (!empty($microdata['average_rating']['#attributes'])) {
      $average_rating_microdata = drupal_attributes($microdata['average_rating']['#attributes']);
    }
    $output .= '&lt;span class="average-rating"&gt;' . t('!stars',
      array('!stars' =&gt; "&lt;span $average_rating_microdata&gt;$average_stars/5&lt;/span&gt;")) . '&lt;/span&gt;';
  }

  if (isset($votes)) {
    if (!isset($user_rating) &amp;&amp; !isset($average_rating)) {
      $div_class = 'count';
    }
    if ($votes === 0) {
      $output = '&lt;span class="empty"&gt;'. t('No votes yet') .'&lt;/span&gt;';
    }
    else {
      if (!empty($microdata['rating_count']['#attributes'])) {
        $rating_count_microdata = drupal_attributes($microdata['rating_count']['#attributes']);
      }
      // We don't directly substitute $votes (i.e. use '@count') in format_plural,
      // because it has a span around it which is not translatable.
      $votes_str = format_plural($votes, '!cnt vote', '!cnt votes', array(
        '!cnt' =&gt; '&lt;span ' . $rating_count_microdata . '&gt;' . intval($votes) . '&lt;/span&gt;'));
      if (isset($user_rating) || isset($average_rating)) {
        $output .= ' &lt;span class="total-votes"&gt;(' . $votes_str . ')&lt;/span&gt;';
      }
      else {
        $output .= ' &lt;span class="total-votes"&gt;' . $votes_str . '&lt;/span&gt;';
      }
    }
  }


  $output = '&lt;div class="fivestar-summary fivestar-summary-' . $div_class . '"&gt;' . $output . '&lt;/div&gt;';
  return $output;
}