fix(Translation): #3591976 Editor edits the site default language instead of...
The Canvas UI requests the layout API on a prefix-free URL, which negotiates to the site default language. The editor therefore loaded whichever translation the site default pointed at, not the page's source translation.
CanvasRouteOptionsEventSubscriber now redirects a layout request that names no language to the entity's source translation. A language selected by the URL, session or domain is still honored, as is the canvas_preview_langcode hint. Redirecting rather than swapping the entity in the controller keeps the whole request in one language, so the entity form, the rendered preview and the URL alias agree.
LanguageSelect.tsx reads the original language from translations.available[0] instead of isDefault, for the trigger label and for editor-vs-preview routing.
Testing
- Create a Canvas page in
enwith a component, add annltranslation, then change the site default language tonl. -
/canvas/editor/canvas_page/Nshows the English source: form fields, component inputs, rendered preview and title. - The language dropdown opens the editor for the source language and a preview for the translation.
-
?canvas_preview_langcode=nlstill serves the Dutch translation. -
/fr/canvas/api/v0/layout/...without a hint still serves French. - A page whose source is the site default is not redirected.
-
composer run phpunit -- tests/src/Functional/TranslationTest.phppasses (18 tests, 481 assertions), includingtestLayoutApiServesSourceTranslation.
AI usage
Root cause analysis, the patch and the test runs were done with Claude Opus 5 in Claude Code, reviewed and verified by me in a local DDEV environment.