Wagtail pagetranslation
Allows to translate specific pages without replicating all wagtail pages tree structure.
Links
Installation
python -m pip install wagtail-pagetranslation
How to use
Add "wagtail_pagetranslation" to list of applications after all wagtail apps
INSTALLED_APPS = [
"your_wagtail_app_1",
"your_wagtail_app_2",
...
"wagtail_pagetranslation",
...
]
Set default language for wagtail_pagetranslation app
WAGTAIL_PAGETRANSLATION_DEFAULT_LANGUAGE = "en"
by default settings.LANGUAGES will be used
LANGUAGES = [
("en", "English"),
("nl", "Dutch"),
("uk", "Ukrainian")
]
or you can specify custom list
WAGTAIL_PAGETRANSLATION_LANGUAGES = [
("en", "English"),
("nl", "Dutch"),
("uk", "Ukrainian")
]
To make available translation per page type add TranslationMixin to your custom Page class. Note: mixin should be added before Page class.
from wagtail_pagetranslation.translation import TranslationMixin
class HomePage(TranslationMixin, Page):
# list of fields that should have translation
translatable_fields = ["title", ...]
By default URL for translated page is page url + ?lang=<lang_code>
This can be change by overriding get_language method:
from wagtail_pagetranslation.translation import TranslationMixin as BaseTranslationMixin
class TranslationMixin(BaseTranslationMixin):
# list of fields that should have translation
translatable_fields = ["title", ...]
def get_language(self, request):
return request.GET.get("language")
Contributing
Install
To make changes to this project, first clone this repository:
git clone https://github.com/dest81/wagtail-pagetranslation.git
cd wagtail-pagetranslation
With your preferred virtualenv activated, install testing dependencies:
Using pip
python -m pip install --upgrade pip>=21.3
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-pagetranslation
# 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-pagetranslation.tests.test_file.TestClass.test_method
To run the test app interactively, use tox -e interactive, visit http://127.0.0.1:8020/admin/ and log in with admin/changeme.
Release files for wagtail-pagetranslation 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wagtail_pagetranslation-0.0.1.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wagtail_pagetranslation-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / wagtail_pagetranslation-0.0.1.tar.gz
| Download URL | wagtail_pagetranslation-0.0.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4197b1aca88e2e6b322dc22c060ee63d6e205f01ada2f9b36b18ea703d69737f
|
|
BLAKE2b-256 checksum How to use checksums |
75a18b793e2b12670ab56cc9f5f5edafbf4903635dcb19e81058c9e7f0c419b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / wagtail_pagetranslation-0.0.1-py3-none-any.whl
| Download URL | wagtail_pagetranslation-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a4c70cb4a119a26d326c733b51f65da32472b99d40a0ec04ec9d9366dac9182
|
|
BLAKE2b-256 checksum How to use checksums |
d8649c386f4c083cf99800b274a6dc9b88dfb419c015385c1c7e71ceaba086d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|