-
-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow lazy translation strings in email contexts #1442
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I cannot find any mentions of this in either:
- https://docs.djangoproject.com/en/4.2/topics/email/
- https://github.com/django/django/blob/main/django/core/mail/message.py
Can you please point to exact places in the docs / source?
I could not find a reference to it either. However, I think it is a valid (and common) use case. In my experience, any user-facing string tends to be translatable in Django, and in the case they are not, some exception is raised, making it necessary to use |
@adamchainz can you please take a look? |
It has been many years since I used translations in Django, but for back when I used them, my experience matches realsuayip's description:
The relevant documentation is https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#working-with-lazy-translation-objects, quote:
I think the Django documentation overstates it, reality is more nuanced. Obviously, there are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the Django code, but it's not straightforward. @realsuayip have you tested that these functions work with lazy strings?
As described in my previous message, I'm inclined to accept this PR, but I'll leave final decision to sobolevn.
@intgr Yes, eventually all functions end up creating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like it works locally! Thanks everyone!
No description provided.