Email not translated inside a Celery Task
celery, django, internationalization
Solution
Try to use
from django.utils import translation
translation.activate('fr')
EDIT
Solution from comments on the question:
check your locale paths, they might be different when they are executed in celery.
Problem
I have a celery task that sends an email asynchronously ``` from djcelery.common import respects_language @task(ignore_result=True) @respects_language def async_send_activation_email(registration_profile): registration_profile.send_activation_email() ``` And the send activation email function ``` from django.core import context_processors def send_activation_email(self): variables = { 'some_variable':'something', } context = context_processors.i18n(None) # Allows to easily get all the language information into context. None is passed as the request does not matter for this context_processor. # Subject # Email subject *must not* contain newlines subject = render_to_string( 'user_manager/activation/email_subject.txt', variables, context ) ... ``` context contains the correct informations (in my case LANGUAGE = 'fr', and other language options). Which is normal as they are correctly set by the `@respects_language` decorator. but render_to_string use the fallback language anyway. Any idea about what might be happening ?