summaryrefslogtreecommitdiff
path: root/Mailman/HTMLFormatter.py
diff options
context:
space:
mode:
authorbwarsaw2000-12-26 19:41:52 +0000
committerbwarsaw2000-12-26 19:41:52 +0000
commitaa0161ff926b932bbc81a4bfaf1b8256bb8966a8 (patch)
tree3f2b45596f2610bf4ac1b6f1ec67f0a91b4a1860 /Mailman/HTMLFormatter.py
parentde2d24c76b0fd6d69d89e667bfe98e169336000c (diff)
downloadmailman-aa0161ff926b932bbc81a4bfaf1b8256bb8966a8.tar.gz
mailman-aa0161ff926b932bbc81a4bfaf1b8256bb8966a8.tar.zst
mailman-aa0161ff926b932bbc81a4bfaf1b8256bb8966a8.zip
Diffstat (limited to 'Mailman/HTMLFormatter.py')
-rw-r--r--Mailman/HTMLFormatter.py223
1 files changed, 123 insertions, 100 deletions
diff --git a/Mailman/HTMLFormatter.py b/Mailman/HTMLFormatter.py
index 4f996a386..99c864ad1 100644
--- a/Mailman/HTMLFormatter.py
+++ b/Mailman/HTMLFormatter.py
@@ -50,23 +50,27 @@ class HTMLFormatter:
Address(
Container(
Link(self.GetScriptURL('listinfo'), self.real_name),
- ' list run by ', owners_html,
+ _(' list run by '), owners_html,
'<br>',
Link(self.GetScriptURL('admin'),
- '%s administrative interface' % self.real_name),
+ _('%s administrative interface') % self.real_name),
' (requires authorization)',
'<p>', MailmanLogo()))).Format()
- def SnarfHTMLTemplate(self, file):
+ def SnarfHTMLTemplate(self, file, lang=None):
# XXX: hack, blech, yuk
+ if lang is None:
+ lang = self.preferred_language
HTMLFormatter.InitVars(self)
- filename = os.path.join(self._template_dir, file)
+ filename = os.path.join(self._template_dir, lang, file)
f = open(filename,'r')
str = f.read()
f.close()
return str
- def FormatUsers(self, digest):
+ def FormatUsers(self, digest, lang=None):
+ if lang is None:
+ lang = self.preferred_language
conceal_sub = mm_cfg.ConcealSubscription
people = []
if digest:
@@ -84,7 +88,7 @@ class HTMLFormatter:
people.sort()
if (num_concealed > 0):
plurality = (((num_concealed > 1) and "s") or "")
- concealed = ("<em>(%d private member%s not shown)</em>"
+ concealed = (_("<em>(%d private member%s not shown)</em>")
% (num_concealed, plurality))
else:
concealed = ""
@@ -135,30 +139,29 @@ class HTMLFormatter:
def FormatDisabledNotice(self, user):
if self.GetUserOption(user, mm_cfg.DisableDelivery):
- text = Center(Header(3,
- "Note - your list delivery is currently"
- " disabled.")).Format()
+ text = Center(Header(3, _(
+ "Note - your list delivery is currently disabled."))).Format()
text = text + "\n"
- text = text + ("You may have set non-delivery deliberately, or"
- " it may have been triggered by bounces from your"
- " delivery address. In either case, to reenable "
- " delivery, change the ")
+ text = text + _("You may have set non-delivery deliberately, or"
+ " it may have been triggered by bounces from your"
+ " delivery address. In either case, to reenable "
+ " delivery, change the ")
text = text + Link('#disable',
- "Disable mail delivery").Format()
- text = text + " option. Contact "
+ _("Disable mail delivery")).Format()
+ text = text + _(" option. Contact ")
text = text + Link('mailto:' + self.GetAdminEmail(),
- 'your list administrator').Format()
- text = text + " if you have questions."
+ _("your list administrator")).Format()
+ text = text + _(" if you have questions.")
return text
else:
return ""
def FormatUmbrellaNotice(self, user, type):
if self.umbrella_list:
- return ("(Note - you are subscribing to a list of mailing lists,"
- " so the %s notice will be sent to the admin address"
- " for your membership, %s.)<p>"
- % (type, self.GetMemberAdminEmail(user)))
+ return _("(Note - you are subscribing to a list of mailing lists,"
+ " so the %s notice will be sent to the admin address"
+ " for your membership, %s.)<p>") % (
+ type, self.GetMemberAdminEmail(user))
else:
return ""
@@ -167,46 +170,46 @@ class HTMLFormatter:
msg = ""
also = ""
if self.subscribe_policy == 1:
- msg = msg + ("You will be sent email requesting confirmation, "
- "to prevent others from gratuitously subscribing "
- "you. ")
+ msg = msg + _("You will be sent email requesting confirmation, "
+ "to prevent others from gratuitously subscribing "
+ "you. ")
if self.subscribe_policy == 2:
- msg = msg + ("This is a closed list, which means your "
- "subscription will be held for approval. You will "
- "be notified of the administrator's decision by "
- "email. ")
- also = "also "
+ msg = msg + _("This is a closed list, which means your "
+ "subscription will be held for approval. You will "
+ "be notified of the administrator's decision by "
+ "email. ")
+ also = _("also ")
if self.subscribe_policy == 3:
- msg = msg + ("You will be sent email requesting confirmation, "
- "to prevent others from gratuitously subscribing "
- "you. Once confirmation is received, your "
- "request will be held for approval by the list "
- "administrator. You will be notified of the "
- "administrator's decision by email. ")
- also = "also "
+ msg = msg + _("You will be sent email requesting confirmation, "
+ "to prevent others from gratuitously subscribing "
+ "you. Once confirmation is received, your "
+ "request will be held for approval by the list "
+ "administrator. You will be notified of the "
+ "administrator's decision by email. ")
+ also = _("also ")
if self.private_roster == 1:
- msg = msg + ("This is %sa private list, which means that "
- "the members list is not available to non-"
- "members. " % also)
+ msg = msg + _("This is %sa private list, which means that "
+ "the members list is not available to non-"
+ "members. ") % also
elif self.private_roster:
- msg = msg + ("This is %sa hidden list, which means that "
- "the members list is available only to the "
- "list administrator. " % also)
+ msg = msg + _("This is %sa hidden list, which means that "
+ "the members list is available only to the "
+ "list administrator. ") % also
else:
- msg = msg + ("This is %sa public list, which means that the "
- "members list is openly available" % also)
+ msg = msg + _("This is %sa public list, which means that the "
+ "members list is openly available") % also
if self.obscure_addresses:
- msg = msg + (" (but we obscure the addresses so they are "
- "not easily recognizable by spammers). ")
+ msg = msg + _(" (but we obscure the addresses so they are "
+ "not easily recognizable by spammers). ")
else:
msg = msg + ". "
if self.umbrella_list:
- msg = msg + ("<p>(Note that this is an umbrella list, intended to"
- " have only other mailing lists as members. Among"
- " other things, this means that your confirmation"
- " request will be sent to the '%s' account for"
- " your address.)" % self.umbrella_member_suffix)
+ msg = msg + _("<p>(Note that this is an umbrella list, intended to"
+ " have only other mailing lists as members. Among"
+ " other things, this means that your confirmation"
+ " request will be sent to the '%s' account for"
+ " your address.)") % self.umbrella_member_suffix
return msg
@@ -230,73 +233,74 @@ class HTMLFormatter:
checked = ' CHECKED'
return '<input type=radio name="plain" value="1"%s>' % checked
- def FormatEditingOption(self):
+ def FormatEditingOption(self, lang):
"Present editing options, according to list privacy."
- text = ('To change your subscription (set options like digest'
- ' and delivery modes, get a reminder of your password,'
- ' or unsubscribe from '
+ text = (_('To change your subscription (set options like digest'
+ ' and delivery modes, get a reminder of your password,'
+ ' or unsubscribe from ')
+ self.real_name
- + '), %senter your subscription email address:<p><center> ')
+ + _('), %senter your subscription email address:')
+ + '<p><center> ')
if self.private_roster == 0:
- text = text % "<b><i>either</i></b> "
+ text = text % _("<b><i> either</i></b> ")
else:
text = text % ""
text = (text
+ TextBox('info', size=30).Format()
+ " "
- + SubmitButton('UserOptions', 'Edit Options').Format()
+ + SubmitButton('UserOptions', _('Edit Options')).Format()
+ "</center>")
if self.private_roster == 0:
- text = text + ("<p>... <b><i>or</i></b> select your entry from the"
- " subscribers list (see above).")
+ text = text + _("<p>... <b><i>or</i></b> select your entry from "
+ " the subscribers list (see above).")
return text
def RestrictedListMessage(self, which, restriction):
if not restriction:
return ""
elif restriction == 1:
- return ("<i>The %s is only available to the list members.</i>"
+ return (_("<i>The %s is only available to the list members.</i>)")
% which)
else:
- return ("<i>The %s is only available to the list"
- " administrator.</i>" % which)
+ return (_("<i>The %s is only available to the list"
+ " administrator.</i>") % which)
- def FormatRosterOptionForUser(self):
- return self.RosterOption().Format()
+ def FormatRosterOptionForUser(self, lang):
+ return self.RosterOption(lang).Format()
- def RosterOption(self):
+ def RosterOption(self, lang):
"Provide avenue to subscribers roster, contingent to .private_roster."
container = Container()
if not self.private_roster:
- container.AddItem("Click here for the list of "
+ container.AddItem(_("Click here for the list of ")
+ self.real_name
- + " subscribers: ")
+ + _(" subscribers: "))
container.AddItem(SubmitButton('SubscriberRoster',
- 'Visit Subscriber list'))
+ _("Visit Subscriber list")))
else:
if self.private_roster == 1:
- only = 'members'
- whom = 'Address:'
+ only = _('members')
+ whom = _('Address:')
else:
- only = 'the list administrator'
- whom = 'Admin address:'
+ only = _('the list administrator')
+ whom = _('Admin address:')
# Solicit the user and password.
- container.AddItem(self.RestrictedListMessage('subscribers list',
+ container.AddItem(self.RestrictedListMessage(_('subscribers list'),
self.private_roster)
- + " <p>Enter your "
+ + _(" <p>Enter your ")
+ string.lower(whom[:-1])
- + " and password to visit"
- " the subscribers list: <p><center> "
+ + _(" and password to visit"
+ " the subscribers list: <p><center> ")
+ whom
+ " ")
container.AddItem(self.FormatBox('roster-email'))
- container.AddItem(" Password: "
+ container.AddItem(_("Password: ")
+ self.FormatSecureBox('roster-pw')
+ "&nbsp;&nbsp;")
container.AddItem(SubmitButton('SubscriberRoster',
- 'Visit Subscriber List'))
+ _('Visit Subscriber List')))
container.AddItem("</center>")
return container
@@ -323,13 +327,16 @@ class HTMLFormatter:
def FormatButton(self, name, text='Submit'):
return '<INPUT type="Submit" name="%s" value="%s">' % (name, text)
- def FormatReminder(self):
+ def FormatReminder(self, lang):
if self.send_reminders:
- return 'Once a month, your password will be emailed to you as a reminder.'
+ return _('Once a month, your password will be emailed to you as'
+ ' a reminder.')
return ''
- def ParseTags(self, template, replacements):
- text = self.SnarfHTMLTemplate(template)
+ def ParseTags(self, template, replacements, lang=None):
+ if lang is None:
+ lang = self.preferred_language
+ text = self.SnarfHTMLTemplate(template, lang)
parts = regsub.splitx(text, '</?[Mm][Mm]-[^>]*>')
i = 1
while i < len(parts):
@@ -343,9 +350,15 @@ class HTMLFormatter:
# This needs to wait until after the list is inited, so let's build it
# when it's needed only.
- def GetStandardReplacements(self):
+ def GetStandardReplacements(self, lang=None):
+ if lang is None:
+ lang = self.preferred_language
dmember_len = len(self.GetDigestMembers())
member_len = len(self.GetMembers())
+ values = self.GetAvailableLanguages()
+ legend = map(_, map(Utils.GetLanguageDescr, values))
+ selected = values.index(self.preferred_language)
+
return {
'<mm-mailman-footer>' : self.GetMailmanFooter(),
'<mm-list-name>' : self.real_name,
@@ -358,7 +371,7 @@ class HTMLFormatter:
'</mm-archive>' : '</a>',
'<mm-list-subscription-msg>' : self.FormatSubscriptionMsg(),
'<mm-restricted-list-message>' : \
- self.RestrictedListMessage('current archive',
+ self.RestrictedListMessage(_('current archive'),
self.archive_private),
'<mm-num-reg-users>' : `member_len`,
'<mm-num-digesters>' : `dmember_len`,
@@ -366,30 +379,40 @@ class HTMLFormatter:
'<mm-posting-addr>' : '%s' % self.GetListEmail(),
'<mm-request-addr>' : '%s' % self.GetRequestEmail(),
'<mm-owner>' : self.GetAdminEmail(),
- '<mm-reminder>' : self.FormatReminder(),
+ '<mm-reminder>' : self.FormatReminder(self.preferred_language),
'<mm-host>' : self.host_name,
+ '<mm-list-langs>' : SelectOptions('language', values, legend,
+ selected).Format(),
}
- def GetAllReplacements(self):
+ def GetAllReplacements(self, lang=None):
"""
returns standard replaces plus formatted user lists in
a dict just like GetStandardReplacements.
"""
- d = self.GetStandardReplacements()
- d.update({"<mm-regular-users>": self.FormatUsers(0),
- "<mm-digest-users>": self.FormatUsers(1)})
+ if lang is None:
+ lang = self.preferred_language
+ d = self.GetStandardReplacements(lang)
+ d.update({"<mm-regular-users>": self.FormatUsers(0, lang),
+ "<mm-digest-users>": self.FormatUsers(1, lang)})
return d
- def InitTemplates(self):
+ def InitTemplates(self, langs=None):
def ExtensionFilter(item):
return item[-5:] == '.html'
- files = filter(ExtensionFilter, os.listdir(mm_cfg.TEMPLATE_DIR))
- Utils.MakeDirTree(self._template_dir)
- for filename in files:
- file1 = open(os.path.join(mm_cfg.TEMPLATE_DIR, filename), 'r')
- text = file1.read()
- file1.close()
- file2 = open(os.path.join(self._template_dir, filename), 'w+')
- file2.write(text)
- file2.close()
+ if not langs:
+ langs = [mm_cfg.DEFAULT_SERVER_LANGUAGE]
+
+ for L in langs:
+ files = filter(ExtensionFilter,
+ os.listdir(os.path.join(mm_cfg.TEMPLATE_DIR, L)))
+ Utils.MakeDirTree(os.path.join(self._template_dir, L))
+
+ for filename in files:
+ file1 = open(os.path.join(mm_cfg.TEMPLATE_DIR, L, filename))
+ text = file1.read()
+ file1.close()
+ file2 = open(os.path.join(self._template_dir, L, filename), 'w+')
+ file2.write(text)
+ file2.close()