Use Signals To Support Extending Segment Processing#900
Open
dchukhin wants to merge 2 commits intowagtail:mainfrom
Open
Use Signals To Support Extending Segment Processing#900dchukhin wants to merge 2 commits intowagtail:mainfrom
dchukhin wants to merge 2 commits intowagtail:mainfrom
Conversation
Sending signals allows other libraries to easily extend segment processing behavior.
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.
Details
This pull request aims to make it easier to extend
wagtail-localizesegment processing in other libraries by adding signals that other libraries can connect to:process_string_segment- sent for each string segment duringTranslationSource._get_segments_for_translation(). If a receiver returns a non-nullStringValue, then that value is used (returningNonekeeps the original value).post_source_update- sent afterTranslationSource.update_from_db()completes. Useful for post-processing (e.g.,migrating metadata) after source content has been synced.
Tests for signals are provided in
wagtail_localize/tests/test_signals.py.Context
Other packages that want to modify how string segments are processed during translation currently have no clean way to do so. Sending signals provides an easy way to extend the processing from other libraries without changing
wagtail-localizebehavior.