wagtail-localize
wagtail-localize copied to clipboard
Add Management Command for Copying and Translating Pages Across Locales
Summary
This PR introduces a new Django management command to automate the process of copying Wagtail pages from a source locale to all other locales and applying machine translation where applicable. The command allows exclusions of specific models and supports a dry-run mode for testing.
Command Usage
python manage.py copy_and_translate_pages <language_code> [<exclude_model1> <exclude_model2> ...] [--dry-run]
<language_code>: The source language code from which pages should be copied.<exclude_model1> <exclude_model2> ...: Optional list of model names to exclude from translation.--dry-run: Runs the command without making any actual changes (useful for testing).
Example run
python manage.py copy_and_translate_pages en BlogPost EventPage
or for testing
python manage.py copy_and_translate_pages en BlogPost EventPage --dry-run
Thank, would be good to add some tests. I hope to get some time next week to review this.
off the top of my head, I'd like to make the exclude list a param --exclude ... rather than exclude_model, exclude_model2
:warning: Please install the to ensure uploads and comments are reliably processed by Codecov.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 93.08%. Comparing base (
a22118b) to head (98ed818).
Additional details and impacted files
@@ Coverage Diff @@
## main #852 +/- ##
=======================================
Coverage 93.08% 93.08%
=======================================
Files 47 47
Lines 4238 4238
Branches 549 549
=======================================
Hits 3945 3945
Misses 176 176
Partials 117 117
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@zerolab I've added some tests. Let me know if you'd like more.
I also renamed exclude_models to --exclude