Internationalisation (i18n)

All user-facing strings in django-multifactor — views, templates, model labels, flash messages — are wrapped for translation, and the package ships compiled .mo files in the wheel. You do not need to run makemessages or compilemessages against this app in your own project.

Enabling translations in your project

These are the Django defaults but worth confirming in settings.py:

USE_I18N = True
LANGUAGE_CODE = "en"  # or your preferred default

For per-request language switching (using the Accept-Language header, a session value, or a cookie), add LocaleMiddleware after SessionMiddleware and before CommonMiddleware:

MIDDLEWARE = [
    # ...
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.locale.LocaleMiddleware",
    "django.middleware.common.CommonMiddleware",
    # ...
]

Translating your overridden LOGIN_MESSAGE

The default LOGIN_MESSAGE is a translatable string. If you override it, wrap your string with gettext_lazy:

from django.utils.translation import gettext_lazy as _

MULTIFACTOR = {
    "LOGIN_MESSAGE": _('<a href="{}">Manage multifactor settings</a>.'),
}

Bundled languages

Locale

Status

en

Source (default)

If you have translated django-multifactor into another language, PRs are welcome — see Contributing translations.

See also