function locale_language_selector_form
Form builder callback to display language selection widget.
See also
Related topics
1 call to locale_language_selector_form()
- locale_form_alter in modules/
locale/ locale.module - Implements hook_form_alter().
File
-
modules/
locale/ locale.module, line 277
Code
function locale_language_selector_form(&$form, &$form_state, $user) {
global $language;
$languages = language_list('enabled');
$languages = $languages[1];
// If the user is being created, we set the user language to the page language.
$user_preferred_language = $user->uid ? user_preferred_language($user) : $language;
$names = array();
foreach ($languages as $langcode => $item) {
$name = t($item->name);
$names[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : '');
}
$form['locale'] = array(
'#type' => 'fieldset',
'#title' => t('Language settings'),
'#weight' => 1,
'#access' => $form['#user_category'] == 'account' || $form['#user_category'] == 'register' && user_access('administer users'),
);
// Get language negotiation settings.
$mode = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_DEFAULT;
$form['locale']['language'] = array(
'#type' => count($names) <= 5 ? 'radios' : 'select',
'#title' => t('Language'),
'#default_value' => $user_preferred_language->language,
'#options' => $names,
'#description' => $mode ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."),
);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.