From aa0161ff926b932bbc81a4bfaf1b8256bb8966a8 Mon Sep 17 00:00:00 2001
From: bwarsaw
Date: Tue, 26 Dec 2000 19:41:52 +0000
Subject: Latest round of jcrey's I18N patches. Specifically,
Mark lots of strings as translatable.
SnarfHTMLTemplate(), FormatUsers(), FormatEditingOption(),
FormatReminder(), GetStandardReplacements(), GetAllReplacements(),
InitTemplates(): Accept optional `lang' argument.
---
Mailman/HTMLFormatter.py | 223 ++++++++++++++++++++++++++---------------------
1 file changed, 123 insertions(+), 100 deletions(-)
(limited to 'Mailman/HTMLFormatter.py')
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,
'
',
Link(self.GetScriptURL('admin'),
- '%s administrative interface' % self.real_name),
+ _('%s administrative interface') % self.real_name),
' (requires authorization)',
'
', 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 = ("(%d private member%s not shown)" + concealed = (_("(%d private member%s not shown)") % (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.)
" - % (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.)
") % ( + 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 + ("
(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 + _("
(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 '' % 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:
... or select your entry from the" - " subscribers list (see above).") + text = text + _("
... or select your entry from " + " the subscribers list (see above).") return text def RestrictedListMessage(self, which, restriction): if not restriction: return "" elif restriction == 1: - return ("The %s is only available to the list members." + return (_("The %s is only available to the list members.)") % which) else: - return ("The %s is only available to the list" - " administrator." % which) + return (_("The %s is only available to the list" + " administrator.") % 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) - + "
Enter your " + + _("
Enter your ") + string.lower(whom[:-1]) - + " and password to visit" - " the subscribers list: