Changeset 7734


Ignore:
Timestamp:
29 Feb 2012, 22:20:07 (13 years ago)
Author:
Henrik Bettermann
Message:

Translate text of emails send to users.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7723 r7734  
    18521852        IUserAccount(student).setPassword(pwd)
    18531853        # Send email with new redentials
    1854         msg = 'You have successfully changed your password for the'
     1854        msg = _('You have successfully changed your password for the')
    18551855        login_url = self.url(grok.getSite(), 'login')
    18561856        success = sirp_utils.sendCredentials(
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py

    r7722 r7734  
    2121import grok
    2222import string
     23from zope.i18n import translate
    2324from random import SystemRandom as r
    2425from waeup.sirp.interfaces import ISIRPUtils
     26from waeup.sirp.interfaces import MessageFactory as _
    2527from waeup.sirp.smtp import send_mail as send_mail_internally
    2628
     
    115117        """
    116118        config = grok.getSite()['configuration']
    117         text = """Fullname: %s
    118 User Id: %s
    119 User Type: %s
    120 Portal: %s
     119        text = _(u"""Fullname: ${a}
     120User Id: ${b}
     121User Type: ${c}
     122Portal: ${d}
    121123
    122 %s
    123 """
    124         body = text % (from_name,from_username,usertype,portal,body)
     124${e}
     125""")
     126        text = _(text,
     127            mapping = {
     128            'a':from_name,
     129            'b':from_username,
     130            'c':usertype,
     131            'd':portal,
     132            'e':body})
     133        body = translate(text, 'waeup.sirp',
     134            target_language=self.PORTAL_LANGUAGE)
    125135        return send_mail(
    126136            from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
     
    152162        """
    153163        subject = 'Your SIRP credentials'
    154         text = """Dear %s,
     164        text = _(u"""Dear ${a},
    155165
    156 %s
     166${b}
    157167Student Registration and Information Portal of
    158 %s.
     168${c}.
    159169
    160 Your user name: %s
    161 Your password: %s
    162 Login page: %s
     170Your user name: ${d}
     171Your password: ${e}
     172Login page: ${f}
    163173
    164174Please remember your user name and keep
     
    168178
    169179Regards
    170 """
     180""")
    171181        config = grok.getSite()['configuration']
    172182        from_name = config.name_admin
     
    174184        rcpt_name = user.title
    175185        rcpt_addr = user.email
    176         body = text % (
    177                 rcpt_name, msg,config.name,user.name,password,login_url)
     186        text = _(text,
     187            mapping = {
     188            'a':rcpt_name,
     189            'b':msg,
     190            'c':config.name,
     191            'd':user.name,
     192            'e':password,
     193            'f':login_url})
     194
     195        body = translate(text, 'waeup.sirp',
     196            target_language=self.PORTAL_LANGUAGE)
    178197        return send_mail(
    179198            from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
Note: See TracChangeset for help on using the changeset viewer.