Problem/Motivation

At the moment there is two predefined language lists available to choose from:

  1. United Nations' official languages
  2. All languages
  3. >

In our use case we only need 2 languages to be available in the list - English and Māori (which is not in the standard language list but this is separate issue).

Māori is not in the UN list so that doesn't fit.

We could use "All languages" as a work around (if Māori was there ) but UX if that is horrible.

Proposed resolution

Provide a way to create a custom, site specific, language list. "Language" CKEditor plugin configuration form could be changed to have third option - Custom, selecting which user will be presented with the multiselect list of all languages from which they can choose.

Remaining tasks

  1. agree on approach
  2. consider UX
  3. code
  4. review
  5. test
  6. commit

User interface changes

TBC

API changes

None

Data model changes

None

Release notes snippet

TBD

Issue fork drupal-3192734

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

RoSk0 created an issue. See original summary.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jwaxo made their first commit to this issue’s fork.

jwaxo’s picture

By complete coincidence I was working on this exact issue last Friday. While it does not solve your exact request, it does allow for customizing of the languages dropdown via the configurable Drupal languages list, with a new option in ckeditor to pull languages from the internal system. https://git.drupalcode.org/project/drupal/-/merge_requests/1665

marcvangend’s picture

I agree, a configurable list is the only solution that makes sense.

In 14 years of Drupal development I have never had to build a site that supports exactly these 6 official UN languages. To even offer that option seems rather arbitrary. IMHO it should be removed, but at least it should not be the default.

At the risk of stretching the scope of this issue, I would propose offering 3 options:
- All enabled languages [default]
- All languages
- Selected languages
The third option should reveal an additional form element to select languages.

liquidcms’s picture

@jwaxo, i am sure years until this would ever get merged, so would a patch file not be more useful here? Do you know if possible to create a patch file from gitlab MR? Of course i can manually make the edits and then create a patch.. :(

liquidcms’s picture

found it.

liquidcms’s picture

Tested the patch on 9.2.11 and works as expected. Thanks for this; hopefully gets merged to core.

marcvangend’s picture

Status: Active » Needs work
Issue tags: +Needs tests

Thanks for the patch. To get it in core, it needs tests.

eelkeblok’s picture

@liquidcms Creating a patch from a a merge request is surprisingly easy. See https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa.... Do make sure you save the patch in your local project and not use the URL directly; you don't want any arbitrary pushes changing the actual patch applied to your project.

ifrik’s picture

The language button now includes a drop-down for "enabled languages".
If a custom language has been added to the site, then this also shows up in the list of enabled languages.

This would also be relevant for the CKEditor 5 module.

wim leers’s picture

Sibling CKEditor 5 issue: #3273986: Third option for the CKEditor 5 "Language" button: `site_configured` (in addition to `un` and `all`).

Either we should expand the scope of this issue to also do the work for CKEditor 5, or that issue needs to be postponed on this one, because this will require changes in the CKEditor 4 to 5 upgrade path.

Patch review

Patch looks great, just one nit:

+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php
@@ -53,9 +53,28 @@ public function getConfig(Editor $editor) {
+        $predefined_languages = LanguageManager::getStandardLanguageList();
+
+        break;
...
+        }
+
+        break;

Nit: no blank line before the break;.

wim leers’s picture

Title: Allow language list to be configurable » Third option for the CKEditor 4 "Language" button: `enabled` (in addition to `un` and `all`)
ifrik’s picture

Status: Needs work » Needs review
StatusFileSize
new3.53 KB

I've changed the wording for the third option and the description in the same way as in the related issue for CKEditor5 #3273986: Third option for the CKEditor 5 "Language" button: `site_configured` (in addition to `un` and `all`), fixed the coding standard errors, and updated the test.

Status: Needs review » Needs work

The last submitted patch, 16: add_available_langs_as_ck_langs-3192734-16.patch, failed testing. View results

ifrik’s picture

Status: Needs work » Needs review
StatusFileSize
new2.9 KB

I'm adding a new patch to just change the wording, but it still needs the test required in #11

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » CKEditor 4 - WYSIWYG HTML editor
Version: 9.5.x-dev » 1.0.x-dev
Component: ckeditor.module » Code

CKEditor has been removed from core, CKEditor 4 is removed from Drupal Core in 10.0.0

xurizaemon’s picture

There's been progress on the CKEditor 5 issue at #3273986: Third option for the CKEditor 5 "Language" button: `site_configured` (in addition to `un` and `all`) and there may be improvements from that issue to introduce here to keep them in parallel.

In that issue, I felt that "enabled" was unclear (enabled how - per the input format settings, the site's configured languages, or some other method?), and substituted "enabled" for "site_configured" so that an option like the one suggested in #7 here and #3375157: [upstream] CKEditor 5 language selector cannot be scrolled if "All NNN languages" option selected could use another term like "format_plugin" and the values would be meaningful.