Last updated November 5, 2012. Created by Jose Reyero on April 1, 2011.
Edited by frederickjh, Kristen Pol, epoitras, pixelite. Log in to edit this page.
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):
- Enable the Variable translation module included with the Internationalization package
- Go to Administration > Configuration > Regional and language > Multilingual settings
- Click on the Variables tab
- Select the variables that will be multilingual
- 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
| Attachment | Size |
|---|---|
| multilingual_variables_1.png | 57.67 KB |
| multilingual_variables_2.png | 34.57 KB |
Comments
Also for what it's worth if
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.
Missing documentation
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 :
<?php/**
* 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;
}
?>
Frenchy drupal developper