You are here

function language_form_xmlsitemap_sitemap_edit_form_alter in XML sitemap 8

Same name and namespace in other branches
  1. 2.x xmlsitemap.module \language_form_xmlsitemap_sitemap_edit_form_alter()

Implements hook_form_FORM_ID_alter() for language module.

File

./xmlsitemap.module, line 1777
xmlsitemap XML sitemap

Code

function language_form_xmlsitemap_sitemap_edit_form_alter(&$form, FormStateInterface $form_state) {
  $options = [];
  $languages = \Drupal::languageManager()
    ->getLanguages();
  foreach ($languages as $language_key => $language) {
    $options[$language_key] = $language
      ->getName();
  }
  $form['context']['language'] = [
    '#type' => 'select',
    '#title' => t('Language'),
    '#options' => $options,
    '#default_value' => isset($form['#entity']->context['language']) ? $form['#entity']->context['language'] : \Drupal::languageManager()
      ->getDefaultLanguage()
      ->getId(),
    '#description' => t('Most sites should only need a sitemap for their default language since translated content is now added to the sitemap using alternate links. If you truly need a sitemap for multiple languages, it is still possible to do so.'),
  ];
}