Skip to main content

Wagtail Localize AI Translator

A machine translator for Wagtail Localize that uses Any-LLM for translation

Prerequisites

  • Python 3.11+
  • a Wagtail project with Wagtail Localize correctly configured

Dependencies

Installation

Install the package using pip:

pip install wagtail-localize-ai

In your settings.py file,

  • Add wagtail_localize_ai to your INSTALLED_APPS
  • Add wagtail.contrib.settings to your INSTALLED_APPS (used to setup model and prompt)
  • Setup WAGTAILLOCALIZE_MACHINE_TRANSLATOR like this:
    WAGTAILLOCALIZE_MACHINE_TRANSLATOR = {
        "CLASS": "wagtail_localize_ai.translator.AITranslator",
    }
    

Then, run python manage.py migrate wagtail_localize_ai to create the required database tables

Setting up providers

To set up providers add to your settings.py file a dict called AI_PROVIDERS.
Each entry is an arbitrary key identifying the provider instance, with a dict of configuration.

Reserved keys (all start with _):

  • _name: display name shown in the Wagtail admin
  • _provider: any-llm provider name (e.g. openai, anthropic). Defaults to the entry key, so you can omit it when the key matches the provider name.

All other keys are passed as kwargs to AnyLLM.create(provider, **kwargs).

You can find supported providers and their kwargs in the any-llm documentation.

Having multiple instances of the same provider (e.g. different API keys or endpoints) is supported:

AI_PROVIDERS = {
    "openai_main": {
        "_name": "OpenAI (main)",
        "_provider": "openai",
        "api_key": "sk-...",
    },
    "openai_secondary": {
        "_name": "OpenAI (secondary)",
        "_provider": "openai",
        "api_key": "sk-other-...",
        "api_base": "https://my-proxy.example.com/v1",
    },
}

Here are some examples for the most popular providers:

OpenAI

AI_PROVIDERS = {
    "openai": {
        "_name": "OpenAI",
        "api_key": "sk-...",
        "organization": "org-...",  # Optional
        "api_base": "https://api.openai.com/v1",  # Optional
    }
}

Anthropic

AI_PROVIDERS = {
    "anthropic": {
        "_name": "Anthropic",
        "api_key": "sk-ant-...",
    }
}

Azure OpenAI

Provider key: azureopenai (OpenAI-compatible Azure endpoint).

AI_PROVIDERS = {
    "azureopenai": {
        "_name": "Azure OpenAI",
        "api_key": "...",
        "api_base": "https://<resource>.openai.azure.com",
        "api_version": "preview",  # Optional, defaults to "preview"
    }
}

Azure AI

Provider key: azure (Azure AI Inference SDK, for models deployed on Azure AI Foundry).

AI_PROVIDERS = {
    "azure": {
        "_name": "Azure AI",
        "api_key": "...",
        "api_base": "https://<model-deployment-name>.<region>.models.ai.azure.com",
    }
}

Gemini

AI_PROVIDERS = {
    "gemini": {
        "_name": "Gemini",
        "api_key": "...",
    }
}

Vertex AI

Provider key: vertexai. project, location and credentials are passed directly to the Google GenAI client.

Using Application Default Credentials (e.g. gcloud auth application-default login):

AI_PROVIDERS = {
    "vertexai": {
        "_name": "Vertex AI",
        "project": "my-gcp-project",
        "location": "europe-west8",
    }
}

Using a service account JSON file:

from google.oauth2 import service_account

AI_PROVIDERS = {
    "vertexai": {
        "_name": "Vertex AI",
        "project": "my-gcp-project",
        "location": "europe-west8",
        "credentials": service_account.Credentials.from_service_account_file(
            "/path/to/service_account.json",
            scopes=["https://www.googleapis.com/auth/cloud-platform"],
        ),
    }
}

Usage

You can set the provider, model and prompt from the AI Translator page reachable from the Settings menu entry.
You can also see the token usage from the Logs pagea in the Reports menu entry.

License

This project is released under the BSD license.

Contributors

Metadata

Release files for wagtail-localize-ai 0.3.3

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-localize-ai 0.3.3
File Size Uploaded
wagtail_localize_ai-0.3.3.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-localize-ai 0.3.3
File Interpreter ABI Platform
wagtail_localize_ai-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / wagtail_localize_ai-0.3.3.tar.gz

Download URL wagtail_localize_ai-0.3.3.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
540fc55783ee2733d413dc1230bce5877cbaf6e03cb00a9a9159ddbe29bcac6f
BLAKE2b-256 checksum
How to use checksums
21040074b6aa909ed29cbedd1744228ef7889e76e824be81e2921681ccee548e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / wagtail_localize_ai-0.3.3-py3-none-any.whl

Download URL wagtail_localize_ai-0.3.3-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efc14a9c4fe68623dbb9928eda62a33a909cc8b6edc738fb67a5e67e3efbc13e
BLAKE2b-256 checksum
How to use checksums
3564a503bd20075e60ffdca56211b3994dc4b6ba422ca2ab829fc447c74056d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

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