Translating email templates in Django
<p>I have an HTML template which I send through email using a Django installation. I'm trying to translate the content of the template (I've loaded i18n and all strings are in po files), but I keep getting the email rendered in English. </p>

<p>I have the following code:</p>

<pre><code>htmly = get_template(self.html_content)
self.values_dict['LANGUAGE_CODE'] = 'es'
d = Context(self.values_dict)
html_content = htmly.render(d)
process_mail.delay(subject=self.subject, message=self.message,
                   from_email=self.from_email,
                   recipient_list=self.recipient_list,
                   html_content=html_content,
                   html_type=self.html_type,
                   attaches=self.attaches, mass=mass)
</code></pre>

<p>For debugging reasons, I've also put this on the template: </p>

<pre><code>{% get_language_info for LANGUAGE_CODE as lang %}
Language code: {{ lang.code }}&lt;br /&gt;
Name of language: {{ lang.name_local }}&lt;br /&gt;
Name in English: {{ lang.name }}&lt;br /&gt;
Bi-directional: {{ lang.bidi }}
Name in the active language: {{ lang.name_translated }}
</code></pre>

<p>Which outputs</p>

<pre><code>Language code: es
Name of language: espaÃ±ol 
Name in English: Spanish
Bi-directional: False Name in the active language:
</code></pre>

<p>Do you know what am I doing wrong?</p>

<p>You don't seem to be actually activating the translation anywhere; all you've done is send a string, "es", as the LANGUAGE_CODE variable. In order to actually make things translated, you need to <a href="https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#explicitly-setting-the-active-language" rel="nofollow">make that language the active one</a>:</p>

<pre><code>from django.utils import translation
translation.activate('es')
</code></pre>

python django email internationalization translation