Looking through django/middleware/locale.py, it seems you can just call:
from django.utils import translation
translation.activate(language)
Here's the whole class LocaleMiddleware, for your guidance:
def process_request(self, request):
language = translation.get_language_from_request(request)
translation.activate(language)
request.LANGUAGE_CODE = translation.get_language()
def process_response(self, request, response):
patch_vary_headers(response, ('Accept-Language',))
if 'Content-Language' not in response:
response['Content-Language'] = translation.get_language()
translation.deactivate()
return response
source
share