[6.x] Add hooks for localization switching - #12333
Closed
tao wants to merge 1 commit into
Closed
Conversation
tao
force-pushed
the
feature/multisite-hooks
branch
from
October 6, 2025 14:39
2a63d61 to
6f9e508
Compare
Member
Member
|
Closing this under the assumption that #13024 is enough to solve your issue. We can reopen if need be though. |
Contributor
Author
|
It's amazing! I'm so happy that this has been implemented finally. #13024 works great except for the text direction of the full-screen markdown window... but I'll see if I can make a pull-request for that using the same solution. |
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.
As discussed in #12328, and potentially related to the collaboration plugin issue #90 it would be helpful to have hooks available when the sites are selected or created in the multisite selector.
This pull requests adds 4 new hooks:
localization.selectinglocalization.selectedlocalization.creatinglocalization.createdThe
createLocalizationandeditLocalizationfunctions both use the sameeditLocalizationRequestaxios request, but I have ensured that only the correct events are fired in either scenario.The
localization.selectingandlocalization.creatinghooks provides the newly selected locale in the payload:While the
localization.selectedandlocalization.createdhooks provide the localization and the response from the editLocalization request, which includes data about the current entry:At the moment, only the entry values are returned in the payload, but if some other values are necessary then they can be included from the response object... I don't specifically need the values for my use-case by perhaps in the future (or for the collab plugin bug) it would be useful to have the entry ID available when creating a new broadcast channel.
These events allow me to detect when a language changes and update the text direction of the Control Panel
It would be nice if we could use the
localization.createdorlocalization.creatinghooks to update values automatically, like allowing for the automatic translation of some fields with an API and resolve() back the new entry data, but I think that might be better to handle on the Laravel side instead of the frontend?I did examine the frontend tests folder and I couldn't see any tests for specific hooks, so I wasn't sure how to go about including those.