class Language in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/Language/Language.php \Drupal\Core\Language\Language
- 9 core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php \Drupal\ckeditor\Plugin\CKEditorPlugin\Language
- 9 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language
- 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language
- 9 core/modules/language/src/Plugin/migrate/source/Language.php \Drupal\language\Plugin\migrate\source\Language
Same name and namespace in other branches
- 8 core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php \Drupal\ckeditor\Plugin\CKEditorPlugin\Language
- 10 core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php \Drupal\ckeditor\Plugin\CKEditorPlugin\Language
Defines the "language" plugin.
Plugin annotation
@CKEditorPlugin(
id = "language",
label = @Translation("Language")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\ckeditor\CKEditorPluginBase implements CKEditorPluginButtonsInterface, CKEditorPluginInterface
- class \Drupal\ckeditor\Plugin\CKEditorPlugin\Language implements CKEditorPluginConfigurableInterface, CKEditorPluginCssInterface
- class \Drupal\ckeditor\CKEditorPluginBase implements CKEditorPluginButtonsInterface, CKEditorPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
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
43 string references to 'Language'
- ckeditor.schema.yml in core/
modules/ ckeditor/ config/ schema/ ckeditor.schema.yml - core/modules/ckeditor/config/schema/ckeditor.schema.yml
- ConfigTestForm::form in core/
modules/ config/ tests/ config_test/ src/ ConfigTestForm.php - Gets the actual form array to be built.
- ConfigTranslationController::itemPage in core/
modules/ config_translation/ src/ Controller/ ConfigTranslationController.php - Language translations overview page for a configuration name.
- ContentTranslationController::overview in core/
modules/ content_translation/ src/ Controller/ ContentTranslationController.php - Builds the translations overview page.
- DateFormatFormBase::form in core/
modules/ system/ src/ Form/ DateFormatFormBase.php - Gets the actual form array to be built.
File
- core/
modules/ ckeditor/ src/ Plugin/ CKEditorPlugin/ Language.php, line 21
Namespace
Drupal\ckeditor\Plugin\CKEditorPluginView 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>',
],
],
];
}
/**
* {@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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CKEditorPluginBase:: |
protected | property | The module list service. | |
CKEditorPluginBase:: |
public | function |
Returns a list of plugins this plugin requires. Overrides CKEditorPluginInterface:: |
1 |
CKEditorPluginBase:: |
protected | function | Gets the module list service. | |
CKEditorPluginBase:: |
protected | function | Gets the Drupal-root relative installation directory of a module. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
Language:: |
public | function |
Returns the buttons that this plugin provides, along with metadata. Overrides CKEditorPluginButtonsInterface:: |
|
Language:: |
public | function |
Returns the additions to CKEDITOR.config for a specific CKEditor instance. Overrides CKEditorPluginInterface:: |
|
Language:: |
public | function |
Retrieves enabled plugins' iframe instance CSS files. Overrides CKEditorPluginCssInterface:: |
|
Language:: |
public | function |
Returns the Drupal root-relative file path to the plugin JavaScript file. Overrides CKEditorPluginInterface:: |
|
Language:: |
public | function |
Returns a list of libraries this plugin requires. Overrides CKEditorPluginBase:: |
|
Language:: |
public | function |
Indicates if this plugin is part of the optimized CKEditor build. Overrides CKEditorPluginBase:: |
|
Language:: |
public | function |
Returns a settings form to configure this CKEditor plugin. Overrides CKEditorPluginConfigurableInterface:: |
|
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 98 |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |