Django comes with a middleware that determines the current language based on request data. This is the LocaleMiddleware middleware that resides in django.middleware.locale. LocaleMiddleware performs the following tasks:
- If you are using i18_patterns, that is, you use translated URL patterns, it looks for a language prefix in the requested URL to determine the current language.
- If no language prefix is found, it looks for an existing LANGUAGE_SESSION_KEY in the current user's session.
- If the language is not set in the session, it looks for an existing cookie with the current language. A custom name for this cookie can be provided in the LANGUAGE_COOKIE_NAME setting. By default, the name for this ...