background: The view is called when a payment service pings back a payment outcome behind the scenes - afterwhich I need to send an email in the right langu
If you are using django 1.10 or higher, there's a new syntax for custom middleware:
from django.utils import translation
class LocaleMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
language_code = 'en' #TODO, your logic
translation.activate(language_code)
response = self.get_response(request)
translation.deactivate()
return response