Skip to main content

A plugin for Wagtail that provides page translations. By extending your pages with the models included in this package users will be redirected to pages in (or closest to) their language.

Installing

Install using pip:

$ pip install wagtailtranslations

Add it to your INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'wagtailtranslations',
    # ...
]

It works with Wagtail 2.2 and upwards. Check versions before 2.0 for compatability with older versions of wagtail.

Quick start

Define a TranslationIndex model:

from wagtailtranslations.models import AbstractTranslationIndexPage

class TranslationHomePage(AbstractTranslationIndexPage):
    subpage_types = ['ContentPage']

Use this as your site root page. Each language your site supports should exist as a separate page tree underneath this index page. The English home page should have a slug “en”, for a URL of /en/; while the French home page should have a slug “fr”, for a URL of /fr/.

Define a translated model:

from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
from wagtailtranslations.models import TranslatedPage

class ContentPage(TranslatedPage, Page):
    body = RichTextField()

    content_panels = Page.content_panels + [
        FieldPanel('body'),
    ]

Enable some languages in the Wagtail admin → Settings → Languages, for example English and French.

Create a new ContentPage for English. On the ‘Translations’ tab, select English for the language, and leave the ‘Translation of …’ field blank.

Create another new ContentPage for French. On the ‘Translations’ tab, select French for the language, and select the English page you just created in the ‘Translation of …’ field.

Testing

To start a test server, run:

$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -e .
$ export DJANGO_SETTINGS_MODULE=tests.settings
$ django-admin migrate
$ django-admin createsuperuser
$ django-admin runserver

To run the automated test suite:

# Do not run this from within a virtual environment
$ pip install --user --upgrade tox pip setuptools
$ tox

Release files for wagtailtranslations 2.0.1

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

Source distribution (sdist)

Source distribution for wagtailtranslations 2.0.1
File Size Uploaded
wagtailtranslations-2.0.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtailtranslations 2.0.1
File Interpreter ABI Platform
wagtailtranslations-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / wagtailtranslations-2.0.1.tar.gz

Download URL wagtailtranslations-2.0.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7b9afcc6f0784e35677f972bd24a7e448ec7386a73c1bcef7b7227bab98d6665
BLAKE2b-256 checksum
How to use checksums
d3c8214f42a0b44828891865c5c652f39f9d75879423f440f44cbdde25fa11c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release files / wagtailtranslations-2.0.1-py3-none-any.whl

Download URL wagtailtranslations-2.0.1-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c16b2ef40aa46fdef0a0145f2d15a0598478abcf2adc003ebb44d07ee685524
BLAKE2b-256 checksum
How to use checksums
3b6eb667ab2a8a530e8a18264bd72ecfa484f7dc3c181b3807f74b0aa01f4868
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

1 release file

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