I've tried to change the text with localization but can't find the text. Is there a way to change the texts "points" / "point" to something else?

http://drunkerer.com

Comments

Christopher Herberte’s picture

Ok, using the theme_vote_up_down_points_alt() override fixed this in my case. To my template.php file i copied and pasted the function and renamed it to suit


function mytheme_vote_up_down_points_alt($cid, $type) {
  $vote_result = votingapi_get_voting_result($type, $cid, 'points', variable_get('vote_up_down_tag', 'vote'), 'sum');
  if ($vote_result) {
    $output = '<div id="vote_points_'. $cid .'" class="vote-points">'. $vote_result->value;
  }
  else {
    $output = '<div id="vote_points_'. $cid .'" class="vote-points">0';
  }

  $output .= '<div class="vote-points-label">'. t('gumtrees') .'</div></div>';
  return $output;
}

...and changed the 2nd last line t('points') to t('gumtrees')

I'm guessing there i could do all sorts of cool theming too, but that's all i needed. hope this helps someone.

Christopher Herberte’s picture

Status: Active » Closed (fixed)

Also, this can be changed by enabling the Locale module and changing the Localization (points) to "gumtrees", this was what i was originally looking for but did not look hard enough.

chadchandler’s picture

Great post and idea! Branding is everything!

I was looking for this as well, what would be better? Adding the code or using localization?

Christopher Herberte’s picture

If you only need to change this text and you already have the localization module installed I would go that route. The template.php way is going to give you more flexibility in theming the widget for sure and is my recommendation. I would much prefer a few lines of code to override the function than enabling the localization.module just for this. My 2c.

manerhabe’s picture

The above code wouldn't work for me, so I followed the directions for changing locales at http://drupal.org/node/24593 (remember to visit some changes to add the default strings to the translation). Changing the string "@count points" to "@count whatever" fixed it for me.

chadchandler’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

I definitely would not enable the locale module just to change the widget text, instead add this function to your template.php file. In this case, I'm changing the "points" to "melons". This example is using Garland.

/**
*Override vote up/down. Change 'points' to 'melons'.
*/
function garland_vote_up_down_points($cid, $type, $nodelink = FALSE) {
  $vote_result = votingapi_get_voting_result($type, $cid, 'points', variable_get('vote_up_down_tag', 'vote'), 'sum');
  if ($nodelink) {
    if ($vote_result) {
      $output = array(
        'title' => '<span id="vote_points_'. $cid .'" class="vote-points">'. format_plural($vote_result->value, '1 melon', '@count melons') .'</span>',
        'html' => TRUE
      );
    }
    else {
      $output = array(
        'title' => '<span id="vote_points_'. $cid .'" class="vote-points">'. t('0 melons') .'</span>',
        'html' => TRUE
      );
    }
  }
  else {
    if ($vote_result) {
      $output = '<span id="vote_points_'. $cid .'" class="vote-points">'. format_plural($vote_result->value, '1 melon', '@count melons') .'</span>';
    }
    else {
      $output = '<span id="vote_points_'. $cid .'" class="vote-points">'. t('0 melons') .'</span>';
    }
  }

  return $output;
}

function garland_vote_up_down_points_alt($cid, $type) {
  $vote_result = votingapi_get_voting_result($type, $cid, 'points', variable_get('vote_up_down_tag', 'vote'), 'sum');
  if ($vote_result) {
    $output = '<div id="vote_points_'. $cid .'" class="vote-points">'. $vote_result->value;
  }
  else {
    $output = '<div id="vote_points_'. $cid .'" class="vote-points">0';
  }

  $output .= '<div class="vote-points-label">'. format_plural($vote_result->value, 'melon', 'melons') .'</div></div>';

  return $output;
}

Don't forget to

  1. replace 'garland' with the name of your own Drupal theme folder
  2. replace each occurrence of 'melon' and 'melons' with your own points name (e.g. spins, goals, boosts, votes etc.) using either the singular or plural
manerhabe’s picture

Thanks Prodigy. I had to change some other text in various other models too. I'm curious why you would not use the locale module to do this though.

marvil07’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Please take a look to the update on the project page, now 5.x is not-really-maintained.

If you think your question is still applicably to the last recommended version(6.x-2.x) please move the version accordingly and reopen it.