fix: #3637712 Use the page language for CKEditor 5 content in Layout Builder

Issue: https://www.drupal.org/i/3637712

Layout Builder block forms are admin routes. With the interface language following the admin language (English admin on an Arabic site), CKEditor 5 used the UI language for content, so Arabic was edited as lang="en" dir="ltr".

A new final class src/Hook/EditorLanguageHooks.php implements #[Hook('editor_js_settings_alter')] and sets editorSettings.language.content to the page's URL language on layout_builder.* routes, mapped through Drupal\ckeditor5\LanguageMapper. The language manager, route match and an optional ?LanguageMapper are autowired, and the hook does nothing when CKEditor 5 is absent. The procedural hook is removed from varbase_layout_builder.module. The toolbar stays in the admin language.

Tested on Drupal 11.4.12 (Varbase 10.1.x-dev): invokeAllWith('editor_js_settings_alter') lists EditorLanguageHooks::editorJsSettingsAlter once, no procedural duplicate. The Arabic add-block form sends {ui: en, content: ar}, English sends {ui: en, content: en}.

Remaining tasks

  • Pipeline 1044446 green. Locally phpcs passes; phpstan (112) and cspell (3) report the same counts as untouched 10.2.x, none in the changed files.

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading
Loading