Following the Ubercart multilingual-variables for user inputs (like the "Add to Chart" button text) this feature should be also in Userpoints

Simply add this function into userpoints.module :)

/**
 * Implements hook_init().
 */
function userpoints_init() {
  global $conf;
  $conf['i18n_variables'][] = USERPOINTS_TRANS_UCPOINTS;
  $conf['i18n_variables'][] = USERPOINTS_TRANS_LCPOINTS;
  $conf['i18n_variables'][] = USERPOINTS_TRANS_UCPOINT;
  $conf['i18n_variables'][] = USERPOINTS_TRANS_LCPOINT;
  $conf['i18n_variables'][] = USERPOINTS_TRANS_UNCAT;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

funature’s picture

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

the words still can not be translated.

funature’s picture

i have the same problem, i just see the string like !Points in translation UI, after a look at the code, i noticed that, the value of userpoints_translation function can not be sent to the string, like the title of a menu item.

  $items['admin/config/people/userpoints'] = array(
      'title' => '!points',
      'title arguments' => userpoints_translation(),
      'description' => strtr('Manage !points', userpoints_translation()),
      'page callback' => 'drupal_get_form',
      'page arguments' => array('userpoints_admin_points'),
      'access callback' => 'userpoints_admin_access',
      'access arguments' => array('list'),
      'file' => 'userpoints.admin.inc',
  );

@kbahey you use the 'title arguments' to insert the value, it seem not working. i see you also use the strtr function, so i made a little change, it works for now. I hope you can find a better way, i'm not a coder anyway.

  $items['admin/config/people/userpoints'] = array(
      'title' => strtr('!points', userpoints_translation()),
      'description' => strtr('Manage !points', userpoints_translation()),
      'page callback' => 'drupal_get_form',
      'page arguments' => array('userpoints_admin_points'),
      'access callback' => 'userpoints_admin_access',
      'access arguments' => array('list'),
      'file' => 'userpoints.admin.inc',
  );
funature’s picture

i must say, what i did is useless. i hope someone to solve this issue.

ps. the menu item can not be translated also.

Berdir’s picture

hook_menu() is correct as it is, there's no need nor point in changing that, it doesn't help.

Instead, what's necessary for 6.x is the code in the initial post and for 7.x-1.x, hook_variable_info() needs to be implemented, see http://api.worldempire.ch/api/simplenews/simplenews.module/function/simp... for an example.

Berdir’s picture

Status: Needs review » Active
funature’s picture

any improve yet?

joelrosen’s picture

So... how can I translate points branding into other languages? It is possible, right?

joelrosen’s picture

It seems this project is not being well maintained as of late, so I won't bother with a patch. Here is the code I added in my custom module to work around this:

/**
 * Implements hook_variable_group_info()
 *
 * Define a variable group for userpoints variables
 */
function my_module_variable_group_info() {
  $groups['userpoints_branding'] = array(
    'title' => t('User points branding'),
    'description' => t('User points branding variables'),
  );
  return $groups;
}

/**
 * Implements hook_variable_info()
 *
 * Expose userpoints branding variables for translation per this issue: http://drupal.org/node/1270768
 */
function my_module_variable_info($options) {
  $variables[USERPOINTS_TRANS_UCPOINTS] = array(
    'title' => t('Points'),
    'description' => t('Word to use in the interface for the upper case plural word Points'),
    'group' => 'userpoints_branding',
    'localize' => TRUE,
  );
  $variables[USERPOINTS_TRANS_LCPOINTS] = array(
    'title' => t('points'),
    'description' => t('Word to use in the interface for the lower case plural word points'),
    'group' => 'userpoints_branding',
    'localize' => TRUE,
  );
  $variables[USERPOINTS_TRANS_UCPOINT] = array(
    'title' => t('Point'),
    'description' => t('Word to use in the interface for the upper case singular word Point'),
    'group' => 'userpoints_branding',
    'localize' => TRUE,
  );
  $variables[USERPOINTS_TRANS_LCPOINT] = array(
    'title' => t('point'),
    'description' => t('Word to use in the interface for the lower case singular word point'),
    'group' => 'userpoints_branding',
    'localize' => TRUE,
  );
  return $variables;
}

Then go to Configuration > Multilingual settings > Variables and enable translation.

akalam’s picture

Thanks for the aproach, joelrosen. Patch attached!

akalam’s picture

quotesBro’s picture

Status: Needs review » Reviewed & tested by the community