function locale_form_alter in Drupal 6
Same name and namespace in other branches
- 7 modules/locale/locale.module \locale_form_alter()
Implementation of hook_form_alter(). Adds language fields to forms.
File
- modules/
locale/ locale.module, line 241 - Add language handling functionality and enables the translation of the user interface to languages other than English.
Code
function locale_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
// Language field for paths
case 'path_admin_form':
$form['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#options' => array(
'' => t('All languages'),
) + locale_language_list('name'),
'#default_value' => $form['language']['#value'],
'#weight' => -10,
'#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set for <em>All languages</em>.'),
);
break;
// Language setting for content types
case 'node_type_form':
if (isset($form['identity']['type'])) {
$form['workflow']['language_content_type'] = array(
'#type' => 'radios',
'#title' => t('Multilingual support'),
'#default_value' => variable_get('language_content_type_' . $form['#node_type']->type, 0),
'#options' => array(
t('Disabled'),
t('Enabled'),
),
'#description' => t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the <a href="!languages">enabled languages</a>. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array(
'!languages' => url('admin/settings/language'),
)),
);
}
break;
// Language field for nodes
default:
if (isset($form['#id']) && $form['#id'] == 'node-form') {
if (isset($form['#node']->type) && variable_get('language_content_type_' . $form['#node']->type, 0)) {
$form['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#default_value' => isset($form['#node']->language) ? $form['#node']->language : '',
'#options' => array(
'' => t('Language neutral'),
) + locale_language_list('name'),
);
}
elseif (!isset($form['#node']->nid)) {
$default = language_default();
$form['language'] = array(
'#type' => 'value',
'#value' => $default->language,
);
}
}
}
}