Issue #3273986: Third option for the CKEditor 4 "Language" button: `configured` (in addition to `un` and `all`)
This is !3328 rebased for 11.x, which I believe we have to target now that 10.1.0 is released?
Merge request reports
Activity
added 1 commit
added 31 commits
-
e90bfbd5...d2cdfb19 - 18 commits from branch
project:11.x
- d2cdfb19...fe8858ae - 3 earlier commits
- d81797f7 - Issue 3273986: add enabled languages of the site as third option to language button
- fa295d48 - Issue 3273986: fix coding standard errors
- ae9e6e45 - Issue 3273986: add enabled languages of the site as third option to language button
- 8560e422 - Issue 3273986: fix coding standard errors
- 90d0f768 - Issue 3273986: change Langugage.php and test following review
- 59bbe194 - Issue 3273986: remove unused Use statements
- b1e5d7a5 - Issue 3273986: fix the test
- bbcf0490 - Issue 3273986: change according to review
- 9a3cad88 - WIP Issue 3273986: fix text direction and unit test
- 559c7811 - Issue #3273986: Fix ordering of use statements
Toggle commit list-
e90bfbd5...d2cdfb19 - 18 commits from branch
mentioned in merge request !3328
added 17 commits
-
bea98c1b...1fad1e00 - 3 commits from branch
project:11.x
- 1fad1e00...5bb9662d - 4 earlier commits
- 0bd8eb8e - Issue 3273986: fix coding standard errors
- 5ca97c12 - Issue 3273986: add enabled languages of the site as third option to language button
- 8250278d - Issue 3273986: fix coding standard errors
- 01532d48 - Issue 3273986: change Langugage.php and test following review
- eea926d4 - Issue 3273986: remove unused Use statements
- 112796b3 - Issue 3273986: fix the test
- 02b60a73 - Issue 3273986: change according to review
- 4ec5d178 - WIP Issue 3273986: fix text direction and unit test
- 621592ee - Issue #3273986: Fix ordering of use statements
- 99aae338 - Issue #3273986: Plugin and test reformat
Toggle commit list-
bea98c1b...1fad1e00 - 3 commits from branch
added 1 commit
added 1 commit
marked this merge request as draft from issue/drupal-3273986@a569645d
I think Drupal.org set this to draft because of the failure in https://www.drupal.org/pift-ci-job/2753248 which appears to be unconnected to these changes?
added 1 commit
added 1 commit
added 1 commit
- e96c44a7 - Issue 33273986: Re-order cases for language list
added 20 commits
-
05e455ed - 1 commit from branch
project:11.x
- 05e455ed...9419ff18 - 9 earlier commits
- bae0d2ef - Issue 3273986: fix the test
- b5a6e081 - Issue 3273986: change according to review
- 4ba6e84d - WIP Issue 3273986: fix text direction and unit test
- aafa1dfb - Issue #3273986: Fix ordering of use statements
- b81cfaae - Issue #3273986: Language changes to test and plugin
- 37ba6a5b - Issue #3273986: Use "Custom language" not "Māori"
- 2fd3a8ba - Issue #3273986: Refactor languageOfPartsPluginConfigHelper() out of...
- d77b8637 - fixup! Issue #3273986: Use "Custom language" not "Māori"
- e9d9aca1 - Issue #3273896: Refactor initial CKEditor configuration into helper
- 1f92f23f - Issue #3273896: Link to Languages configuration (if possible) from list description
Toggle commit list-
05e455ed - 1 commit from branch
marked this merge request as draft from issue/drupal-3273986@d77b8637
added 19 commits
- 1f92f23f...eea926d4 - 9 earlier commits
- 112796b3 - Issue 3273986: fix the test
- 02b60a73 - Issue 3273986: change according to review
- 4ec5d178 - WIP Issue 3273986: fix text direction and unit test
- 621592ee - Issue #3273986: Fix ordering of use statements
- 613459ad - Issue #3273986: Language changes to test and plugin
- a850ab6b - Issue #3273986: Use "Custom language" not "Māori"
- b6a8b31c - Issue #3273986: Refactor languageOfPartsPluginConfigHelper() out of...
- a569645d - fixup! Issue #3273986: Use "Custom language" not "Māori"
- 9a27cc9b - Issue #3273896: Refactor initial CKEditor configuration into helper
- 130c3de1 - Issue #3273896: Link to Languages configuration (if possible) from list description
Toggle commit listadded 1 commit
added 1 commit
added 20 commits
-
05e455ed - 1 commit from branch
project:11.x
- 05e455ed...6f9f3139 - 9 earlier commits
- 349195fd - Issue 3273986: fix the test
- 29c8eb3e - Issue 3273986: change according to review
- 4d6f417e - WIP Issue 3273986: fix text direction and unit test
- ee631890 - Issue #3273986: Fix ordering of use statements
- a8c91ed2 - Issue #3273986: Language changes to test and plugin
- 233fd2e4 - Issue #3273986: Use "Custom language" not "Māori"
- 18d211ef - Issue #3273986: Refactor languageOfPartsPluginConfigHelper() out of...
- 9761d7b9 - fixup! Issue #3273986: Use "Custom language" not "Māori"
- 2f9adfb7 - Issue #3273896: Refactor initial CKEditor configuration into helper
- 638480c4 - Issue #3273896: Link to Languages configuration (if possible) from list description
Toggle commit list-
05e455ed - 1 commit from branch
marked this merge request as draft from issue/drupal-3273986@9761d7b9
added 19 commits
-
08f6d675 - 1 commit from branch
project:11.x
- 08f6d675...2b3e4af8 - 8 earlier commits
- 382d1bdd - Issue 3273986: remove unused Use statements
- 3b6f1907 - Issue 3273986: fix the test
- 53873fc1 - Issue 3273986: change according to review
- 52d73ebb - WIP Issue 3273986: fix text direction and unit test
- df215993 - Issue #3273986: Fix ordering of use statements
- 47f52d96 - Issue #3273986: Language changes to test and plugin
- 889cf10d - Issue #3273986: Use "Custom language" not "Māori"
- 75c1c064 - Issue #3273986: Refactor languageOfPartsPluginConfigHelper() out of...
- dc0b080e - Issue #3273896: Refactor initial CKEditor configuration into helper
- 39353cde - Issue #3273896: Link to Languages configuration (if possible) from list description
Toggle commit list-
08f6d675 - 1 commit from branch
added 1 commit
added 1 commit
added 1 commit
44 45 /** 46 * Language constructor. 47 * 48 * @param array $configuration 49 * A configuration array containing information about the plugin instance. 50 * @param string $plugin_id 51 * The plugin_id for the plugin instance. 52 * @param \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition $plugin_definition 53 * The plugin implementation definition. 54 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager 55 * The language manager. 56 * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider 57 * The route provider. 58 */ 59 public function __construct(array $configuration, string $plugin_id, CKEditor5PluginDefinition $plugin_definition, LanguageManagerInterface $language_manager, RouteProviderInterface $route_provider) { changed this line in version 21 of the diff
85 $languages = []; 86 foreach ($configured_languages as $language) { 87 $languages[$language->getId()] = [ 88 $language->getName(), 89 '', 90 $language->getDirection(), 91 ]; 92 } 93 break; 94 95 case 'all': 96 $languages = LanguageManager::getStandardLanguageList(); 97 break; 98 99 case 'un': 100 default: changed this line in version 21 of the diff
146 $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()]); 147 } 148 else { 149 $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); 150 } 151 64 152 $form['language_list'] = [ 65 153 '#title' => $this->t('Language list'), 66 154 '#title_display' => 'invisible', 67 155 '#type' => 'select', 68 156 '#options' => [ 69 'un' => $this->t("United Nations' official languages"), 70 'all' => $this->t('All @count languages', ['@count' => count($predefined_languages)]), 157 'un' => $this->t("United Nations' official languages (@count)", ['@count' => $united_nations]), 158 'all' => $this->t('Drupal predefined languages (@count)', ['@count' => $predefined]), 159 'site_configured' => $this->t("Site configured languages (@count)", ['@count' => $configured]), - Comment on lines +158 to +159
158 'all' => $this->t('Drupal predefined languages (@count)', ['@count' => $predefined]), 159 'site_configured' => $this->t("Site configured languages (@count)", ['@count' => $configured]), 158 'all' => $this->t('Drupal-predefined languages (@count)', ['@count' => $predefined]), 159 'site_configured' => $this->t("Site-configured languages (@count)", ['@count' => $configured]), I think this would be the correct grammar?
changed this line in version 21 of the diff
71 $languages[$language->getId()] = [ 72 $language->getName(), 73 '', 74 $language->getDirection(), 75 ]; 76 } 77 break; 78 79 case 'all': 80 $languages = LanguageManager::getStandardLanguageList(); 81 break; 82 83 case 'un': 84 default: 85 $languages = LanguageManager::getUnitedNationsLanguageList(); 86 } - Comment on lines +66 to +86
I'd still like to see the
default
disappear. To fix the PHPStan complaint, we can do this:66 switch ($this->configuration['language_list']) { 67 case 'site_configured': 68 $configured_languages = $this->languageManager->getLanguages(); 69 $languages = []; 70 foreach ($configured_languages as $language) { 71 $languages[$language->getId()] = [ 72 $language->getName(), 73 '', 74 $language->getDirection(), 75 ]; 76 } 77 break; 78 79 case 'all': 80 $languages = LanguageManager::getStandardLanguageList(); 81 break; 82 83 case 'un': 84 default: 85 $languages = LanguageManager::getUnitedNationsLanguageList(); 86 } 66 $languages = NULL; 67 switch ($this->configuration['language_list']) { 68 case 'site_configured': 69 $configured_languages = $this->languageManager->getLanguages(); 70 $languages = []; 71 foreach ($configured_languages as $language) { 72 $languages[$language->getId()] = [ 73 $language->getName(), 74 '', 75 $language->getDirection(), 76 ]; 77 } 78 break; 79 80 case 'all': 81 $languages = LanguageManager::getStandardLanguageList(); 82 break; 83 84 case 'un': 85 $languages = LanguageManager::getUnitedNationsLanguageList(); 86 }
218 220 $page = $this->getSession()->getPage(); 219 221 $assert_session = $this->assertSession(); 220 222 223 $this->languageOfPartsPluginInitialConfigurationHelper($page, $assert_session); 224 225 // Test for "United Nations' official languages" option. 226 $languages = LanguageManager::getUnitedNationsLanguageList(); 227 $this->languageOfPartsPluginConfigureLanguageListHelper($page, $assert_session, 'un'); 228 $this->languageOfPartsPluginTestHelper($page, $assert_session, $languages); 229 230 // Test for "Drupal predefined languages" option. 231 $languages = LanguageManager::getStandardLanguageList(); 232 $this->languageOfPartsPluginConfigureLanguageListHelper($page, $assert_session, 'all'); 233 $this->languageOfPartsPluginTestHelper($page, $assert_session, $languages); 234 235 // Test for "Site configured languages" option. changed this line in version 23 of the diff
59 ); 60 } 61 25 62 /** 26 63 * {@inheritdoc} 27 64 */ 28 65 public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor): array { 29 $predefined_languages = $this->configuration['language_list'] === 'all' ? 30 LanguageManager::getStandardLanguageList() : 31 LanguageManager::getUnitedNationsLanguageList(); 66 $languages = NULL; 67 switch ($this->configuration['language_list']) { 68 case 'site_configured': 69 $configured_languages = $this->languageManager->getLanguages(); 70 $languages = []; 71 foreach ($configured_languages as $language) { I concur that the current page language could be redundant to assign where the HTML document has a language attribute assigned, and Declaring language in HTML suggests to only assign languages which are not the default language of the document. However, we should consider the cases of nesting of languages (eg an English word in a Māori sentence in an English document), that documents (nodes) may have undefined languages, and that Drupal has multiple layers of editing (embeds, blocks, pages, nodes, etc).
While that might be an interesting technical challenge, I don't think the diversion of implementing it should stand in the way of delivering this useful functionality, which Drupal currently does not support. There's a bug here that today prevents useful functionality for sites in languages not well-supported by Drupal.
Let's fix that, and consider that in a follow up issue if you wish to do so?
Edited by Chris Burgess