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
File details
Details for the file wagtailtranslations-0.1.0.tar.gz
.
File metadata
- Download URL: wagtailtranslations-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d07f61e12427dfd49fd73d94f9bf6c635e420317d372768da7420c65231b4795 |
|
MD5 | bcf12a1188bd66f05793ecc976307a0b |
|
BLAKE2b-256 | cf39e8e26d640e83186666b1b826b080e48b8e7f81bc17d46d6b6612b7dc98e3 |