function locale_form_node_form_alter in Drupal 7
Implements hook_form_BASE_FORM_ID_alter().
File
- modules/
locale/ locale.module, line 366 - Add language handling functionality and enables the translation of the user interface to languages other than English.
Code
function locale_form_node_form_alter(&$form, &$form_state) {
if (isset($form['#node']->type) && locale_multilingual_node_type($form['#node']->type)) {
$form['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#default_value' => isset($form['#node']->language) ? $form['#node']->language : '',
'#options' => array(
LANGUAGE_NONE => t('Language neutral'),
) + locale_language_list('name'),
);
}
elseif (!isset($form['#node']->nid)) {
$default = language_default();
$form['language'] = array(
'#type' => 'value',
'#value' => $default->language,
);
}
$form['#submit'][] = 'locale_field_node_form_submit';
}