From e8fab9d5550b2747a8ceb89502ef6737b401624e Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Thu, 15 Feb 2001 15:47:10 +0000 Subject: Some additional i18n markup, although I can't remember if this is Juan Carlos's contribution or not. Specifically, GetMailmanFooter(), FormatSubscriptionMsg(), FormatEditingOption(): Mark some strings as translatable, using the Mailman.i18n._ `auto-interpolating' function. SnarfHTMLTemplate(): Catch IOErrors which could result if a list was created in an older version of Mailman before the i18n support was added. GetStandardReplacements(): Watch out for missing list preferred language (can happen to an older list which hasn't been updated). Use DEFAULT_SERVER_LANGUAGE in that case. InitTemplates(): Some additional code reorg. --- Mailman/HTMLFormatter.py | 65 +++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'Mailman/HTMLFormatter.py') diff --git a/Mailman/HTMLFormatter.py b/Mailman/HTMLFormatter.py index 99c864ad1..5eb04fb5e 100644 --- a/Mailman/HTMLFormatter.py +++ b/Mailman/HTMLFormatter.py @@ -19,6 +19,7 @@ import os +import errno # XXX: should be converted to use re module import regsub import string @@ -26,6 +27,8 @@ import mm_cfg import Utils from htmlformat import * +from Mailman.i18n import _ + class HTMLFormatter: @@ -45,6 +48,7 @@ class HTMLFormatter: owners_html.AddItem(', ') # Remove the .Format() when htmlformat conversion is done. + realname = self.real_name return Container( '
', MailmanLogo()))).Format() @@ -63,7 +67,14 @@ class HTMLFormatter: lang = self.preferred_language HTMLFormatter.InitVars(self) filename = os.path.join(self._template_dir, lang, file) - f = open(filename,'r') + try: + f = open(filename) + except IOError, e: + if e.errno <> errno.ENOENT: raise + # Could be a list that was created before i18n support was added. + # In that case, use the templates one directory higher. + filename = os.path.join(self._template_dir, file) + f = open(filename) str = f.read() f.close() return str @@ -196,8 +207,8 @@ class HTMLFormatter: "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 %(also)sa public list, which means that the" + " members list is openly available") if self.obscure_addresses: msg = msg + _(" (but we obscure the addresses so they are " "not easily recognizable by spammers). ") @@ -236,17 +247,17 @@ class HTMLFormatter: 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 ') - + self.real_name - + _('), %senter your subscription email address:') - + '