Skip to content

Settings models

These models are responsible for storing settings that are configured by a user.

graph TD A[LocaleSynchronization] --> B[wagtail.Locale] style B stroke-dasharray: 5 5

LocaleSynchronization

Stores the "Sync from" setting that users can add to Locales.

This tells Wagtail Localize to synchronise the contents of the 'sync_from' Locale to the 'locale' Locale.

Attributes:

Name Type Description
locale ForeignKey to Locale

The destination Locale of the synchronisation

sync_from ForeignKey to Locale

The source Locale of the synchronisation

base_form_class

validate_with_locale(self, locale)

Validates the locale component against the given locale.

Source code in wagtail_localize/models.py
def validate_with_locale(self, locale):
    # Note, we must compare the language_codes as it may be the same locale record but the language_code was updated in this request
    if (
        "sync_from" in self.cleaned_data
        and locale.language_code == self.cleaned_data["sync_from"].language_code
    ):
        raise ValidationError(
            {"sync_from": _("This locale cannot be synced into itself.")}
        )