Answer the question
In order to leave comments, you need to log in
Why does my email come in English in a django {% trans %} block?
The text of the letter received by mail:
{% load i18n %}
<html>
<title>Company - {% trans 'Activation by email' %}</title>
<body>
<p>{% trans 'Hello' %}, {{ user }}</p>
<p>{% trans 'Your account in Company name has been successfully created. Please click link below to activate your account.'%}</p>
<p><a href="{{ activate_url }}">{% trans 'Activate your account' %}</a></p>
</body>
</html>
def mail_send(scheme, host, user_id):
user = User.objects.get(pk=user_id)
text_content = 'Account Activation Email'
subject = 'Email Activation'
template_name = "activation.html"
from_email = settings.DEFAULT_FROM_EMAIL
recipients = [user.email]
# receive url with encoded data
context = encoder(scheme, host, user)
html_content = render_to_string(template_name, context)
email = EmailMultiAlternatives(subject, text_content, from_email, recipients)
email.attach_alternative(html_content, "text/html")
mail_sent = email.send()
return mail_sent
Answer the question
In order to leave comments, you need to log in
Link to the doc - solution to the problem:
https://docs.djangoproject.com/en/3.0/topics/i18n/... I
took the required language from the signup method in views (the language is correct there) and inserted it into mail_send with one more parameter
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question