The Variable translation module, part of the Internationalization (i18n) package, allows you to translate text and settings that are stored in Drupal as variables. These variables include text such as 'site name' and 'site slogan', as well as settings like 'Default front page' and 'Default 404 page'.

Dependency

The Variable translation module has a dependency on the Variable module.

Support for Contributed Modules

Variables provided by contributed modules can also be translated by the Variable translation module if they implement hook_variable_info(). For documentation, see the Variable module project page.

Usage

To enable multilingual variables (Figure 1):

  1. Enable the Variable translation module included with the Internationalization package
  2. Go to Administration > Configuration > Regional and language > Multilingual settings
  3. Click on the Variables tab
  4. Select the variables that will be multilingual
  5. Click Save configuration button

Figure 1

Once you have the correct settings, they'll be marked with "This is a multilingual variable" when you go to the corresponding administration pages (Figure 2). You must switch the site language while in the administration pages to set the variables for each language. A language switcher link will appear at the top of each administrative page that has multilingual variables.

Figure 2

Comments

ShaneOnABike’s picture

Also for what it's worth if you need to access any of these variables that you have translated you can use variable_get_value($name, $options) where $options can contain your language to grab an appropriate language you might need.

DuaelFr’s picture

When defining your variables using hook_variable_info(), you have to specify a localize key if you want your variables to be translatables.

See an example above :

/**
 * Implements hook_variable_info().
 */
function MYMODULE_variable_info($options) {
  $variables['VAR_NAME'] = array(
    'type' => 'array',
    'title' => t('VAR TITLE', array(), $options),
    'default' => array('*' => 0),
    'description' => t('VAR DESCRIPTION', array(), $options),
    'required' => TRUE,
    'localize' => TRUE,
    'group' => 'GROUP_NAME',
  );
  return $variables;
}

Not a man. Empathy buddy & NVC trainee. Ally.

dandekarprashant’s picture

Thanks man
this works.....!

knorbi’s picture

Thank you! It is work!
But can I export and import these translations?

kelutrab11’s picture

I just want to translate site name to different language - so when users browse a domain in english they see site name, and when they browse in polish for example, they see nazwa strony.

I got all modules (DA, i18n, variable) and I had enabled two languages, checked variable in admin/config/regional/i18n/variable
- but I can't translate the site name.

I try to translate it on admin/config/system/site-information page - different name for en patch and different for pl - no results, and on admin/structure/domain/view/X/config - also without any results.

I just can't select - https://www.drupal.org/files/multilingual_variables_2.png language - there is no sellection.

Any idea how to menage to translate site name? Am I doing something wrong ?