Problem/Motivation
Layout Builder block forms (layout_builder.add_block, layout_builder.update_block, ...) are admin routes. A site that detects the interface language from "Account administration pages" runs them in the editor's admin language, for example English on an Arabic page.
CKEditor 5 only sets language.ui, and its content language defaults to that. The editable is lang="en" dir="ltr" inside an RTL page, so Arabic lists, numbers and alignment sit on the wrong side and do not match the front end.
Steps to reproduce
- Install Varbase and add Arabic.
- At
/admin/config/regional/language/detection, enable "Account administration pages" above URL. - Set your user's administration pages language to English.
- Open
/ar/node/NID/layout, Add block, Create content block, Rich text. - Type a bulleted and a numbered list in Arabic. Expected: right to left, markers on the right. Actual: left to right, markers on the left.
Proposed resolution
Implement hook_editor_js_settings_alter() on layout_builder.* routes and set each CKEditor 5 format's language.content to the page's URL language, mapped to a CKEditor langcode. The toolbar stays in the admin language; the content follows the page. Guarded so it does nothing without CKEditor 5, and procedural on both branches.
10.2.x(Varbase 10.1.x): usesDrupal\ckeditor5\LanguageMapper.10.0.x(Varbase 9.2.x): also falls back to_ckeditor5_get_langcode_mapping(), since Drupal 10.6 has no LanguageMapper.
Testing
- Manually tested on Drupal 11.4.12: the
10.0.xchange on Varbase 9.2.x (Varbase Layout Builder 10.0.74), the10.2.xchange on Varbase 10.1.x-dev. - On
/ar/node/NID/layoutwith an English admin language: the editable islang="ar" dir="rtl", CKEditor UI en and content ar, toolbar stays LTR, list markers on the right. Before: en, LTR, markers on the left. - English pages stay en and LTR.
- Not tested on Drupal 10.6.
Remaining tasks
- ✅ File an issue
- ✅ Addition/Change/Update/Fix
- ❌ Testing to ensure no regression
- ➖ Automated unit/functional testing coverage
- ➖ Developer Documentation support
- ➖ User Guide Documentation support
- ➖ UX/UI designer responsibilities
- ➖ Accessibility and Readability
- ❌ Reviewed by a human
- ❌ Code review by maintainers
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review with the product owner
- ❌ Update Release Notes
- ❌ Release
User interface changes
- CKEditor 5 in Layout Builder block forms edits content in the page's language and direction.
API changes
- N/A
Data model changes
- N/A
Release notes snippet
- N/A
AI-Generated: Yes
Issue fork varbase_layout_builder-3637712
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
Comment #4
rajab natshahMerge requests, one per branch:
Both pipelines are green and match their target branches job for job. Ready for review.
AI-Generated: Yes
Comment #5
rajab natshahBefore and after screenshots and a short demo video for the fix in MR !119 (10.2.x) and MR !120 (10.0.x).
Varbase 9.2.x (10.0.x branch)
Rich text block dialog on the Arabic page. Before: content is left to right, bullets and numbers on the left.
After: right to left, toolbar still English.
Editor close-up. Before:
lang="en" dir="ltr".After:
lang="ar" dir="rtl", markers on the right.Varbase 10.1 (~10.1.0, 10.2.x branch)
Dialog before.
Dialog after.
Close-up before.
Close-up after.
Varbase 10.1.x-dev
Dialog before.
Dialog after.
Demo video
11-ckeditor5-content-language-demo.mp4 (1 min 25 s, narrated): walkthrough on Varbase 9.2.x of the Arabic page, the editor before, then after.
The screenshots and video were recorded with the same hook code running from a local test module before it was moved into varbase_layout_builder; the behaviour is identical with the MR applied.
AI-Generated: Yes
Comment #6
rajab natshahBoth MRs now use an OOP
#[Hook]class,EditorLanguageHooks. On 10.0.x a#[LegacyHook]procedural shim delegates to it for Drupal 10.6; Drupal 11.1+ runs only the OOP hook.Not yet runtime-tested on Drupal 10.6.
AI-Generated: Yes