Changeset 1180 in main


Ignore:
Timestamp:
06/06/12 12:58:11 (7 years ago)
Author:
zali
Message:

function send mail: subject is translated before the mail is sent

Location:
trunk/openPLM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/locale/es/LC_MESSAGES/django.po

    r1124 r1180  
    18841884msgstr "Rechazar invitacion" 
    18851885 
     1886#: plmapp/mail.py:192 
     1887msgid "New account on openPLM" 
     1888msgstr "Nueva cuenta en openPLM" 
     1889 
    18861890#: templates/mails/new_account.html:5 
    18871891#, python-format 
  • trunk/openPLM/locale/fr/LC_MESSAGES/django.po

    r1124 r1180  
    18461846msgstr "Refuser l'invitation" 
    18471847 
     1848#: plmapp/mail.py:192 
     1849msgid "New account on openPLM" 
     1850msgstr "Nouveau compte sur openPLM" 
    18481851#: templates/mails/new_account.html:5 
    18491852#, python-format 
  • trunk/openPLM/plmapp/mail.py

    r1177 r1180  
    3333from django.conf import settings 
    3434from django.utils import translation 
     35from django.utils.translation import ugettext as _ 
    3536from django.core.mail import EmailMultiAlternatives 
    3637from django.db.models import Model, Q 
     
    186187        for lang, emails in lang_to_email.items(): 
    187188            translation.activate(lang) 
    188             html_content = translation.gettext(render_to_string(template + ".html", ctx)) 
    189             message = translation.gettext(render_to_string(template + ".txt", ctx)) 
    190             msg = EmailMultiAlternatives(subject, message, settings.EMAIL_OPENPLM, 
     189            html_content = render_to_string(template + ".html", ctx) 
     190            message = _(render_to_string(template + ".txt", ctx)) 
     191            subj_translation = _(subject) 
     192            msg = EmailMultiAlternatives(subj_translation, message, settings.EMAIL_OPENPLM, 
    191193                emails) 
    192194            msg.attach_alternative(html_content, "text/html") 
    193195            msg.send(fail_silently=True) 
     196         
     197        if lang_to_email.items(): 
     198            translation.deactivate() 
    194199 
    195200def send_mail(subject, recipients, ctx, template, blacklist=()): 
Note: See TracChangeset for help on using the changeset viewer.