function Language::buildConfigurationForm

Same name in this branch
  1. 11.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
Same name in other branches
  1. 9 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
  2. 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()
  3. 8.9.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
  4. 10 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
  5. 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()

See also

editor_image_upload_settings_form()

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php, line 116

Class

Language
CKEditor 5 Language plugin.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $configured = count($this->languageManager
        ->getLanguages());
    $predefined = count(LanguageManager::getStandardLanguageList());
    $united_nations = count(LanguageManager::getUnitedNationsLanguageList());
    $language_list_description_args = [
        ':united-nations-official' => 'https://www.un.org/en/sections/about-un/official-languages',
        '@count_predefined' => $predefined,
        '@count_united_nations' => $united_nations,
        '@count_configured' => $configured,
    ];
    // If Language is enabled, link to the configuration route.
    if ($this->routeProvider
        ->getRoutesByNames([
        'entity.configurable_language.collection',
    ])) {
        $language_list_description = $this->t('The list of languages in the CKEditor "Language" dropdown can present the <a href=":united-nations-official">@count_united_nations official languages of the UN</a>, all @count_predefined languages predefined in Drupal, or the <a href=":admin-configure-languages">@count_configured languages configured for this site</a>.', $language_list_description_args + [
            ':admin-configure-languages' => Url::fromRoute('entity.configurable_language.collection')->toString(),
        ]);
    }
    else {
        $language_list_description = $this->t('The list of languages in the CKEditor "Language" dropdown can present the <a href=":united-nations-official">@count_united_nations official languages of the UN</a>, all @count_predefined languages predefined in Drupal, or the languages configured for this site.', $language_list_description_args);
    }
    $form['language_list'] = [
        '#title' => $this->t('Language list'),
        '#title_display' => 'invisible',
        '#type' => 'select',
        '#options' => [
            'un' => $this->t("United Nations' official languages (@count)", [
                '@count' => $united_nations,
            ]),
            'all' => $this->t('Drupal predefined languages (@count)', [
                '@count' => $predefined,
            ]),
            'site_configured' => $this->t("Site-configured languages (@count)", [
                '@count' => $configured,
            ]),
        ],
        '#default_value' => $this->configuration['language_list'],
        '#description' => $language_list_description,
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.