Skip to main content

Wagtail Translate

Wagtail Translate adds machine translations to your Wagtail site, with built-in support for DeepL and the flexibility to integrate other translation services. It automatically detects when a page is copied to a new locale and initiates the translation process.

Wagtail Localize and Wagtail Simple Translation are the go-to solutions for multi-language Wagtail projects. Wagtail Localize offers advanced features that may be excessive for many projects, while Wagtail Simple Translation only copies pages to new locales, requiring manual translation.

Wagtail Translate adds machine translations to Wagtail. It works in combination with Simple Translation, offering the ideal solution for projects seeking a simple interface with powerful translation support.

License: MIT PyPI version Translate CI

Links

Supported versions

  • Python 3.8 - 3.12
  • Django 4.2 - 5.0
  • Wagtail 5.2 - 6.0

Internationalization

You need to configure your project for authoring content in multiple languages. See Wagtail documentation on internationalization.

In summary:

# settings.py
USE_I18N = True
WAGTAIL_I18N_ENABLED = True
USE_L10N = True

LANGUAGE_CODE = 'en'
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
    (LANGUAGE_CODE, "English"),
    ('fr', "French"),
]

INSTALLED_APPS += [
    "wagtail.locales",
    "wagtail.contrib.simple_translation",
]

MIDDLEWARE += [
    'django.middleware.locale.LocaleMiddleware',
]

# urls.py
from django.conf.urls.i18n import i18n_patterns

urlpatterns += i18n_patterns(
    path("", include(wagtail_urls)),
)

Create the French locale at: /admin/locales/new/.

Installation

python -m pip install wagtail-translate
INSTALLED_APPS = [
    "wagtail_translate",
    "wagtail_translate.default_behaviour",
    ...
]

WAGTAIL_TRANSLATE_TRANSLATOR = "wagtail_translate.translators.rot13.ROT13Translator"

In the Wagtail admin interface, go to the homepage, in the dot-dot-dot-menu, choose "Translate".

The contents should be translated! 🥳

ROT13Translator

The installation example uses the ROT13Translator. It shifts each letter by 13 places. Applying it twice will return the text to its original form. ROT13 is good for testing and evaluation, but not for real-world use.

DeepLTranslator

Wagtail Translation has a DeepL translator. Install and configure it as follows:

  • pip install deepl
  • Get a DeepL API key from https://www.deepl.com/pro#developer
  • Add WAGTAIL_TRANSLATE_DEEPL_KEY = "..." to your settings.
  • Set WAGTAIL_TRANSLATE_TRANSLATOR = "wagtail_translate.translators.deepl.DeepLTranslator"

Documentation

Contributing

Install

To make changes to this project, first clone this repository:

git clone https://github.com/allcaps/wagtail-translate.git
cd wagtail-translate

With your preferred virtualenv activated, install testing dependencies:

Using pip

python -m pip install --upgrade pip
python -m pip install -e '.[testing]' -U

Using flit

python -m pip install flit
flit install

pre-commit

Note that this project uses pre-commit. It is included in the project testing requirements. To set up locally:

# go to the project directory
cd wagtail-translate
# initialize pre-commit
pre-commit install

# Optional, run all checks once for this, then the checks will run only on the changed files
git ls-files --others --cached --exclude-standard | xargs pre-commit run --files

How to run tests

Now you can run tests as shown below:

tox

or, you can run them for a specific environment tox -e python3.11-django4.2-wagtail5.1 or specific test tox -e python3.11-django4.2-wagtail5.1-sqlite wagtail-translate.tests.test_file.TestClass.test_method

To run the test app interactively, use tox -e interactive, visit http://127.0.0.1:8000/admin/ and log in with admin/changeme.

Project template

This project has been created with Cruft, a drop-in replacement for Cookiecutter.

cruft create git@github.com:wagtail/cookiecutter-wagtail-package.git

The "cookiecutter answers" are stored in .cruft.json. To update the project to the latest template, run:

cruft update

Release files for wagtail-translate 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-translate 0.3.0
File Size Uploaded
wagtail_translate-0.3.0.tar.gz 22.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-translate 0.3.0
File Interpreter ABI Platform
wagtail_translate-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.7 kB

Release files / wagtail_translate-0.3.0.tar.gz

Download URL wagtail_translate-0.3.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
81d4de551e9dbd68e0473d77fdb6983885e45e69ee06a1316d2f1d11196248fc
BLAKE2b-256 checksum
How to use checksums
d8645ec784b65ddfd2fd1ba08f3cb21d068ab74b4d9430f250343e21a186497b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / wagtail_translate-0.3.0-py3-none-any.whl

Download URL wagtail_translate-0.3.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e64d4bf2e83cc3128de885c29be4f592379bdd39507cab00626292271c62f9f
BLAKE2b-256 checksum
How to use checksums
dfeaac4e08f8763448d09c03d5516584b1df728df9e7c9f79903f156b81ce9bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page