I have a model, Order, that has an action in the admin panel that lets an admin send information about the order to certain persons listed that order. Each person has
language set and that is the
language the message is supposed to be sent in.
A short version of what I'm using:
from django.utils.translation import ugettext as _
from django.core.mail import EmailMessage
lang = method_that_gets_customer_language()
body = _("Dear mister X, here is the information you requested\n")
body += some_order_information
subject = _("Order information")
email = EmailMessage(subject, body, '
[email protected]', ['
[email protected]'])
email.send()
The customer information about the
language he uses is available in lang. The default
language is en-us, the translations are in french (fr) and german (de).
Is there a way to use the translation for the
language specified in lang for body and subject then switch back to en-us? For example: lang is 'de'. The subject and body should get the strings specified in the 'de' translation files.