wagtail-localize icon indicating copy to clipboard operation
wagtail-localize copied to clipboard

Add Management Command for Copying and Translating Pages Across Locales

Open nickAalst opened this issue 9 months ago • 3 comments

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

nickAalst avatar Feb 07 '25 12:02 nickAalst

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

zerolab avatar Feb 07 '25 12:02 zerolab

:warning: 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 :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.

codecov-commenter avatar Feb 07 '25 13:02 codecov-commenter

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

I also renamed exclude_models to --exclude

nickAalst avatar Feb 07 '25 15:02 nickAalst