it was an issue #196111: Translation for term "User Points for drupal 5.
It reproduces in 6.x-1.0 version - it is impossible to use russian plural forms.

Comments

crea’s picture

subs

kbahey’s picture

Version: 6.x-1.0 » 6.x-1.x-dev

I have no idea how to fix this. Can you or someone else create a patch and a few people test it?

fasdalf@fasdalf.ru’s picture

Title: 6юч plural form for "!Points" » 6.x plural form for "!Points"

Corrected issue title.

fasdalf@fasdalf.ru’s picture

We used thid code in our project

function userpoints_plural_stub_userpoints($op,  $params = array()) {
  switch ($op) {
    case 'points after':
      // number
      $count = $params['points'];
      if ($count!==0) {
        // now have
        $sum = userpoints_get_current_points($params['uid'], $params['tid']);

        // placeholders
        global $user;
        $user_pointed = user_load($params['uid']);
        $subst = array(
          '@count' => format_plural(abs($count), '@count userpoint', '@count userpoints'),
          '@sum' => format_plural($sum, '@count userpoint', '@count userpoints'),
          '@user' => $user_pointed->name,
        );
        // @@@ TODO: add userpoints category to the output.
        $subst = array_merge(userpoints_translation(),$subst);
        // formst output
        if ($user->uid == $params['uid']) { // own points
          if ($count > 0) {
            drupal_set_message(
              t('You gained @count and now you have @sum.', $subst)
            );
          }else{
            drupal_set_message(
              t('You lost @count and now you have @sum.', $subst)
            );
          }
        } else { // other user's points
          if ($count > 0) {
            drupal_set_message(
              t('User @user gained @count and have @sum now.', $subst)
            );
          }else{
            drupal_set_message(
              t( 'User @user lost @count and have @sum now.', $subst)
            );
          }
        }
        
      }

      break;
    case 'setting':
      // plurals
      $group = 'plural_messages';
      $form[$group] = array(
        '#type'        => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed'   => TRUE,
        '#title'       => t('Fixed plural messages'),
        //'#description' => t('How much !points...', userpoints_translation()),
      );
      $form[$group][URS_VARIABLE_PLURAL] = array(
        '#type'        => 'checkbox',
        '#title'       => t('Enable plural messages'),
        '#return_value'  => 1,
        '#default_value' => variable_get(URS_VARIABLE_PLURAL, 0),
        '#description' => t('Show true plural messages when !points are gained or lost', userpoints_translation()),
      );
      return $form;
      break;
  }

}
YK85’s picture

subscribing - can someone create a patch to be reviewed?
thanks!

andypost’s picture

.

mile23’s picture

From the old issue falsdaf linked to, it seems this should have been fixed in 5.x-dev. Why did it not make it to 6.x?

I just made a patch for http://drupal.org/node/284609 dealing with the same code. I wish I had known about format_plural() at the time. :-)

andypost’s picture

Bilmar’s picture

subscribing

chuckbar77’s picture

+1 subscribing

YK85’s picture

Status: Active » Needs review

Is #4 to be reviewed? I am not sure where it should go, but supporting plural form for !points would be awesome!

berdir’s picture

Status: Needs review » Closed (duplicate)

No, not really. That is solving it with a separate module, to really fix it, it would need to be a patch against 6.x.

Here is what we did for 7.x: #872238: Improve Message Syntax When Points Are Awarded

The problem is that this would obviously result in string changes, and that is discouraged for stable versions, because it would break all existing transations on sites which are already using it.

Anyway, I think that issue here can be closed as duplicate of the linked one. (And a few other issues in the queue too)