diff options
| author | bwarsaw | 2000-12-26 17:44:36 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-12-26 17:44:36 +0000 |
| commit | 5fd4143eac0913e7d80abf8f65f2b7d29e299526 (patch) | |
| tree | 7be7575fd8647bf5012395550849616a6e58f38b | |
| parent | 32b60f92af057cc2c8d1035d61dddc7b4d2722a2 (diff) | |
| download | mailman-5fd4143eac0913e7d80abf8f65f2b7d29e299526.tar.gz mailman-5fd4143eac0913e7d80abf8f65f2b7d29e299526.tar.zst mailman-5fd4143eac0913e7d80abf8f65f2b7d29e299526.zip | |
Latest set of I18N patches from jcrey. Specifically,
Exception classes: Mark the `rejection' strings for translation, but
don't similarly mark the class docstrings. pygettext.py is able to
extract these strings without markings.
hold_for_approval(): Other changes to support I18N include setting
$LANG to list's preferred language; marking more strings as
translatable. There's duplicate code here which can be refactored
much better.
| -rw-r--r-- | Mailman/Handlers/Hold.py | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/Mailman/Handlers/Hold.py b/Mailman/Handlers/Hold.py index 93b0abe3e..6947016cd 100644 --- a/Mailman/Handlers/Hold.py +++ b/Mailman/Handlers/Hold.py @@ -49,44 +49,44 @@ from Mailman.Logging.Syslog import syslog class ForbiddenPoster(HandlerAPI.MessageHeld): "Sender is explicitly forbidden" - rejection = 'You are forbidden from posting messages to this list.' + rejection = _('You are forbidden from posting messages to this list.') class ModeratedPost(HandlerAPI.MessageHeld): "Post to moderated list" - rejection = 'Your message has been deemed inappropriate by the moderator.' + rejection = _('Your message was deemed inappropriate by the moderator.') class NonMemberPost(HandlerAPI.MessageHeld): "Post by non-member to a members-only list" - rejection = 'Non-members are not allowed to post messages to this list.' + rejection = _('Non-members are not allowed to post messages to this list.') class NotExplicitlyAllowed(HandlerAPI.MessageHeld): "Posting to a restricted list by sender requires approval" - rejection = 'This list is restricted; your message was not approved.' + rejection = _('This list is restricted; your message was not approved.') class TooManyRecipients(HandlerAPI.MessageHeld): "Too many recipients to the message" - rejection = 'Please trim the recipient list; it is too long.' + rejection = _('Please trim the recipient list; it is too long.') class ImplicitDestination(HandlerAPI.MessageHeld): "Message has implicit destination" - rejection = '''Blind carbon copies or other implicit destinations are + rejection = _('''Blind carbon copies or other implicit destinations are not allowed. Try reposting your message by explicitly including the list -address in the To: or Cc: fields.''' +address in the To: or Cc: fields.''') class Administrivia(HandlerAPI.MessageHeld): "Message may contain administrivia" def rejection_notice(self, mlist): - return """Please do *not* post administrative requests to the mailing + return _("""Please do *not* post administrative requests to the mailing list. If you wish to subscribe, visit %(listurl)s or send a message with the word `help' in it to the request address, %(request)s, for further -instructions.""" % {'listurl': mlist.GetScriptURL('listinfo', absolute=1), - 'request': mlist.GetRequestEmail(), +instructions.""") % {'listurl': mlist.GetScriptURL('listinfo', absolute=1), + 'request': mlist.GetRequestEmail(), } class SuspiciousHeaders(HandlerAPI.MessageHeld): - "Message has a suspicious header" - rejection = 'Your message had a suspicious header.' + "Message has a suspicious header" + rejection = _('Your message had a suspicious header.') class MessageTooBig(HandlerAPI.MessageHeld): "Message body is too big: %d bytes but there's a limit of %d KB" @@ -99,8 +99,8 @@ class MessageTooBig(HandlerAPI.MessageHeld): self.__msgsize, self.__limit) def rejection_notice(self, mlist): - return """Your message was too big; please trim it to less than -%(kb)s KB in size.""" % {'kb': mlist.max_message_size} + return _("""Your message was too big; please trim it to less than +%(kb)s KB in size.""") % {'kb': mlist.max_message_size} @@ -211,9 +211,11 @@ def hold_for_approval(mlist, msg, msgdata, exc): # Go ahead and instantiate it now. exc = exc() listname = mlist.real_name - reason = str(exc) sender = msg.GetSender() adminaddr = mlist.GetAdminEmail() + # BAW: I don't like using $LANG :( + os.environ['LANG'] = mlist.preferred_language + reason = str(exc) msgdata['rejection-notice'] = exc.rejection_notice(mlist) mlist.HoldMessage(msg, reason, msgdata) # now we need to craft and send a message to the list admin so they can @@ -222,9 +224,19 @@ def hold_for_approval(mlist, msg, msgdata, exc): 'hostname' : mlist.host_name, 'reason' : reason, 'sender' : sender, - 'subject' : msg.get('subject', '(no subject)'), + 'subject' : msg.get('subject', _('(no subject)')), 'admindb_url': mlist.GetScriptURL('admindb', absolute=1), } + # We may want to send a notification to the original sender too + fromusenet = msgdata.get('fromusenet') + # jcrey: I need to translate subject in msg before it may be overriden by + # the notification to the admin, so I must to duplicate code :-( + # + # BAW: I don't like using $LANG :( + if not fromusenet and not mlist.dont_respond_to_post_requests: + os.environ['LANG'] = mlist.GetPreferredLanguage(sender) + usersubject = msg.get('subject', _('(no subject)')) + os.environ['LANG'] = mlist.preferred_language if mlist.admin_immed_notify: # get the text from the template subject = _('%(listname)s post from %(sender)s requires approval') @@ -232,11 +244,14 @@ def hold_for_approval(mlist, msg, msgdata, exc): # craft the admin notification message and deliver it msg = Message.UserNotification(adminaddr, adminaddr, subject, text) HandlerAPI.DeliverToUser(mlist, msg) - # We may want to send a notification to the original sender too - fromusenet = msgdata.get('fromusenet') if not fromusenet and not mlist.dont_respond_to_post_requests: + # jcrey: We need to translate certains parts to user's preferred + # language. + os.environ['LANG'] = pluser = mlist.GetPreferredLanguage(sender) subject = _('Your message to %(listname)s awaits moderator approval') - text = Utils.maketext('postheld.txt', d) + d['reason'] = str(exc) + d['subject'] = usersubject + text = Utils.maketext('postheld.txt', d, pluser) msg = Message.UserNotification(sender, adminaddr, subject, text) HandlerAPI.DeliverToUser(mlist, msg) # Log the held message |
