diff options
| -rw-r--r-- | Mailman/Cgi/admin.py | 216 | ||||
| -rw-r--r-- | Mailman/Cgi/admindb.py | 77 | ||||
| -rw-r--r-- | Mailman/Cgi/edithtml.py | 45 | ||||
| -rw-r--r-- | Mailman/Cgi/handle_opts.py | 92 | ||||
| -rw-r--r-- | Mailman/Cgi/listinfo.py | 69 | ||||
| -rw-r--r-- | Mailman/Cgi/options.py | 30 | ||||
| -rw-r--r-- | Mailman/Cgi/private.py | 28 | ||||
| -rw-r--r-- | Mailman/Cgi/roster.py | 14 | ||||
| -rw-r--r-- | Mailman/Cgi/subscribe.py | 56 | ||||
| -rw-r--r-- | Mailman/Handlers/Acknowledge.py | 5 | ||||
| -rw-r--r-- | Mailman/Handlers/CookHeaders.py | 2 | ||||
| -rw-r--r-- | Mailman/Handlers/HandlerAPI.py | 3 | ||||
| -rw-r--r-- | Mailman/Handlers/ToDigest.py | 31 |
13 files changed, 343 insertions, 325 deletions
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py index fd856bc61..63b6e3e90 100644 --- a/Mailman/Cgi/admin.py +++ b/Mailman/Cgi/admin.py @@ -64,7 +64,7 @@ def main(): try: mlist = MailList.MailList(listname) except Errors.MMListError, e: - FormatAdminOverview('No such list <em>%s</em>' % listname) + FormatAdminOverview(_('No such list <em>%s</em>') % listname) syslog('error', 'Someone tried to access the admin interface for a ' 'non-existent list: %s' % listname) return @@ -90,6 +90,15 @@ def main(): Auth.loginpage(mlist, 'admin', frontpage=1) return + CATEGORIES = [('general', _("General Options")), + ('members', _("Membership Management")), + ('privacy', _("Privacy Options")), + ('nondigest', _("Regular-member (non-digest) Options")), + ('digest', _("Digest-member Options")), + ('bounce', _("Bounce Options")), + ('archive', _("Archival Options")), + ('gateway', _("Mail-News and News-Mail gateways"))] + if category not in map(lambda x: x[0], CATEGORIES): category = 'general' @@ -118,19 +127,19 @@ def main(): # Sanity checks if not mlist.digestable and not mlist.nondigestable: - AddErrorMessage(doc, '''You have turned off delivery of + AddErrorMessage(doc, _('''You have turned off delivery of both digest and non-digest messages. This is an incompatible state of affairs. You must turn on either digest delivery or non-digest delivery or your mailing list will basically be - unusable.''') + unusable.''')) if not mlist.digestable and len(mlist.GetDigestMembers()): - AddErrorMessage(doc, '''You have digest members, + AddErrorMessage(doc, _('''You have digest members, but digests are turned off. Those people will not receive - mail.''') + mail.''')) if not mlist.nondigestable and len(mlist.GetMembers()): - AddErrorMessage(doc, '''You have regular list members + AddErrorMessage(doc, _('''You have regular list members but non-digestified mail is turned off. They will receive mail - until you fix this problem.''') + until you fix this problem.''')) FormatConfiguration(doc, mlist, category, category_suffix, cgidata) print doc.Format(bgcolor="#ffffff") @@ -144,7 +153,7 @@ def main(): def FormatAdminOverview(error=None): "Present a general welcome and itemize the (public) lists." doc = Document() - legend = "%s mailing lists - Admin Links" % mm_cfg.DEFAULT_HOST_NAME + legend = _("%s mailing lists - Admin Links") % mm_cfg.DEFAULT_HOST_NAME doc.SetTitle(legend) table = Table(border=0, width="100%") @@ -163,39 +172,39 @@ def FormatAdminOverview(error=None): if error: greeting = FontAttr(error, color="ff5060", size="+1") else: - greeting = "Welcome!" + greeting = _("Welcome!") if not advertised: welcome_items = (greeting, - "<p>" - " There currently are no publicly-advertised ", + _("<p>" + " There currently are no publicly-advertised "), Link(mm_cfg.MAILMAN_URL, "mailman"), - " mailing lists on %s." % mm_cfg.DEFAULT_HOST_NAME, + _(" mailing lists on %s.") % mm_cfg.DEFAULT_HOST_NAME, ) else: welcome_items = ( greeting, - "<p>" - " Below is the collection of publicly-advertised ", + _("<p>" + " Below is the collection of publicly-advertised "), Link(mm_cfg.MAILMAN_URL, "mailman"), - " mailing lists on %s." % mm_cfg.DEFAULT_HOST_NAME, - (' Click on a list name to visit the configuration pages' - ' for that list.' + _(" mailing lists on %s.") % mm_cfg.DEFAULT_HOST_NAME, + (_(' Click on a list name to visit the configuration pages' + ' for that list.') ) ) welcome_items = (welcome_items + - (" To visit the administrators configuration page for" - " an unadvertised list, open a URL similar to this" + (_(" To visit the administrators configuration page for" + " an unadvertised list, open a URL similar to this") + - (" one, but with a '/' and the %slist name appended.<p>" - % ((error and "right ") or "")) + (_(" one, but with a '/' and the %slist name appended.<p>") + % ((error and _("right ")) or "")) + - " General list information can be found at ", + _(" General list information can be found at "), Link(Utils.ScriptURL('listinfo'), - 'the mailing list overview page'), - "." - "<p>(Send questions and comments to ", + _('the mailing list overview page')), + "." + + _("<p>(Send questions and comments to "), Link("mailto:%s" % mm_cfg.MAILMAN_OWNER, mm_cfg.MAILMAN_OWNER), ".)<p>" @@ -207,11 +216,11 @@ def FormatAdminOverview(error=None): if advertised: table.AddRow([' ', ' ']) - table.AddRow([Bold("List"), Bold("Description")]) + table.AddRow([Bold(_("List")), Bold(_("Description"))]) for l in advertised: table.AddRow( [Link(l.GetScriptURL('admin'), Bold(l.real_name)), - l.description or Italic('[no description available]'), + l.description or Italic(_('[no description available]')), ]) doc.AddItem(table) @@ -227,24 +236,25 @@ def FormatConfiguration(doc, mlist, category, category_suffix, cgi_data): if k == category: label = v - doc.SetTitle('%s Administration (%s)' % (mlist.real_name, label)) - doc.AddItem(Center(Header(2, '%s mailing list administration<br>%s' - % (mlist.real_name, label + ' Section')))) + realname = mlist.real_name + doc.SetTitle(_('%(realname)s Administration (%(label)s)')) + doc.AddItem(Center(Header(2, _( + '%(realname)s mailing list administration<br>%(label)s Section')))) doc.AddItem('<hr>') linktable = Table(valign="top") - linktable.AddRow([Center(Bold("Configuration Categories")), - Center(Bold("Other Administrative Activities"))]) + linktable.AddRow([Center(Bold(_("Configuration Categories"))), + Center(Bold(_("Other Administrative Activities")))]) adminurl = mlist.GetScriptURL('admin') otherlinks = UnorderedList() otherlinks.AddItem(Link(mlist.GetScriptURL('admindb'), - 'Tend to pending administrative requests')) + _('Tend to pending administrative requests'))) otherlinks.AddItem(Link(mlist.GetScriptURL('listinfo'), - 'Go to the general list information page')) + _('Go to the general list information page'))) otherlinks.AddItem(Link(mlist.GetScriptURL('edithtml'), - 'Edit the HTML for the public list pages')) + _('Edit the HTML for the public list pages'))) otherlinks.AddItem(Link(mlist.GetBaseArchiveURL(), 'Go to list archives')) otherlinks.AddItem(Link('%s/logout' % adminurl, # TBD: What I really want is a blank line :/ @@ -274,12 +284,12 @@ def FormatConfiguration(doc, mlist, category, category_suffix, cgi_data): doc.AddItem(form) if category == 'general': - andpassmsg = " (You can change your password there, too.)" + andpassmsg = _(" (You can change your password there, too.)") else: andpassmsg = "" - form.AddItem("Make your changes below, and then submit them" - " using the button at the bottom.%s<p>" - % andpassmsg) + form.AddItem(_("Make your changes below, and then submit them" + " using the button at the bottom.") + + andpassmsg + '<p>') form.AddItem(FormatOptionsSection(category, mlist, cgi_data)) @@ -311,7 +321,7 @@ def FormatOptionsSection(category, mlist, cgi_data): colspan=2, bgcolor="#99ccff") def ColHeader(big_table = big_table): - big_table.AddRow([Center(Bold('Description')), Center(Bold('Value'))]) + big_table.AddRow([Center(Bold(_('Description'))), Center(Bold(_('Value')))]) big_table.AddCellInfo(max(big_table.GetCurrentRowIndex(), 0), 0, width="15%") big_table.AddCellInfo(max(big_table.GetCurrentRowIndex(), 0), 1, @@ -351,7 +361,7 @@ def AddOptionsTableItem(table, item, category, mlist, detailsp=1): varname, kind, params, dependancies, descr, elaboration = got except ValueError, msg: syslog('error', 'admin: %s' % msg) - return Italic("<malformed option>") + return Italic(_("<malformed option>")) descr = GetItemGuiDescr(mlist, category, varname, descr, detailsp) val = GetItemGuiValue(mlist, kind, varname, params) table.AddRow([descr, val]) @@ -373,7 +383,7 @@ def FormatOptionHelp(doc, varref, mlist): item = i break if not item: - bad = 'Option %s/%s not found: %s' % ( + bad = _('Option %s/%s not found: %s') % ( category, varname, os.environ.get('PATH_INFO')) AddErrorMessage(doc, bad) return @@ -386,12 +396,13 @@ def FormatOptionHelp(doc, varref, mlist): varname, kind, params, dependancies, descr = got elaboration = descr header = Table(width="100%") - legend = ('%s Mailing list Configuration Help<br><em>%s</em> Option' - % (mlist.real_name, varname)) + realname = mlist.real_name + legend = (_("""%(realname)s Mailing list Configuration Help + <br><em>%(varname)s</em> Option""")) header.AddRow([Center(Header(3, legend))]) header.AddCellInfo(max(header.GetCurrentRowIndex(), 0), 0, colspan=2, bgcolor="#99ccff") - doc.SetTitle("Mailman %s List Option Help" % varname) + doc.SetTitle(_("Mailman %(varname)s List Option Help")) doc.AddItem(header) doc.AddItem("<b>%s</b> (%s): %s<p>" % (varname, category, descr)) doc.AddItem("%s<p>" % elaboration) @@ -403,12 +414,12 @@ def FormatOptionHelp(doc, varref, mlist): form.AddItem('<p>') form.AddItem(Center(FormatSubmit())) doc.AddItem(Center(form)) - doc.AddItem("""<em><strong>Warning:</strong> changing this option here + doc.AddItem(_("""<em><strong>Warning:</strong> changing this option here could cause other screens to be out-of-sync. Be sure to reload any other pages that are displaying this option for this mailing list. You can - also """) + also """)) doc.AddItem(Link('%s/%s' % (mlist.GetScriptURL('admin'), category), - 'return to the ' + category + ' options page.')) + _('return to the %(category)s options page.'))) doc.AddItem('</em>') doc.AddItem(mlist.GetMailmanFooter()) @@ -428,7 +439,7 @@ def GetItemCharacteristics(table_entry): elif len(table_entry) == 6: varname, kind, params, dependancies, descr, elaboration = table_entry else: - raise ValueError, ("Badly formed options entry:\n %s" + raise ValueError, (_("Badly formed options entry:\n %s") % table_entry) return (varname, kind, params, dependancies, descr, elaboration) @@ -482,9 +493,9 @@ def GetItemGuiValue(mlist, kind, varname, params): if not val: val = '' container = Container() - container.AddItem('<em>Enter the text below, or...</em><br>') + container.AddItem(_('<em>Enter the text below, or...</em><br>')) container.AddItem(TextArea(varname, val, r, c)) - container.AddItem('<br><em>...specify a file to upload</em><br>') + container.AddItem(_('<br><em>...specify a file to upload</em><br>')) container.AddItem(FileUpload(varname+'_upload', r, c)) return container @@ -504,9 +515,9 @@ def GetItemGuiDescr(mlist, category, varname, descr, detailsp): else: text = '<div ALIGN="right">' + descr + '</div>' if varname[0] == '_': - text = text + '''<div ALIGN="right"><br><em><strong>Note:</strong> + text = text + _('''<div ALIGN="right"><br><em><strong>Note:</strong> setting this value performs an immediate action but does not modify - permanent state.</em></div>''' + permanent state.</em></div>''') return text @@ -514,27 +525,28 @@ def GetItemGuiDescr(mlist, category, varname, descr, detailsp): def FormatMembershipOptions(mlist, cgi_data): container = Container() header = Table(width="100%") - header.AddRow([Center(Header(2, "Membership Management"))]) + header.AddRow([Center(Header(2, _("Membership Management")))]) header.AddCellInfo(max(header.GetCurrentRowIndex(), 0), 0, colspan=2, bgcolor="#99ccff") container.AddItem(header) user_table = Table(width="90%", border='2') - user_table.AddRow([Center(Header(4, "Membership List"))]) + user_table.AddRow([Center(Header(4, _("Membership List")))]) user_table.AddCellInfo(user_table.GetCurrentRowIndex(), user_table.GetCurrentCellIndex(), bgcolor="#cccccc", colspan=8) + membercnt = len(mlist.members) + len(mlist.digest_members) + chunksz = mlist.admin_member_chunksize user_table.AddRow( - [Center(Italic("(%s members total, max. %s at a time displayed)" % - (len(mlist.members) - + len(mlist.digest_members), - mlist.admin_member_chunksize)))]) + [Center(Italic(_( + "(%(membercnt)s members total, max. %(chunksz)s at a time displayed)") + ))]) user_table.AddCellInfo(user_table.GetCurrentRowIndex(), user_table.GetCurrentCellIndex(), bgcolor="#cccccc", colspan=8) - user_table.AddRow(map(Center, ['member address', 'subscr', - 'hide', 'nomail', 'ack', 'not metoo', - 'digest', 'plain'])) + user_table.AddRow(map(Center, [_('member address'), _('subscr'), + _('hide'), _('nomail'), _('ack'), _('not metoo'), + _('digest'), _('plain')])) rowindex = user_table.GetCurrentRowIndex() for i in range(8): user_table.AddCellInfo(rowindex, i, bgcolor='#cccccc') @@ -546,15 +558,15 @@ def FormatMembershipOptions(mlist, cgi_data): else: chunk = string.atoi(cgi_data["chunk"].value) all = chunks[chunk] - footer = ("<p><em>To View other sections, " - "click on the appropriate range listed below</em>") + footer = (_("<p><em>To View other sections, " + "click on the appropriate range listed below</em>")) chunk_indices = range(len(chunks)) chunk_indices.remove(chunk) buttons = [] for ci in chunk_indices: start, end = chunks[ci][0], chunks[ci][-1] url = mlist.GetScriptURL('admin') - buttons.append("<a href=%s/members?chunk=%d> from %s to %s </a>" + buttons.append("<a href=%s/members?chunk=%d>" + _("from %s to %s") + "</a>" % (url, ci, start, end)) buttons = apply(UnorderedList, tuple(buttons)) footer = footer + buttons.Format() + "<p>" @@ -592,25 +604,25 @@ def FormatMembershipOptions(mlist, cgi_data): user_table.AddRow(cells) container.AddItem(Center(user_table)) legend = UnorderedList() - legend.AddItem('<b>subscr</b> -- Is the member subscribed?') - legend.AddItem("<b>hide</b> -- Is the member's address " - "concealed on the list of subscribers?") - legend.AddItem('<b>nomail</b> -- Is delivery to the member disabled?') - legend.AddItem('<b>ack</b> -- ' - 'Does the member get acknowledgements of their posts?') - legend.AddItem('<b>not metoo</b> -- ' - 'Does the member avoid copies of their own posts?') - legend.AddItem('<b>digest</b> -- ' - 'Does the member get messages in digests? ' - '(otherwise, individual messages)') + legend.AddItem(_('<b>subscr</b> -- Is the member subscribed?')) + legend.AddItem(_("<b>hide</b> -- Is the member's address " + "concealed on the list of subscribers?")) + legend.AddItem(_('<b>nomail</b> -- Is delivery to the member disabled?')) + legend.AddItem(_('<b>ack</b> -- ' + 'Does the member get acknowledgements of their posts?')) + legend.AddItem(_('<b>not metoo</b> -- ' + 'Does the member avoid copies of their own posts?')) + legend.AddItem(_('<b>digest</b> -- ' + 'Does the member get messages in digests? ' + '(otherwise, individual messages)')) legend.AddItem( - '<b>plain</b> -- ' - 'If getting digests, does the member get plain text digests? ' - '(otherwise, MIME)') + _('<b>plain</b> -- ' + 'If getting digests, does the member get plain text digests? ' + '(otherwise, MIME)')) container.AddItem(legend.Format()) container.AddItem(footer) t = Table(width="90%") - t.AddRow([Center(Header(4, "Mass Subscribe Members"))]) + t.AddRow([Center(Header(4, _("Mass Subscribe Members")))]) t.AddCellInfo(t.GetCurrentRowIndex(), t.GetCurrentCellIndex(), bgcolor="#cccccc", colspan=8) @@ -620,14 +632,14 @@ def FormatMembershipOptions(mlist, cgi_data): else: nochecked = 1 yeschecked = 0 - t.AddRow([("<b>1.</b> Send Welcome message to this batch? " + t.AddRow([("<b>1.</b>" + _("Send Welcome message to this batch? ") + RadioButton("send_welcome_msg_to_this_batch", 0, nochecked).Format() - + " no " + + _(" no ") + RadioButton("send_welcome_msg_to_this_batch", 1, yeschecked).Format() - + " yes ")]) - t.AddRow(["<b>2.</b> Enter one address per line: <p>"]) + + _(" yes "))]) + t.AddRow(["<b>2.</b>" + _("Enter one address per line:") + "<p>"]) container.AddItem(Center(t)) container.AddItem(Center(TextArea(name='subscribees', rows=10,cols=60,wrap=None))) @@ -640,17 +652,17 @@ def FormatPasswordStuff(): cellspacing=0, cellpadding=2, valign="top") change_pw_table.AddRow( - [Bold(Center('To Change The Administrator Password'))]) + [Bold(Center(_('To Change The Administrator Password')))]) change_pw_table.AddCellInfo(0, 0, align="left", colspan=2) old = Table(bgcolor="#99cccc", border=1, cellspacing=0, cellpadding=2, valign="top") - old.AddRow(['<div ALIGN="right"> Enter current password:</div>', + old.AddRow(['<div ALIGN="right">' + _(" Enter current password:") + '</div>', PasswordBox('adminpw')]) new = Table(bgcolor="#99cccc", border=1, cellspacing=0, cellpadding=2, valign="top") - new.AddRow(['<div ALIGN="right"> Enter new password: </div>', + new.AddRow(['<div ALIGN="right">' + _(" Enter new password:") + '</div>', PasswordBox('newpw')]) - new.AddRow(['<div ALIGN="right">Confirm new password:</div>', + new.AddRow(['<div ALIGN="right">' + _("Confirm new password:") + '</div>', PasswordBox('confirmpw')]) change_pw_table.AddRow([old, new]) change_pw_table.AddCellInfo(1, 0, align="left", valign="top") @@ -662,7 +674,7 @@ def FormatPasswordStuff(): def FormatSubmit(): submit = Table(bgcolor="#99ccff", border=0, cellspacing=0, cellpadding=2) - submit.AddRow([Bold(SubmitButton('submit', 'Submit Your Changes'))]) + submit.AddRow([Bold(SubmitButton('submit', _('Submit Your Changes')))]) submit.AddCellInfo(submit.GetCurrentRowIndex(), 0, align="middle") return submit @@ -758,25 +770,25 @@ def ChangeOptions(mlist, category, cgi_info, document): confirmed = 1 except Errors.MMBadPasswordError: AddErrorMessage(document, - 'Incorrect administrator password', + _('Incorrect administrator password'), tag='Error: ') if confirmed: new = string.strip(cgi_info['newpw'].value) confirm = string.strip(cgi_info['confirmpw'].value) if new == '' and confirm == '': AddErrorMessage(document, - 'Empty admin passwords are not allowed', + _('Empty admin passwords are not allowed'), tag='Error: ') elif new == confirm: mlist.password = crypt(new, Utils.GetRandomSeed()) # Re-authenticate (to set new cookie) mlist.WebAuthenticate(password=new, cookie='admin') else: - AddErrorMessage(document, 'Passwords did not match', + AddErrorMessage(document, _('Passwords did not match'), tag='Error: ') else: AddErrorMessage(document, - 'You must type in your new password twice', + _('You must type in your new password twice'), tag='Error: ') # # for some reason, the login page mangles important values for the list @@ -827,9 +839,9 @@ def ChangeOptions(mlist, category, cgi_info, document): if property == 'real_name' and \ string.lower(value) <> string.lower(mlist._internal_name): # then don't install this value. - document.AddItem("""<p><b>real_name</b> attribute not + document.AddItem(_("""<p><b>real_name</b> attribute not changed! It must differ from the list's name by case - only.<p>""") + only.<p>""")) continue setattr(mlist, property, value) # @@ -858,22 +870,22 @@ def ChangeOptions(mlist, category, cgi_info, document): # result[name] is set from sys.exc_info()[:2] e, v = result[name] if e is Errors.MMAlreadyAMember: - subscribe_errors.append((name, 'Already a member')) + subscribe_errors.append((name, _('Already a member'))) elif e is Errors.MMBadEmailError: if name == '': name = '<blank line>' subscribe_errors.append( - (name, "Bad/Invalid email address")) + (name, _("Bad/Invalid email address"))) elif e is Errors.MMHostileAddress: subscribe_errors.append( - (name, "Hostile Address (illegal characters)")) + (name, _("Hostile Address (illegal characters)"))) if subscribe_success: - document.AddItem(Header(5, "Successfully Subscribed:")) + document.AddItem(Header(5, _("Successfully Subscribed:"))) document.AddItem(apply(UnorderedList, tuple((subscribe_success)))) document.AddItem("<p>") # ApprovedAddMembers will already have saved the list for us. if subscribe_errors: - document.AddItem(Header(5, "Error Subscribing:")) + document.AddItem(Header(5, _("Error Subscribing:"))) items = map(lambda x: "%s -- %s" % (x[0], x[1]), subscribe_errors) document.AddItem(apply(UnorderedList, tuple((items)))) document.AddItem("<p>") @@ -894,7 +906,7 @@ def ChangeOptions(mlist, category, cgi_info, document): try: mlist.DeleteMember(user) except Errors.MMNoSuchUserError: - errors.append((user, 'Not subscribed')) + errors.append((user, _('Not subscribed'))) continue value = cgi_info.has_key('%s_digest' % user) try: @@ -910,7 +922,7 @@ def ChangeOptions(mlist, category, cgi_info, document): else: mlist.SetUserOption(user, opt_code, 0, save_list=0) if errors: - document.AddItem(Header(5, "Error Unsubscribing:")) + document.AddItem(Header(5, _("Error Unsubscribing:"))) items = map(lambda x: "%s -- %s" % (x[0], x[1]), errors) document.AddItem(apply(UnorderedList, tuple((items)))) document.AddItem("<p>") diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py index fa07655db..44eead820 100644 --- a/Mailman/Cgi/admindb.py +++ b/Mailman/Cgi/admindb.py @@ -32,21 +32,21 @@ from Mailman.htmlformat import * from Mailman.Logging.Syslog import syslog - + def handle_no_list(doc, extra=''): - doc.SetTitle('Mailman Admindb Error') - doc.AddItem(Header(2, 'Mailman Admindb Error')) + doc.SetTitle(_('Mailman Admindb Error')) + doc.AddItem(Header(2, _('Mailman Admindb Error'))) doc.AddItem(extra) - doc.AddItem('You must specify a list name. Here is the ') + doc.AddItem(_('You must specify a list name. Here is the ')) link = mm_cfg.DEFAULT_URL if link[-1] <> '/': link = link + '/' link = link + 'admin' - doc.AddItem(Link(link, 'list of available mailing lists.')) + doc.AddItem(Link(link, _('list of available mailing lists.'))) print doc.Format(bgcolor="#ffffff") - + def main(): doc = Document() # figure out which list we're going to process @@ -64,7 +64,7 @@ def main(): try: mlist = MailList.MailList(listname) except Errors.MMListError, e: - handle_no_list(doc, 'No such list <em>%s</em><p>' % listname) + handle_no_list(doc, _('No such list <em>%s</em><p>') % listname) syslog('error', 'No such list "%s": %s\n' % (listname, e)) return # @@ -83,11 +83,12 @@ def main(): # print the results. otherwise (there are no keys in the form), we'll # print out the list of pending requests # + realname = mlist.real_name if len(cgidata.keys()): - doc.SetTitle("%s Admindb Results" % mlist.real_name) + doc.SetTitle(_("%(realname)s Admindb Results")) HandleRequests(mlist, doc, cgidata) else: - doc.SetTitle("%s Admindb" % mlist.real_name) + doc.SetTitle(_("%(realname)s Admindb")) PrintRequests(mlist, doc) text = doc.Format(bgcolor="#ffffff") print text @@ -96,16 +97,16 @@ def main(): mlist.Unlock() - + def PrintRequests(mlist, doc): # The only types of requests we know about are add member and post. # Anything else that might have gotten in here somehow we'll just ignore # (This should never happen unless someone is hacking at the code). - doc.AddItem(Header(2, 'Administrative requests for mailing list: <em>' + + doc.AddItem(Header(2, _('Administrative requests for mailing list:') + ' <em>' + mlist.real_name + '</em>')) # short circuit for when there are no pending requests if not mlist.NumRequestsPending(): - doc.AddItem('There are no pending requests.') + doc.AddItem(_('There are no pending requests.')) doc.AddItem(mlist.GetMailmanFooter()) return @@ -114,18 +115,18 @@ def PrintRequests(mlist, doc): doc.AddItem('.<p>') form = Form(mlist.GetScriptURL('admindb')) doc.AddItem(form) - form.AddItem(SubmitButton('submit', 'Submit All Data')) + form.AddItem(SubmitButton('submit', _('Submit All Data'))) # # Add the subscription request section subpendings = mlist.GetSubscriptionIds() if subpendings: form.AddItem('<hr>') - form.AddItem(Center(Header(2, 'Subscription Requests'))) + form.AddItem(Center(Header(2, _('Subscription Requests')))) t = Table(border=2) t.AddRow([ - Bold('Address'), - Bold('Your Decision'), - Bold('If you refuse this subscription, please explain (optional)') + Bold(_('Address')), + Bold(_('Your Decision')), + Bold(_('If you refuse this subscription, please explain (optional)')) ]) for id in subpendings: PrintAddMemberRequest(mlist, id, t) @@ -140,15 +141,15 @@ def PrintRequests(mlist, doc): PrintPostRequest(mlist, id, info, total, count, form) count = count + 1 form.AddItem('<hr>') - form.AddItem(SubmitButton('submit', 'Submit All Data')) + form.AddItem(SubmitButton('submit', _('Submit All Data'))) doc.AddItem(mlist.GetMailmanFooter()) - + def PrintAddMemberRequest(mlist, id, table): time, addr, passwd, digest = mlist.GetRecord(id) table.AddRow([addr, - RadioButtonArray(id, ('Subscribe', 'Refuse'), + RadioButtonArray(id, (_('Subscribe'), _('Refuse')), values=(mm_cfg.SUBSCRIBE, mm_cfg.REJECT)), TextBox('comment-%d' % id, size=60) ]) @@ -161,9 +162,9 @@ def PrintPostRequest(mlist, id, info, total, count, form): else: ptime, sender, subject, reason, filename, msgdata = info form.AddItem('<hr>') - msg = 'Posting Held for Approval' + msg = _('Posting Held for Approval') if total <> 1: - msg = msg + ' (%d of %d)' % (count, total) + msg = msg + _(' (%d of %d)') % (count, total) form.AddItem(Center(Header(2, msg))) try: fp = open(os.path.join(mm_cfg.DATA_DIR, filename)) @@ -172,7 +173,7 @@ def PrintPostRequest(mlist, id, info, total, count, form): text = msg.body[:mm_cfg.ADMINDB_PAGE_TEXT_LIMIT] except IOError, (code, msg): if code == ENOENT: - form.AddItem('<em>Message with id #%d was lost.' % id) + form.AddItem(_('<em>Message with id #%d was lost.') % id) form.AddItem('<p>') # TBD: kludge to remove id from requests.db. value==2 means # discard the message. @@ -183,58 +184,58 @@ def PrintPostRequest(mlist, id, info, total, count, form): return raise t = Table(cellspacing=0, cellpadding=0, width='100%') - t.AddRow([Bold('From:'), sender]) + t.AddRow([Bold(_('From:')), sender]) row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex() t.AddCellInfo(row, col-1, align='right') - t.AddRow([Bold('Subject:'), subject]) + t.AddRow([Bold(_('Subject:')), subject]) t.AddCellInfo(row+1, col-1, align='right') - t.AddRow([Bold('Reason:'), reason]) + t.AddRow([Bold(_('Reason:')), reason]) t.AddCellInfo(row+2, col-1, align='right') # We can't use a RadioButtonArray here because horizontal placement can be # confusing to the user and vertical placement takes up too much # real-estate. This is a hack! buttons = Table(cellspacing="5", cellpadding="0") buttons.AddRow(map(lambda x, s=' '*5: s+x+s, - ('Defer', 'Approve', 'Reject', 'Discard'))) + (_('Defer'), _('Approve'), _('Reject'), _('Discard')))) buttons.AddRow([Center(RadioButton(id, mm_cfg.DEFER, 1)), Center(RadioButton(id, mm_cfg.APPROVE, 0)), Center(RadioButton(id, mm_cfg.REJECT, 0)), Center(RadioButton(id, mm_cfg.DISCARD, 0)), ]) - t.AddRow([Bold('Action:'), buttons]) + t.AddRow([Bold(_('Action:')), buttons]) t.AddCellInfo(row+3, col-1, align='right') t.AddRow([' ', CheckBox('preserve-%d' % id, 'on', 0).Format() + - ' Preserve message for site administrator' + ' ' + _('Preserve message for site administrator') ]) t.AddRow([' ', CheckBox('forward-%d' % id, 'on', 0).Format() + - ' Additionally, forward this message to: ' + + ' ' + _('Additionally, forward this message to: ') + TextBox('forward-addr-%d' % id, size=47, value=mlist.GetOwnerEmail()).Format() ]) t.AddRow([ - Bold('If you reject this post,<br>please explain (optional):'), + Bold(_('If you reject this post,<br>please explain (optional):')), TextArea('comment-%d' % id, rows=4, cols=80, text = Utils.wrap(msgdata.get('rejection-notice', - '[No explanation given]'), + _('[No explanation given]')), column=80)) ]) row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex() t.AddCellInfo(row, col-1, align='right') - t.AddRow([Bold('Message Headers:'), + t.AddRow([Bold(_('Message Headers:')), TextArea('headers-%d' % id, string.join(msg.headers, ''), rows=10, cols=80)]) row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex() t.AddCellInfo(row, col-1, align='right') - t.AddRow([Bold('Message Excerpt:'), + t.AddRow ([Bold(_('Message Excerpt:')), TextArea('fulltext-%d' % id, text, rows=10, cols=80)]) t.AddCellInfo(row+1, col-1, align='right') form.AddItem(t) form.AddItem('<p>') - + def HandleRequests(mlist, doc, cgidata): erroraddrs = [] for k in cgidata.keys(): @@ -252,7 +253,7 @@ def HandleRequests(mlist, doc, cgidata): forwardkey = 'forward-%d' % request_id forwardaddrkey = 'forward-addr-%d' % request_id # defaults - comment = '[No reason given]' + comment = _('[No reason given]') preserve = 0 forward = 0 forwardaddr = '' @@ -277,7 +278,7 @@ def HandleRequests(mlist, doc, cgidata): erroraddrs.append(v) # save the list and print the results mlist.Save() - doc.AddItem(Header(2, 'Database Updated...')) + doc.AddItem(Header(2, _('Database Updated...'))) if erroraddrs: for addr in erroraddrs: - doc.AddItem(`addr` + ' is already a member<br>') + doc.AddItem(`addr` + _(' is already a member') + '<br>') diff --git a/Mailman/Cgi/edithtml.py b/Mailman/Cgi/edithtml.py index 76c3338e9..8c7f8fec3 100644 --- a/Mailman/Cgi/edithtml.py +++ b/Mailman/Cgi/edithtml.py @@ -32,16 +32,16 @@ from Mailman.Logging.Syslog import syslog def main(): template_data = ( - ('listinfo.html', 'General list information page'), - ('subscribe.html', 'Subscribe results page'), - ('options.html', 'User specific options page'), - ('handle_opts.html', 'Changing user options results page'), + ('listinfo.html', _('General list information page')), + ('subscribe.html', _('Subscribe results page')), + ('options.html', _('User specific options page')), + ('handle_opts.html', _('Changing user options results page')), ) doc = Document() parts = Utils.GetPathPieces() if not parts: - doc.AddItem(Header(2, "List name is required.")) + doc.AddItem(Header(2, _("List name is required."))) print doc.Format(bgcolor='#ffffff') return @@ -49,9 +49,9 @@ def main(): try: mlist = MailList.MailList(listname, lock=0) except Errors.MMListError, e: - doc.AddItem(Header(2, 'No such list <em>%s</em>' % listname)) + doc.AddItem(Header(2, _('No such list <em>%s</em>') % listname)) print doc.Format(bgcolor='#ffffff') - syslog('error', 'No such list "%s": %s\n' % (listname, e)) + syslog('error', _('No such list "%s": %s\n') % (listname, e)) return # Must be authenticated to get any farther @@ -65,27 +65,28 @@ def main(): # get the list._template_dir attribute HTMLFormatter.InitVars(mlist) + realname = mlist.real_name if len(parts) > 1: template_name = parts[1] for (template, info) in template_data: if template == template_name: - template_info = info - doc.SetTitle('%s -- Edit html for %s' % - (mlist.real_name, template_info)) + template_info = _(info) + doc.SetTitle(_( + '%(realname)s -- Edit html for %(template_info)s')) break else: - doc.SetTitle('Edit HTML : Error') - doc.AddItem(Header(2, "%s: Invalid template" % template_name)) + doc.SetTitle(_('Edit HTML : Error')) + doc.AddItem(Header(2, _("%s: Invalid template") % template_name)) doc.AddItem(mlist.GetMailmanFooter()) print doc.Format(bgcolor='#ffffff') return else: - doc.SetTitle('%s -- HTML Page Editing' % mlist.real_name) - doc.AddItem(Header(1, '%s -- HTML Page Editing' % mlist.real_name)) - doc.AddItem(Header(2, 'Select page to edit:')) + doc.SetTitle(_('%(realname)s -- HTML Page Editing')) + doc.AddItem(Header(1, _('%(realname)s -- HTML Page Editing'))) + doc.AddItem(Header(2, _('Select page to edit:'))) template_list = UnorderedList() for (template, info) in template_data: - l = Link(mlist.GetScriptURL('edithtml') + '/' + template, info) + l = Link(mlist.GetScriptURL('edithtml') + '/' + template, _(info)) template_list.AddItem(l) doc.AddItem(FontSize("+2", template_list)) doc.AddItem(mlist.GetMailmanFooter()) @@ -108,7 +109,7 @@ def FormatHTML(mlist, doc, template_name, template_info): doc.AddItem('<hr>') link = Link(mlist.GetScriptURL('admin'), - 'View or edit the list configuration information.') + _('View or edit the list configuration information.')) doc.AddItem(FontSize("+1", link)) doc.AddItem('<p>') @@ -116,21 +117,21 @@ def FormatHTML(mlist, doc, template_name, template_info): form = Form(mlist.GetScriptURL('edithtml') + '/' + template_name) text = Utils.QuoteHyperChars(mlist.SnarfHTMLTemplate(template_name)) form.AddItem(TextArea('html_code', text, rows=40, cols=75)) - form.AddItem('<p>When you are done making changes...') - form.AddItem(SubmitButton('submit', 'Submit Changes')) + form.AddItem('<p>' + _('When you are done making changes...')) + form.AddItem(SubmitButton('submit', _('Submit Changes'))) doc.AddItem(form) def ChangeHTML(mlist, cgi_info, template_name, doc): if not cgi_info.has_key('html_code'): - doc.AddItem(Header(3,"Can't have empty html page.")) - doc.AddItem(Header(3,"HTML Unchanged.")) + doc.AddItem(Header(3,_("Can't have empty html page."))) + doc.AddItem(Header(3,_("HTML Unchanged."))) doc.AddItem('<hr>') return code = cgi_info['html_code'].value f = open(os.path.join(mlist._template_dir, template_name), 'w') f.write(code) f.close() - doc.AddItem(Header(3, 'HTML successfully updated.')) + doc.AddItem(Header(3, _('HTML successfully updated.'))) doc.AddItem('<hr>') diff --git a/Mailman/Cgi/handle_opts.py b/Mailman/Cgi/handle_opts.py index ff9d6dd98..74f3f4ba9 100644 --- a/Mailman/Cgi/handle_opts.py +++ b/Mailman/Cgi/handle_opts.py @@ -34,8 +34,8 @@ def PrintResults(mlist, operation, doc, results, user=None): if user: url = '%s/%s' % (mlist.GetScriptURL('options'), Utils.ObscureEmail(user)) - results = results + '<p>Continue to ' + \ - Link(url, 'edit your personal options').Format() + \ + results = results + _('<p>Continue to ') + \ + Link(url, _('edit your personal options')).Format() + \ '.' replacements = mlist.GetStandardReplacements() replacements['<mm-results>'] = results @@ -52,8 +52,8 @@ def main(): doc = Document() parts = Utils.GetPathPieces() if not parts or len(parts) < 2: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold("Invalid options to CGI script.")) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_("Invalid options to CGI script."))) print doc.Format(bgcolor="#ffffff") return @@ -63,8 +63,8 @@ def main(): try: mlist = MailList.MailList(listname) except Errors.MMListError, e: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold('No such list <em>%s</em>' % listname)) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_('No such list <em>%s</em>') % listname)) print doc.Format(bgcolor="#ffffff") syslog('error', 'No such list "%s": %s\n' % (listname, e)) return @@ -85,13 +85,13 @@ def process_form(mlist, user, doc): if not Utils.FindMatchingAddresses(user, mlist.members, mlist.digest_members): - PrintResults(mlist, operation, doc, "%s not a member!<p>" % user) + PrintResults(mlist, operation, doc, _("%s not a member!<p>") % user) if form.has_key("unsub"): operation = "Unsubscribe" if not form.has_key("upw"): PrintResults(mlist, operation, doc, - "You must give your password to unsubscribe.<p>", + _("You must give your password to unsubscribe.") + "<p>", user) else: try: @@ -99,58 +99,58 @@ def process_form(mlist, user, doc): if mlist.ConfirmUserPassword(user, pw): mlist.DeleteMember(user, "web cmd") except Errors.MMListNotReadyError: - PrintResults(mlist, operation, doc, "List is not functional.", + PrintResults(mlist, operation, doc, _("List is not functional."), user) except Errors.MMNoSuchUserError: PrintResults(mlist, operation, doc, - "You seem to already be not a member.<p>", user) + _("You seem to already be not a member.") + "<p>", user) except Errors.MMBadUserError: PrintResults(mlist, operation, doc, - "Your account has gone awry - " - "please contact the list administrator!<p>", user) + _("Your account has gone awry - " + "please contact the list administrator!") + "<p>", user) except Errors.MMBadPasswordError: PrintResults(mlist, operation, doc, - "That password was incorrect.<p>") - PrintResults(mlist, operation, doc, "You have been unsubscribed.<p>") + _("That password was incorrect.") + "<p>") + PrintResults(mlist, operation, doc, _("You have been unsubscribed.") + "<p>") elif form.has_key("emailpw"): try: mlist.MailUserPassword(user) PrintResults(mlist, operation, doc, - "A reminder of your password " - "has been emailed to you.<p>", user) + _("A reminder of your password " + "has been emailed to you.") + "<p>", user) except Errors.MMBadUserError: PrintResults(mlist, operation, doc, - "The password entry for `%s' has not " + _("The password entry for `%s' has not " 'been found. The list administrator is being ' - 'notified.<p>' % user, user) + 'notified.<p>') % user, user) elif form.has_key("othersubs"): if not form.has_key('othersubspw'): PrintResults(mlist, operation, doc, - "You must specify your password.", user) + _("You must specify your password."), user) else: try: mlist.ConfirmUserPassword(user, form['othersubspw'].value) except Errors.MMListNotReadyError: PrintResults(mlist, operation, doc, - "The list is currently not functional.", user) + _("The list is currently not functional."), user) except Errors.MMNotAMemberError: PrintResults(mlist, operation, doc, - "You seem to no longer be a list member.", user) + _("You seem to no longer be a list member."), user) except Errors.MMBadPasswordError: - PrintResults(mlist, operation, doc, "Incorrect password.", + PrintResults(mlist, operation, doc, _("Incorrect password."), user) except Errors.MMBadUserError: PrintResults( mlist, operation, doc, - "You have no password. Contact the list administrator.", + _("You have no password. Contact the list administrator."), user) - doc.AddItem(Header(2, "List Subscriptions for %s on %s" + doc.AddItem(Header(2, _("List Subscriptions for %s on %s") % (user, mlist.host_name))) - doc.AddItem("Click a link to visit your options page for" - " that mailing list:") + doc.AddItem(_("Click a link to visit your options page for" + " that mailing list:")) def optionslinks(listname, user=user): mlist = MailList.MailList(listname, lock=0) @@ -183,27 +183,27 @@ def process_form(mlist, user, doc): form['confpw'].value) except Errors.MMListNotReadyError: PrintResults(mlist, operation, doc, - "The list is currently not functional.", + _("The list is currently not functional."), user) except Errors.MMNotAMemberError: PrintResults(mlist, operation, doc, - "You seem to no longer be a list member.", + _("You seem to no longer be a list member."), user) except Errors.MMBadPasswordError: PrintResults(mlist, operation, doc, - "The old password you supplied was incorrect.", + _("The old password you supplied was incorrect."), user) except Errors.MMPasswordsMustMatch: - PrintResults(mlist, operation, doc, "Passwords must match.", + PrintResults(mlist, operation, doc, _("Passwords must match."), user) PrintResults(mlist, operation, doc, - "Your password has been changed.", + _("Your password has been changed."), user) else: PrintResults(mlist, operation, doc, - "You must specify your old password," - " and your new password twice.", user) + _("You must specify your old password," + " and your new password twice."), user) else: # if key doesn't exist, or its value can't be int()'ified, return the @@ -228,7 +228,7 @@ def process_form(mlist, user, doc): if not form.has_key("digpw"): PrintResults(mlist, operation, doc, - "You must supply a password to change options.", + _("You must supply a password to change options."), user) try: mlist.ConfirmUserPassword(user, form['digpw'].value) @@ -238,46 +238,46 @@ def process_form(mlist, user, doc): pass except Errors.MMMustDigestError: PrintResults(mlist, operation, doc, - "List only accepts digest members.", user) + _("List only accepts digest members."), user) except Errors.MMCantDigestError: PrintResults(mlist, operation, doc, - "List doesn't accept digest members.", user) + _("List doesn't accept digest members."), user) except Errors.MMNotAMemberError: PrintResults(mlist, operation, doc, - "%s isn't subscribed to this list." + _("%s isn't subscribed to this list.") % mail.GetSender(), user) except Errors.MMListNotReadyError: - PrintResults(mlist, operation, doc, "List is not functional.", + PrintResults(mlist, operation, doc, _("List is not functional."), user) except Errors.MMNoSuchUserError: PrintResults(mlist, operation, doc, - "%s is not subscribed to this list." + _("%s is not subscribed to this list.") % mail.GetSender(), user) except Errors.MMBadPasswordError: PrintResults(mlist, operation, doc, - "You gave the wrong password.", user) + _("You gave the wrong password."), user) mlist.SetUserOption(user, mm_cfg.DisableDelivery, disable_mail) mlist.SetUserOption(user, mm_cfg.DontReceiveOwnPosts, dont_receive) mlist.SetUserOption(user, mm_cfg.AcknowledgePosts, ack_posts) mlist.SetUserOption(user, mm_cfg.DisableMime, mime) - msg = 'You have successfully set your options.' + msg = _('You have successfully set your options.') try: mlist.SetUserDigest(user, digest_value) # digest mode changed from on to off, so send the current digest # to the user. if digest_value == 0: PrintResults(mlist, operation, doc, - 'You may get one last digest.', user) + _('You may get one last digest.'), user) except (Errors.MMAlreadyDigested, Errors.MMAlreadyUndigested): pass except Errors.MMCantDigestError: - msg = '''The list administrator has disabled digest delivery for + msg = _('''The list administrator has disabled digest delivery for this list, so your delivery option has not been set. However your - other options have been set successfully.''' + other options have been set successfully.''') except Errors.MMMustDigestError: - msg = '''The list administrator has disabled non-digest delivery + msg = _('''The list administrator has disabled non-digest delivery for this list, so your delivery option has not been set. However - your other options have been set successfully.''' + your other options have been set successfully.''') mlist.SetUserOption(user, mm_cfg.ConcealSubscription, conceal) PrintResults(mlist, operation, doc, msg, user) diff --git a/Mailman/Cgi/listinfo.py b/Mailman/Cgi/listinfo.py index 8c9e78229..3d5b10155 100644 --- a/Mailman/Cgi/listinfo.py +++ b/Mailman/Cgi/listinfo.py @@ -41,7 +41,7 @@ def main(): try: mlist = MailList.MailList(listname, lock=0) except Errors.MMListError, e: - FormatListinfoOverview('No such list <em>%s</em>' % listname) + FormatListinfoOverview(_('No such list <em>%(listname)s</em>')) syslog('error', 'listinfo: no such list "%s": %s' % (listname, e)) return @@ -65,7 +65,7 @@ def FormatListinfoOverview(error=None): host_name = mm_cfg.DEFAULT_HOST_NAME doc = Document() - legend = "%s Mailing Lists" % host_name + legend = _("%(hostname)s Mailing Lists") doc.SetTitle(legend) table = Table(border=0, width="100%") @@ -92,52 +92,49 @@ def FormatListinfoOverview(error=None): if error: greeting = FontAttr(error, color="ff5060", size="+1") else: - greeting = FontAttr('Welcome!', size='+2') + greeting = FontAttr(_('Welcome!'), size='+2') + welcomeitems = [greeting] if not advertised: - welcome_items = (greeting, - "<p>" - " There currently are no publicly-advertised ", - Link(mm_cfg.MAILMAN_URL, "mailman"), - " mailing lists on %s." % host_name, - ) + welcomeitems.extend( + ("<p>" + + _(" There currently are no publicly-advertised "), + Link(mm_cfg.MAILMAN_URL, "mailman"), + _(" mailing lists on %(host_name)s."))) else: - welcome_items = ( - greeting, - '''<p>Below is a listing of all the public mailing lists on - %(hostname)s. Click on a list name to get more information about + welcomeitems.append( + _('''<p>Below is a listing of all the public mailing lists on + %(host_name)s. Click on a list name to get more information about the list, or to subscribe, unsubscribe, and change the preferences - on your subscription.''' % {'hostname': host_name}, - ) + on your subscription.''')) - welcome_items = (welcome_items + - (" To visit the info page for an unadvertised list," - " open a URL similar to this one, but with a '/' and" - + - (" the %slist name appended." - % ((error and "right ") or "")) - + - '<p> List administrators, you can visit ', - Link(Utils.ScriptURL('admin'), - 'the list admin overview page'), - " to find the management interface for your list." - "<p>(Send questions or comments to ", - Link("mailto:%s" % mm_cfg.MAILMAN_OWNER, - mm_cfg.MAILMAN_OWNER), - ".)<p>")) + # set up some local variables + adj = error and _('right') or '' + welcomeitems.extend( + (_(''' To visit the info page for an unadvertised list, + a URL similar to this one, but with a "/" and the %(adj)s + list name appended. + <p>List administrators, you can visit '''), + Link(Utils.ScriptURL('admin'), + _('the list admin overview page')), + _(''' to find the management interface for your list. + <p>Send questions or comments to '''), + Link('mailto:' + mm_cfg.MAILMAN_OWNER, + mm_cfg.MAILMAN_OWNER), + '.<p>')) - table.AddRow([apply(Container, welcome_items)]) + table.AddRow([apply(Container, welcomeitems)]) table.AddCellInfo(max(table.GetCurrentRowIndex(), 0), 0, colspan=2) if advertised: table.AddRow([' ', ' ']) - table.AddRow([Bold(FontAttr('List', size='+2')), - Bold(FontAttr('Description', size='+2')) + table.AddRow([Bold(FontAttr(_('List'), size='+2')), + Bold(FontAttr(_('Description'), size='+2')) ]) for mlist in advertised: table.AddRow( [Link(mlist.GetScriptURL('listinfo'), Bold(mlist.real_name)), - mlist.description or Italic('[no description available]')]) + mlist.description or Italic(_('[no description available]'))]) doc.AddItem(table) doc.AddItem('<hr>') @@ -165,7 +162,7 @@ def FormatListListinfo(mlist): replacements['<mm-mime-digests-button>'] = mlist.FormatMimeDigestsButton() replacements['<mm-subscribe-box>'] = mlist.FormatBox('email', size=30) replacements['<mm-subscribe-button>'] = mlist.FormatButton( - 'email-button', text='Subscribe') + 'email-button', text=_('Subscribe')) replacements['<mm-new-password-box>'] = mlist.FormatSecureBox('pw') replacements['<mm-confirm-password>'] = mlist.FormatSecureBox('pw-conf') replacements['<mm-subscribe-form-start>'] = mlist.FormatFormStart( @@ -173,7 +170,7 @@ def FormatListListinfo(mlist): replacements['<mm-roster-form-start>'] = mlist.FormatFormStart('roster') replacements['<mm-editing-options>'] = mlist.FormatEditingOption() replacements['<mm-info-button>'] = SubmitButton('UserOptions', - 'Edit Options').Format() + _('Edit Options')).Format() replacements['<mm-roster-option>'] = mlist.FormatRosterOptionForUser() # Do the expansion. diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py index c79e90459..f986389df 100644 --- a/Mailman/Cgi/options.py +++ b/Mailman/Cgi/options.py @@ -41,8 +41,8 @@ def main(): doc = HeadlessDocument() parts = Utils.GetPathPieces() if not parts or len(parts) < 2: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold("Invalid options to CGI script.")) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_("Invalid options to CGI script."))) print doc.Format() return @@ -53,8 +53,8 @@ def main(): try: mlist = MailList.MailList(listname, lock=0) except Errors.MMListError, e: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold('No such list <em>%s</em>' % listname)) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_('No such list <em>%s</em>') % listname)) print doc.Format() syslog('error', 'No such list "%s": %s\n' % (listname, e)) return @@ -64,8 +64,8 @@ def main(): if not mlist.members.has_key(user) and \ not mlist.digest_members.has_key(user): # then - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold("%s: No such member %s." % (listname, `user`))) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_("%s: No such member %s.") % (listname, `user`))) doc.AddItem(mlist.GetMailmanFooter()) print doc.Format() return @@ -110,9 +110,9 @@ def main(): replacements['<mm-hide-subscription-button>'] = mlist.FormatOptionButton( mm_cfg.ConcealSubscription, 1, user) replacements['<mm-digest-submit>'] = mlist.FormatButton( - 'setdigest', 'Submit My Changes') + 'setdigest', _('Submit My Changes')) replacements['<mm-unsubscribe-button>'] = ( - mlist.FormatButton('unsub', 'Unsubscribe')) + mlist.FormatButton('unsub', _('Unsubscribe'))) replacements['<mm-digest-pw-box>'] = mlist.FormatSecureBox('digpw') replacements['<mm-unsub-pw-box>'] = mlist.FormatSecureBox('upw') replacements['<mm-old-pw-box>'] = mlist.FormatSecureBox('opw') @@ -122,23 +122,23 @@ def main(): mlist.FormatSecureBox('othersubspw')) replacements['<mm-other-subscriptions-submit>'] = ( mlist.FormatButton('othersubs', - 'List my other subscriptions')) + _('List my other subscriptions'))) replacements['<mm-change-pass-button>'] = ( - mlist.FormatButton('changepw', "Change My Password")) + mlist.FormatButton('changepw', _("Change My Password"))) replacements['<mm-form-start>'] = ( mlist.FormatFormStart('handle_opts', user)) replacements['<mm-user>'] = user replacements['<mm-presentable-user>'] = presentable_user replacements['<mm-email-my-pw>'] = mlist.FormatButton('emailpw', - ('Email My Password' - ' To Me')) + (_('Email My Password' + ' To Me'))) replacements['<mm-umbrella-notice>'] = ( - mlist.FormatUmbrellaNotice(user, "password")) + mlist.FormatUmbrellaNotice(user, _("password"))) if cpuser is not None: - replacements['<mm-case-preserved-user>'] = ''' + replacements['<mm-case-preserved-user>'] = _(''' You are subscribed to this list with the case-preserved address -<em>%s</em>.''' % cpuser +<em>%s</em>.''') % cpuser else: replacements['<mm-case-preserved-user>'] = '' diff --git a/Mailman/Cgi/private.py b/Mailman/Cgi/private.py index cef7a3b2a..d8d799eb3 100644 --- a/Mailman/Cgi/private.py +++ b/Mailman/Cgi/private.py @@ -94,8 +94,8 @@ def main(): doc = Document() parts = Utils.GetPathPieces() if not parts: - doc.SetTitle("Private Archive Error") - doc.AddItem(Header(3, "You must specify a list.")) + doc.SetTitle(_("Private Archive Error")) + doc.AddItem(Header(3, _("You must specify a list."))) print doc.Format(bgcolor="#FFFFFF") sys.exit(0) @@ -130,8 +130,8 @@ def main(): mlist = MailList.MailList(listname, lock=0) mlist.IsListInitialized() except Errors.MMListError, e: - msg = 'No such list <em>%s</em>' % listname - doc.SetTitle("Private Archive Error - %s" % msg) + msg = _('No such list <em>%s</em>') % listname + doc.SetTitle(_("Private Archive Error - %s") % msg) doc.AddItem(Header(2, msg)) print doc.Format(bgcolor="#FFFFFF") syslog('error', 'No such list "%s": %s\n' % (listname, e)) @@ -149,23 +149,23 @@ def main(): password = password.value is_auth = 0 - message = ("Please enter your %s subscription email address " - "and password." % mlist.real_name) + message = (_("Please enter your %s subscription email address " + "and password.") % mlist.real_name) try: is_auth = mlist.WebAuthenticate(user=user, password=password, cookie='archive') except (Errors.MMBadUserError, Errors.MMBadPasswordError, Errors.MMNotAMemberError): - message = ('Your email address or password were incorrect. ' - 'Please try again.') + message = (_('Your email address or password were incorrect. ' + 'Please try again.')) except Errors.MMExpiredCookieError: - message = 'Your cookie has gone stale, ' \ - 'enter password to get a new one.', + message = _('Your cookie has gone stale, ' \ + 'enter password to get a new one.'), except Errors.MMInvalidCookieError: - message = 'Error decoding authorization cookie.' + message = _('Error decoding authorization cookie.') except Errors.MMAuthenticationError: - message = 'Authentication error.' + message = _('Authentication error.') if not is_auth: # Output the password form @@ -192,8 +192,8 @@ def main(): except IOError: print 'Content-type: text/html\n' - print "<H3>Archive File Not Found</H3>" - print "No file", path, '(%s)' % true_filename + print "<H3>" + _("Archive File Not Found") + "</H3>" + print _("No file"), path, '(%s)' % true_filename else: print 'Content-type: %s\n' % ctype sys.stdout.write(f.read()) diff --git a/Mailman/Cgi/roster.py b/Mailman/Cgi/roster.py index 22cb305a3..5eb1a2443 100644 --- a/Mailman/Cgi/roster.py +++ b/Mailman/Cgi/roster.py @@ -40,14 +40,14 @@ def main(): parts = Utils.GetPathPieces() if not parts: - error_page('Invalid options to CGI script') + error_page(_('Invalid options to CGI script')) return listname = string.lower(parts[0]) try: mlist = MailList.MailList(listname, lock=0) except Errors.MMListError, e: - error_page('No such list <em>%s</em>' % listname) + error_page(_('No such list <em>%s</em>') % listname) syslog('error', 'roster: no such list "%s": %s' % (listname, e)) return @@ -60,7 +60,7 @@ def main(): # No privacy. bad = "" else: - auth_req = ("%s subscriber list requires authentication." + auth_req = (_("%s subscriber list requires authentication.") % mlist.real_name) if not form.has_key("roster-pw"): bad = auth_req @@ -80,12 +80,12 @@ def main(): except (Errors.MMBadUserError, Errors.MMBadPasswordError, Errors.MMNotAMemberError): - bad = ("%s subscriber authentication failed." + bad = (_("%s subscriber authentication failed.") % mlist.real_name) else: # Anonymous list - admin-only visible # - and we already tried admin password, above. - bad = ("%s admin authentication failed." + bad = (_("%s admin authentication failed.") % mlist.real_name) if bad: doc = error_page_doc(bad) @@ -108,8 +108,8 @@ def error_page_doc(errmsg, *args): Optional arg justreturn means just return the doc, don't print it.""" doc = htmlformat.Document() - doc.SetTitle("Error") - doc.AddItem(htmlformat.Header(2, "Error")) + doc.SetTitle(_("Error")) + doc.AddItem(htmlformat.Header(2, _("Error"))) doc.AddItem(htmlformat.Bold(errmsg % args)) return doc diff --git a/Mailman/Cgi/subscribe.py b/Mailman/Cgi/subscribe.py index a84f2c0ef..270e76dd2 100644 --- a/Mailman/Cgi/subscribe.py +++ b/Mailman/Cgi/subscribe.py @@ -34,8 +34,8 @@ def main(): doc = Document() parts = Utils.GetPathPieces() if not parts: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold('Invalid options to CGI script')) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_('Invalid options to CGI script'))) print doc.Format(bgcolor="#ffffff") return @@ -44,8 +44,8 @@ def main(): mlist = MailList.MailList(listname) mlist.IsListInitialized() except Errors.MMListError, e: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold('No such list <em>%s</em>' % listname)) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_('No such list <em>%s</em>') % listname)) print doc.Format(bgcolor="#ffffff") syslog('error', 'No such list "%s": %s\n' % (listname, e)) return @@ -84,8 +84,8 @@ def process_form(mlist, doc): # then # Go to user options section. if not form.has_key("info"): - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold("You must supply your email address.")) + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_("You must supply your email address."))) doc.AddItem(mlist.GetMailmanFooter()) print doc.Format(bgcolor="#ffffff") return @@ -93,8 +93,8 @@ def process_form(mlist, doc): addr = form['info'].value member = mlist.FindUser(addr) if not member: - doc.AddItem(Header(2, "Error")) - doc.AddItem(Bold("%s has no subscribed addr <i>%s</i>." + doc.AddItem(Header(2, _("Error"))) + doc.AddItem(Bold(_("%s has no subscribed addr <i>%s</i>.") % (mlist.real_name, addr))) doc.AddItem(mlist.GetMailmanFooter()) print doc.Format(bgcolor="#ffffff") @@ -106,7 +106,7 @@ def process_form(mlist, doc): if not form.has_key("email"): error = 1 - results = results + "You must supply a valid email address.<br>" + results = results + _("You must supply a valid email address.<br>") # # define email so we don't get a NameError below # with if email == mlist.GetListEmail() -scott @@ -119,25 +119,25 @@ def process_form(mlist, doc): if email == mlist.GetListEmail(): error = 1 if remote: - remote = "Web site " + remote + remote = _("Web site ") + remote else: - remote = "unidentified origin" + remote = _("unidentified origin") badremote = "\n\tfrom " + remote syslog("mischief", "Attempt to self subscribe %s:%s" % (email, badremote)) - results = results + "You must not subscribe a list to itself!<br>" + results = results + _("You must not subscribe a list to itself!<br>") if not form.has_key("pw") or not form.has_key("pw-conf"): error = 1 results = (results + - "You must supply a valid password, and confirm it.<br>") + _("You must supply a valid password, and confirm it.<br>")) else: pw = form["pw"].value pwc = form["pw-conf"].value if not error and pw <> pwc: error = 1 - results = results + "Your passwords did not match.<br>" + results = results + _("Your passwords did not match.<br>") if form.has_key("digest"): try: @@ -167,46 +167,46 @@ def process_form(mlist, doc): # options on the web page for this cgi # except Errors.MMBadEmailError: - results = results + ("Mailman won't accept the given email " + results = results + (_("Mailman won't accept the given email " "address as a valid address. (Does it " - "have an @ in it???)<p>") + "have an @ in it???)<p>")) except Errors.MMListError: - results = results + ("The list is not fully functional, and " - "can not accept subscription requests.<p>") + results = results + (_("The list is not fully functional, and " + "can not accept subscription requests.<p>")) except Errors.MMSubscribeNeedsConfirmation: - results = results + ("Confirmation from your email address is " + results = results + (_("Confirmation from your email address is " "required, to prevent anyone from " "subscribing you without permission. " "Instructions are being " "sent to you at %s. Please note your " "subscription will not start until you " - "confirm your subscription." % email) + "confirm your subscription.") % email) except Errors.MMNeedApproval, x: - results = results + ("Subscription was <em>deferred</em> " + results = results + (_("Subscription was <em>deferred</em> " "because %s. Your request has been " "forwarded to the list administrator. " "You will receive email informing you " "of the moderator's decision when they " - "get to your request.<p>" % x) + "get to your request.<p>") % x) except Errors.MMHostileAddress: - results = results + ("Your subscription is not allowed because " - "the email address you gave is insecure.<p>") + results = results + (_("Your subscription is not allowed because " + "the email address you gave is insecure.<p>")) except Errors.MMAlreadyAMember: - results = results + "You are already subscribed!<p>" + results = results + _("You are already subscribed!<p>") # # these shouldn't happen, but if someone's futzing with the cgi # they might -scott # except Errors.MMCantDigestError: results = results + \ - "No one can subscribe to the digest of this list!" + _("No one can subscribe to the digest of this list!") except Errors.MMMustDigestError: results = results + \ - "This list only supports digest subscriptions!" + _("This list only supports digest subscriptions!") else: results = results + \ - "You have been successfully subscribed to %s." % \ + _("You have been successfully subscribed to %s.") % \ (mlist.real_name) PrintResults(mlist, results, doc) diff --git a/Mailman/Handlers/Acknowledge.py b/Mailman/Handlers/Acknowledge.py index 5617629d1..8ad2ab709 100644 --- a/Mailman/Handlers/Acknowledge.py +++ b/Mailman/Handlers/Acknowledge.py @@ -41,15 +41,16 @@ def process(mlist, msg, msgdata): if len(subject) > plen and subject[0:plen] == prefix: subject = subject[plen:] # get the text from the template + realname = mlist.real_name text = Utils.maketext( 'postack.txt', {'subject' : subject, - 'listname' : mlist.real_name, + 'listname' : realname, 'listinfo_url': mlist.GetScriptURL('listinfo', absolute=1), }) # craft the outgoing message, with all headers and attributes # necessary for general delivery - subject = '%s post acknowledgement' % mlist.real_name + subject = _('%(realname)s post acknowledgement') msg = Message.UserNotification(sender, mlist.GetAdminEmail(), subject, text) HandlerAPI.DeliverToUser(mlist, msg) diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index 8bd66fbcd..e51a82dde 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -47,7 +47,7 @@ def process(mlist, msg, msgdata): prefix = mlist.subject_prefix # we purposefully leave no space b/w prefix and subject! if not subject: - msg['Subject'] = prefix + '(no subject)' + msg['Subject'] = prefix + _('(no subject)') elif prefix and not re.search(re.escape(prefix), subject, re.I): msg['Subject'] = prefix + subject # diff --git a/Mailman/Handlers/HandlerAPI.py b/Mailman/Handlers/HandlerAPI.py index ca455a281..09eaeb705 100644 --- a/Mailman/Handlers/HandlerAPI.py +++ b/Mailman/Handlers/HandlerAPI.py @@ -24,6 +24,7 @@ from Mailman import mm_cfg from Mailman import Errors from Mailman.Logging.Syslog import syslog from Mailman.pythonlib.StringIO import StringIO +from Mailman.i18n import _ @@ -37,7 +38,7 @@ class MessageHeld(HandlerError): def __str__(self): return self.__class__.__doc__ - rejection = 'Your message was rejected' + rejection = _('Your message was rejected') def rejection_notice(self, mlist): return self.__class__.rejection diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py index ec39d6aa0..bfdde1af7 100644 --- a/Mailman/Handlers/ToDigest.py +++ b/Mailman/Handlers/ToDigest.py @@ -206,11 +206,12 @@ class Digest: def ComposeBaseHeaders(self, msg): """Populate the message with the presentation-independent headers.""" - mlist = self.__mlist - msg['From'] = mlist.GetRequestEmail() - msg['Subject'] = ('%s digest, %s - %s' % - (mlist.real_name, self.__volume, self.__numinfo)) - msg['Reply-to'] = mlist.GetListEmail() + realname = self.__mlist.real_name + volume = self.__volume + numinfo = self.__numinfo + msg['From'] = self.__mlist.GetRequestEmail() + msg['Subject'] = _('%(realname)s digest, %(volume)s - %(numinfo)s') + msg['Reply-to'] = self.__mlist.GetListEmail() msg['X-Mailer'] = "Mailman v%s" % mm_cfg.VERSION msg['MIME-version'] = '1.0' @@ -261,10 +262,12 @@ class Digest: lines = [] # Masthead: if mime: + realname = self.__mlist.real_name + volume = self.__volume lines.append(dashbound) lines.append("Content-type: text/plain; charset=us-ascii") - lines.append("Content-description: Masthead (%s digest, %s)" - % (self.__mlist.real_name, self.__volume)) + lines.append("Content-description:" + + _(" Masthead (%(realname)s digest, %(volume)s)")) lines.append('') masthead = Utils.maketext('masthead.txt', self.TemplateRefs()) lines = lines + string.split(masthead, '\n') @@ -274,18 +277,19 @@ class Digest: if mime: lines.append(dashbound) lines.append("Content-type: text/plain; charset=us-ascii") - lines.append("Content-description: Digest Header") + lines.append("Content-description: " + _("Digest Header")) lines.append('') lines.append(self.__mlist.digest_header % self.TemplateRefs()) # Table of contents: lines.append('') if mime: + numinfo = self.__numinfo lines.append(dashbound) lines.append("Content-type: text/plain; charset=us-ascii") - lines.append("Content-description: Today's Topics (%s)" % - self.__numinfo) + lines.append("Content-description: " + + _("Today's Topics (%(numinfo)s)")) lines.append('') - lines.append("Today's Topics:") + lines.append(_("Today's Topics:")) lines.append('') lines.append(self.__toc) # Digest text: @@ -308,7 +312,7 @@ class Digest: lines.append(dashbound) if mime: lines.append("Content-type: text/plain; charset=us-ascii") - lines.append("Content-description: Digest Footer") + lines.append("Content-description: " + _("Digest Footer")) lines.append('') lines.append(self.__mlist.digest_footer % self.TemplateRefs()) # Close: @@ -317,7 +321,8 @@ class Digest: lines.append('') lines.append(dashbound + "--") lines.append('') - lines.append("End of %s Digest" % self.__mlist.real_name) + realname = self.__mlist.real_name + lines.append(_("End of %(realname)s Digest")) msg.body = string.join(lines, '\n') return msg |
