Skip to content

Use Signals To Support Extending Segment Processing#900

Open
dchukhin wants to merge 2 commits intowagtail:mainfrom
dchukhin:support-extendable-segment-processing
Open

Use Signals To Support Extending Segment Processing#900
dchukhin wants to merge 2 commits intowagtail:mainfrom
dchukhin:support-extendable-segment-processing

Conversation

@dchukhin
Copy link
Copy Markdown

Details

This pull request aims to make it easier to extend wagtail-localize segment processing in other libraries by adding signals that other libraries can connect to:

  • process_string_segment - sent for each string segment during TranslationSource._get_segments_for_translation(). If a receiver returns a non-null StringValue, then that value is used (returning None keeps the original value).
  • post_source_update - sent after TranslationSource.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-localize behavior.

Sending signals allows other libraries to easily
extend segment processing behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant