-
-
Notifications
You must be signed in to change notification settings - Fork 587
[6.x] Add hooks for localization switching #12333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Conversation
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
@tao
tao
changed the title
(削除) Feature/multisite hooks (削除ここまで)
(追記) Add hooks for localization switching (追記ここまで)
Sep 6, 2025
@tao
tao
changed the title
(削除) Add hooks for localization switching (削除ここまで)
(追記) [6.x] Add hooks for localization switching (追記ここまで)
Sep 6, 2025
@tao
tao
force-pushed
the
feature/multisite-hooks
branch
from
October 6, 2025 14:39
2a63d61
to
6f9e508
Compare
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.selecting
localization.selected
localization.creating
localization.created
The
createLocalization
andeditLocalization
functions both use the sameeditLocalizationRequest
axios request, but I have ensured that only the correct events are fired in either scenario.The
localization.selecting
andlocalization.creating
hooks provides the newly selected locale in the payload:While the
localization.selected
andlocalization.created
hooks 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.created
orlocalization.creating
hooks 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.