Skip to content

Conversation

@nickAalst
Copy link

@nickAalst nickAalst commented Feb 7, 2025

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

@zerolab
Copy link
Collaborator

zerolab commented Feb 7, 2025

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

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

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           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…or argument parsing by renaming `exclude_models` to `--exclude`.
@nickAalst
Copy link
Author

@zerolab I've added some tests. Let me know if you'd like more.

I also renamed exclude_models to --exclude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants