Skip to main content

Page translation plugin for Wagtail

Project description

A plugin for Wagtail that provides page translations.

Installing

Install using pip:

$ pip install wagtailtranslations

Add it to your INSTALLED_APPS:

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

It works with Wagtail 1.7 and upwards.

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.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailcore.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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtailtranslations-0.2.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

wagtailtranslations-0.2.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file wagtailtranslations-0.2.2.tar.gz.

File metadata

File hashes

Hashes for wagtailtranslations-0.2.2.tar.gz
Algorithm Hash digest
SHA256 fbee97834c3d6dfc8d6a0cc163e02d31e9e79beafdca3ed51e08110e2ef88739
MD5 98f04990a33d4fb5e82398e6845606c5
BLAKE2b-256 50bf4353a35eeb73f570a521ececc5942e9346c7a1554d4d653f3eaa94778273

See more details on using hashes here.

File details

Details for the file wagtailtranslations-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtailtranslations-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2fb24d761bc90be63c7c2dca52f305aad84db76377e401ab30597d45c12e1e5c
MD5 7f9fa8303cba99b4fb6a5dfb662a34be
BLAKE2b-256 fb6cbb661e9eb7ddcd921c84ec7feb9b49e0602b353a60fdcce21f80b147e444

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page