in my application, I regularly need to switch the active language for a
short period of time. A popular example would be that a German-speaking
user does something and I need to send out a notification to an
English-speaking user.

Cluttering the code with translation.activate() statements is certainly
not making the core more readable, which is why I'm now using a context

    with language(other_user.locale):

language() is currently implemented in my project like this:

    def language(lng):
        _lng = translation.get_language()
        translation.activate(lng or settings.LANGUAGE_CODE)

This turned out to be very convenient and readable and I'd wanted to ask
for your opinion if 

(a) something like this should be added to django
(b) the activate() method itself should be changed to optionally work as
    a context manager


You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Attachment: pgpxloUreQIqG.pgp
Description: Digitale Signatur von OpenPGP

Reply via email to