function Language::settingsForm

Same name in other branches
  1. 8.9.x core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php \Drupal\ckeditor\Plugin\CKEditorPlugin\Language::settingsForm()

Overrides CKEditorPluginConfigurableInterface::settingsForm

File

core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php, line 102

Class

Language
Defines the "language" plugin.

Namespace

Drupal\ckeditor\Plugin\CKEditorPlugin

Code

public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
    // Defaults.
    $config = [
        'language_list' => 'un',
    ];
    $settings = $editor->getSettings();
    if (isset($settings['plugins']['language'])) {
        $config = $settings['plugins']['language'];
    }
    $predefined_languages = LanguageManager::getStandardLanguageList();
    $form['language_list'] = [
        '#title' => $this->t('Language list'),
        '#title_display' => 'invisible',
        '#type' => 'select',
        '#options' => [
            'un' => $this->t("United Nations' official languages"),
            'all' => $this->t('All @count languages', [
                '@count' => count($predefined_languages),
            ]),
        ],
        '#default_value' => $config['language_list'],
        '#description' => $this->t('The list of languages to show in the language dropdown. The basic list will only show the <a href=":url">six official languages of the UN</a>. The extended list will show all @count languages that are available in Drupal.', [
            ':url' => 'https://www.un.org/en/sections/about-un/official-languages',
            '@count' => count($predefined_languages),
        ]),
        '#attached' => [
            'library' => [
                'ckeditor/drupal.ckeditor.language.admin',
            ],
        ],
    ];
    return $form;
}

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