Repository navigation
fix(i18n): workbench preview renders the target locale on Sylius hosts - #61
Merged
Merged
Conversation
Sylius's RequestLocaleSetter (kernel.request, priority 4) runs after PreviewLocaleListener and puts the channel locale back, so the whole preview pane rendered the source text; only a just-edited block, rendered through the route that passes the locale explicitly, showed its translation. The listener now also pins the locale on the main request, and RequestRenderLocaleResolver reads it before the request locale. The page and field machine-translation buttons show a spinner and are disabled while the provider runs, so a run cannot be started twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a Sylius host (Bocklip), the translation workbench had two problems:
Cause of (1)
PreviewLocaleListener(kernel.request, priority 15) sets the request locale to the workbench locale. Sylius'sRequestLocaleSetter(priority 4) runs after it and sets the channel locale back, so the whole preview page renders in the source language. Editing a field refreshes only that block, through the render route that takes the locale as an explicit parameter, which is why an edited field showed its translation.Changes
PreviewLocaleListeneralso stores the locale in a request attribute (PreviewLocaleListener::ATTRIBUTE).RequestRenderLocaleResolverreads that attribute on the main request before the request locale, so sub-requests are covered too. The host's own strings (header, menu) stay in the host's locale; only the content follows the workbench. The guards (cb_preview=1plus the session marker) are unchanged.aria-busy) until the provider answers. The page button stays busy until the page reloads, and becomes clickable again if the call fails.docs/internals/i18n.md#the-preview-pane; the i18n CHANGELOG has an entry under Unreleased.Tests
translation-workbenchandimport-export-i18n: 9 specs pass. PHPStan and php-cs-fixer are clean.The main sandbox does not use Sylius core, so no e2e test covers the Sylius case; the resolver's unit test covers it.
🤖 Generated with Claude Code