Drupal 7 variables

Declare multilingual variables in the module code

<?php

/**
 * @file
 * Hooks provided by the Variable module.
 */

/**
 * Implements hook_variable_info().
 */
function uc_paypal_variable_info($options) {
  $variables['uc_paypal_wps_checkout_button'] = array(
    'title' => t('PayPal checkout button'),
    'description' => t('PayPal checkout button (for WPS).'),
    'group' => 'uc_paypal',
    'localize' => TRUE,
  );

  return $variables;
}

/**
 * Implements hook_variable_group_info().
 */
function uc_paypal_variable_group_info() {
  $groups['uc_paypal'] = array(
    'title' => t('Ubercart PayPal settings'),
    'access' => 'administer store',
  );

  return $groups;
}

Enable the "variable" module

  • see: http://www.drupal.org/project/variable
  • flush the Drupal cache if the module was already enabled

Enable multi-lingual variables

  • Go to: admin/config/regional/i18n/variable
  • Set the variable as multilingual

Translate the variable

  • Go to: admin/config/system/variable
  • Find the variable (by module or group), translate in all languages.

References / examples

Notes