class Language

Same name in this branch
  1. 9 core/modules/language/src/Plugin/migrate/source/Language.php \Drupal\language\Plugin\migrate\source\Language
  2. 9 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language
  3. 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language
  4. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language
  5. 9 core/lib/Drupal/Core/Language/Language.php \Drupal\Core\Language\Language
Same name in other branches
  1. 8.9.x core/modules/language/src/Plugin/migrate/source/Language.php \Drupal\language\Plugin\migrate\source\Language
  2. 8.9.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language
  3. 8.9.x core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php \Drupal\ckeditor\Plugin\CKEditorPlugin\Language
  4. 8.9.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language
  5. 8.9.x core/lib/Drupal/Core/Language/Language.php \Drupal\Core\Language\Language
  6. 10 core/modules/language/src/Plugin/migrate/source/Language.php \Drupal\language\Plugin\migrate\source\Language
  7. 10 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language
  8. 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language
  9. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language
  10. 10 core/lib/Drupal/Core/Language/Language.php \Drupal\Core\Language\Language
  11. 11.x core/modules/language/src/Plugin/migrate/source/Language.php \Drupal\language\Plugin\migrate\source\Language
  12. 11.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language
  13. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language
  14. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language
  15. 11.x core/lib/Drupal/Core/Language/Language.php \Drupal\Core\Language\Language

Defines the "language" plugin.

Plugin annotation


@CKEditorPlugin(
  id = "language",
  label = @Translation("Language")
)

Hierarchy

Expanded class hierarchy of Language

1 file declares its use of Language
LanguageTest.php in core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php
393 string references to 'Language'
AccountSettingsForm::buildForm in core/modules/user/src/AccountSettingsForm.php
Form constructor.
block.block.umami_languageswitcher.yml in core/profiles/demo_umami/config/install/block.block.umami_languageswitcher.yml
core/profiles/demo_umami/config/install/block.block.umami_languageswitcher.yml
BlockContentTypeForm::form in core/modules/block_content/src/BlockContentTypeForm.php
Gets the actual form array to be built.
BlockForm::buildVisibilityInterface in core/modules/block/src/BlockForm.php
Helper function for building the visibility UI form.
BlockLanguageTest::testLanguageBlockVisibilityLanguageDelete in core/modules/block/tests/src/Functional/BlockLanguageTest.php
Tests if the visibility settings are removed if the language is deleted.

... See full list

File

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

Namespace

Drupal\ckeditor\Plugin\CKEditorPlugin
View source
class Language extends CKEditorPluginBase implements CKEditorPluginConfigurableInterface, CKEditorPluginCssInterface {
    
    /**
     * {@inheritdoc}
     */
    public function isInternal() {
        return TRUE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getFile() {
        // This plugin is already part of Drupal core's CKEditor build.
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getLibraries(Editor $editor) {
        return [
            'ckeditor/drupal.ckeditor.plugins.language',
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getConfig(Editor $editor) {
        $language_list = [];
        $config = [
            'language_list' => 'un',
        ];
        $settings = $editor->getSettings();
        if (isset($settings['plugins']['language'])) {
            $config = $settings['plugins']['language'];
        }
        $predefined_languages = $config['language_list'] === 'all' ? LanguageManager::getStandardLanguageList() : LanguageManager::getUnitedNationsLanguageList();
        // Generate the language_list setting as expected by the CKEditor Language
        // plugin, but key the values by the full language name so that we can sort
        // them later on.
        foreach ($predefined_languages as $langcode => $language) {
            $english_name = $language[0];
            $direction = empty($language[2]) ? NULL : $language[2];
            if ($direction === LanguageInterface::DIRECTION_RTL) {
                $language_list[$english_name] = $langcode . ':' . $english_name . ':rtl';
            }
            else {
                $language_list[$english_name] = $langcode . ':' . $english_name;
            }
        }
        // Sort on full language name.
        ksort($language_list);
        $config = [
            'language_list' => array_values($language_list),
        ];
        return $config;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getButtons() {
        $label = $this->t('Language');
        return [
            'Language' => [
                'label' => $label,
                'image_alternative' => [
                    '#type' => 'inline_template',
                    '#template' => '<a href="#" class="cke-icon-only" role="button" title="{{ label }}" aria-label="{{ label }}"><span class="cke_button_icon cke_button__language_icon">{{ label }}</span></a>',
                    '#context' => [
                        'label' => $label,
                    ],
                ],
            ],
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCssFiles(Editor $editor) {
        return [
            $this->getModulePath('ckeditor') . '/css/plugins/language/ckeditor.language.css',
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
CKEditorPluginBase::$moduleList protected property The module list service.
CKEditorPluginBase::getDependencies public function Returns a list of plugins this plugin requires. Overrides CKEditorPluginInterface::getDependencies 1
CKEditorPluginBase::getModuleList protected function Gets the module list service.
CKEditorPluginBase::getModulePath protected function Gets the Drupal-root relative installation directory of a module.
Language::getButtons public function Returns the buttons that this plugin provides, along with metadata. Overrides CKEditorPluginButtonsInterface::getButtons
Language::getConfig public function Returns the additions to CKEDITOR.config for a specific CKEditor instance. Overrides CKEditorPluginInterface::getConfig
Language::getCssFiles public function Retrieves enabled plugins&#039; iframe instance CSS files. Overrides CKEditorPluginCssInterface::getCssFiles
Language::getFile public function Returns the Drupal root-relative file path to the plugin JavaScript file. Overrides CKEditorPluginInterface::getFile
Language::getLibraries public function Returns a list of libraries this plugin requires. Overrides CKEditorPluginBase::getLibraries
Language::isInternal public function Indicates if this plugin is part of the optimized CKEditor build. Overrides CKEditorPluginBase::isInternal
Language::settingsForm public function Returns a settings form to configure this CKEditor plugin. Overrides CKEditorPluginConfigurableInterface::settingsForm
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2

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