From f8d6bcc2c18e6a3d857dd99be24084c6488590c4 Mon Sep 17 00:00:00 2001 From: Yasuhito FUTATSUKI at POEM Date: Sat, 16 Jun 2018 02:46:52 +0900 Subject: enhance i18n in admin(un)?subscribeack messages --- Mailman/Bouncer.py | 3 ++- Mailman/Cgi/admin.py | 8 +++++--- Mailman/Cgi/options.py | 3 ++- Mailman/ListAdmin.py | 4 +++- Mailman/MailList.py | 4 ++-- Mailman/i18n.py | 5 ++++- 6 files changed, 18 insertions(+), 9 deletions(-) (limited to 'Mailman') diff --git a/Mailman/Bouncer.py b/Mailman/Bouncer.py index 2a1cb539..21a4df38 100644 --- a/Mailman/Bouncer.py +++ b/Mailman/Bouncer.py @@ -49,6 +49,7 @@ REASONS = {MemberAdaptor.BYBOUNCE: _('due to excessive bounces'), } _ = i18n._ +D_ = i18n.D_ @@ -265,7 +266,7 @@ class Bouncer: if info.noticesleft <= 0: # BAW: Remove them now, with a notification message self.ApprovedDeleteMember( - member, 'disabled address', + member, D_('disabled address'), admin_notif=self.bounce_notify_owner_on_removal, userack=1) # Expunge the pending cookie for the user. We throw away the diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py index 174cf34f..984904a7 100644 --- a/Mailman/Cgi/admin.py +++ b/Mailman/Cgi/admin.py @@ -47,6 +47,7 @@ from Mailman.CSRFcheck import csrf_check # Set up i18n _ = i18n._ i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) +D_ = i18n.D_ NL = '\n' OPTCOLUMNS = 11 @@ -1484,7 +1485,7 @@ def change_options(mlist, category, subcat, cgidata, doc): else: mlist.ApprovedAddMember(userdesc, send_welcome_msg, send_admin_notif, invitation, - whence='admin mass sub') + whence=D_('admin mass sub')) except Errors.MMAlreadyAMember: subscribe_errors.append((safeentry, _('Already a member'))) except Errors.MMBadEmailError: @@ -1538,7 +1539,7 @@ def change_options(mlist, category, subcat, cgidata, doc): for addr in names: try: mlist.ApprovedDeleteMember( - addr, whence='admin mass unsub', + addr, whence=D_('admin mass unsub'), admin_notif=send_unsub_notifications, userack=userack) unsubscribe_success.append(Utils.websafe(addr)) @@ -1645,7 +1646,8 @@ def change_options(mlist, category, subcat, cgidata, doc): quser = urllib.quote(user) if cgidata.has_key('%s_unsub' % quser): try: - mlist.ApprovedDeleteMember(user, whence='member mgt page') + mlist.ApprovedDeleteMember(user, + whence=D_('member mgt page')) removes.append(user) except Errors.NotAMemberError: errors.append((user, _('Not subscribed'))) diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py index 4f128baf..d563d253 100644 --- a/Mailman/Cgi/options.py +++ b/Mailman/Cgi/options.py @@ -45,6 +45,7 @@ DIGRE = re.compile( # Set up i18n _ = i18n._ i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) +D_ = i18n.D_ try: True, False @@ -583,7 +584,7 @@ address. Upon confirmation, any other mailing list containing the address try: try: mlist.DeleteMember( - user, 'via the member options page', userack=1) + user, D_('via the member options page'), userack=1) except Errors.MMNeedApproval: needapproval = True except Errors.NotAMemberError: diff --git a/Mailman/ListAdmin.py b/Mailman/ListAdmin.py index 877aa5c4..d083a521 100755 --- a/Mailman/ListAdmin.py +++ b/Mailman/ListAdmin.py @@ -45,6 +45,7 @@ from Mailman.Logging.Syslog import syslog from Mailman import i18n _ = i18n._ +D_ = i18n.D_ # Request types requiring admin approval IGN = 0 @@ -436,7 +437,8 @@ class ListAdmin: assert value == mm_cfg.SUBSCRIBE try: userdesc = UserDesc(addr, fullname, password, digest, lang) - self.ApprovedAddMember(userdesc, whence='via admin approval') + self.ApprovedAddMember(userdesc, + whence=D_('via admin approval')) except Errors.MMAlreadyAMember: # User has already been subscribed, after sending the request pass diff --git a/Mailman/MailList.py b/Mailman/MailList.py index cc1be3b5..72b50a11 100755 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -1075,7 +1075,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, "adminsubscribeack.txt", {"listname" : realname, "member" : formataddr((name, email)), - "whence" : "" if whence is None else "(" + whence + ")" + "whence" : "" if whence is None else "(" + _(whence) + ")" }, mlist=self) msg = Message.OwnerNotification(self, subject, text) msg.send(self) @@ -1112,7 +1112,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, 'adminunsubscribeack.txt', {'member' : name, 'listname': self.real_name, - "whence" : "" if whence is None else "(" + whence + ")" + "whence" : "" if whence is None else "(" + _(whence) + ")" }, mlist=self) msg = Message.OwnerNotification(self, subject, text) msg.send(self) diff --git a/Mailman/i18n.py b/Mailman/i18n.py index 605d4e76..f39b1004 100644 --- a/Mailman/i18n.py +++ b/Mailman/i18n.py @@ -123,7 +123,10 @@ else: def C_(s): return tolocale(_(s, 2)) - +# marking for pygettext +def D_(s): + return s + def ctime(date): # Don't make these module globals since we have to do runtime translation -- cgit v1.2.3 From 17a8600ed2bc13b01a6443f9b9f2fa21ff1be0c6 Mon Sep 17 00:00:00 2001 From: Yasuhito FUTATSUKI at POEM Date: Sat, 16 Jun 2018 04:45:33 +0900 Subject: whence should be translated to lists language for admin notify --- Mailman/MailList.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Mailman') diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 72b50a11..03af588d 100755 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -1065,6 +1065,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, otrans = i18n.get_translation() i18n.set_language(lang) try: + whence = "" if whence is None else "(" + _(whence) + ")" realname = self.real_name subject = _('%(realname)s subscription notification') finally: @@ -1075,7 +1076,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, "adminsubscribeack.txt", {"listname" : realname, "member" : formataddr((name, email)), - "whence" : "" if whence is None else "(" + _(whence) + ")" + "whence" : whence }, mlist=self) msg = Message.OwnerNotification(self, subject, text) msg.send(self) -- cgit v1.2.3 From 3e3819ce7fa318f5e60b2f04ae94b48698ab73a5 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Sat, 16 Jun 2018 09:39:45 -0700 Subject: Preserve translation accross a call to SendSubscribeAck(). --- Mailman/MailList.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Mailman') diff --git a/Mailman/MailList.py b/Mailman/MailList.py index cc1be3b5..abc46abd 100755 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -1058,8 +1058,14 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, syslog('subscribe', '%s: new%s %s, %s', self.internal_name(), kind, formataddr((name, email)), whence) if ack: - self.SendSubscribeAck(email, self.getMemberPassword(email), - digest, text) + lang = self.preferred_language + otrans = i18n.get_translation() + i18n.set_language(lang) + try: + self.SendSubscribeAck(email, self.getMemberPassword(email), + digest, text) + finally: + i18n.set_translation(otrans) if admin_notif: lang = self.preferred_language otrans = i18n.get_translation() -- cgit v1.2.3 From b885614b0c7b14040be7919c98636b00ad4973ce Mon Sep 17 00:00:00 2001 From: Yasuhito FUTATSUKI at POEM Date: Sun, 17 Jun 2018 16:41:38 +0900 Subject: add missed whence msgid in previous commit --- Mailman/MailList.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Mailman') diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 03af588d..e8a6bbf0 100755 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -72,6 +72,7 @@ from Mailman import i18n from Mailman.Logging.Syslog import syslog _ = i18n._ +D_ = i18n.D_ EMPTYSTRING = '' OR = '|' @@ -1302,7 +1303,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, except ValueError: raise Errors.MMBadConfirmation, 'op-less data %s' % (rec,) if op == Pending.SUBSCRIPTION: - whence = 'via email confirmation' + whence = D_('via email confirmation') try: userdesc = data[0] # If confirmation comes from the web, context should be a @@ -1311,7 +1312,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, # context is a Message and isn't relevant, so ignore it. if isinstance(context, UserDesc): userdesc += context - whence = 'via web confirmation' + whence = D_('via web confirmation') addr = userdesc.address fullname = userdesc.fullname password = userdesc.password @@ -1343,9 +1344,9 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin, addr = data[0] # Log file messages don't need to be i18n'd if isinstance(context, Message.Message): - whence = 'email confirmation' + whence = D_('email confirmation') else: - whence = 'web confirmation' + whence = D_('web confirmation') # Can raise NotAMemberError if they unsub'd via other means self.ApprovedDeleteMember(addr, whence=whence) return op, addr -- cgit v1.2.3