You are here

function language_process_language_select in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/language.module \language_process_language_select()
  2. 9 core/modules/language/language.module \language_process_language_select()

Processes a language select list form element.

Parameters

array $element: The form element to process.

Return value

array The processed form element.

1 string reference to 'language_process_language_select'
language_element_info_alter in core/modules/language/language.module
Implements hook_element_info_alter().

File

core/modules/language/language.module, line 152
Add language handling functionality to Drupal.

Code

function language_process_language_select($element) {

  // Don't set the options if another module (translation for example) already
  // set the options.
  if (!isset($element['#options'])) {
    $element['#options'] = [];
    foreach (\Drupal::languageManager()
      ->getLanguages($element['#languages']) as $langcode => $language) {
      $element['#options'][$langcode] = $language
        ->isLocked() ? t('- @name -', [
        '@name' => $language
          ->getName(),
      ]) : $language
        ->getName();
    }
  }
  return $element;
}