summaryrefslogtreecommitdiff
path: root/src/mailman/app
diff options
context:
space:
mode:
authorBarry Warsaw2009-02-12 20:36:21 -0500
committerBarry Warsaw2009-02-12 20:36:21 -0500
commit62f4c909f90535986614a411db982bdcccaec3a1 (patch)
tree2fe5dd3316cea73f63cb34230d848758050eade3 /src/mailman/app
parent2b28803e7165e91d812cd9e9e3804a6d9bdce8a1 (diff)
downloadmailman-62f4c909f90535986614a411db982bdcccaec3a1.tar.gz
mailman-62f4c909f90535986614a411db982bdcccaec3a1.tar.zst
mailman-62f4c909f90535986614a411db982bdcccaec3a1.zip
Much clean up of the language code, though more can be done. Factor out the
language manager stuff into a separate Language class, and be clearer in the APIs about whether we want a language code or a Language instance. The impetus to this was to get rid of Utils.GetCharSet(), which is done.
Diffstat (limited to 'src/mailman/app')
-rw-r--r--src/mailman/app/bounces.py8
-rw-r--r--src/mailman/app/moderator.py14
-rw-r--r--src/mailman/app/notifications.py6
-rw-r--r--src/mailman/app/replybot.py2
4 files changed, 14 insertions, 16 deletions
diff --git a/src/mailman/app/bounces.py b/src/mailman/app/bounces.py
index aa7f51c77..cea91b2e2 100644
--- a/src/mailman/app/bounces.py
+++ b/src/mailman/app/bounces.py
@@ -29,7 +29,7 @@ import logging
from email.mime.message import MIMEMessage
from email.mime.text import MIMEText
-from mailman import Utils
+from mailman.Utils import oneline
from mailman.email.message import Message, UserNotification
from mailman.i18n import _
@@ -45,8 +45,7 @@ def bounce_message(mlist, msg, e=None):
# to.
return
subject = msg.get('subject', _('(no subject)'))
- subject = Utils.oneline(subject,
- Utils.GetCharSet(mlist.preferred_language))
+ subject = oneline(subject, mlist.preferred_language.charset)
if e is None:
notice = _('[No bounce details are available]')
else:
@@ -57,8 +56,7 @@ def bounce_message(mlist, msg, e=None):
# BAW: Be sure you set the type before trying to attach, or you'll get
# a MultipartConversionError.
bmsg.set_type('multipart/mixed')
- txt = MIMEText(notice,
- _charset=Utils.GetCharSet(mlist.preferred_language))
+ txt = MIMEText(notice, _charset=mlist.preferred_language.charset)
bmsg.attach(txt)
bmsg.attach(MIMEMessage(msg))
bmsg.send(mlist)
diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py
index 1f66e00ac..ffe0f779e 100644
--- a/src/mailman/app/moderator.py
+++ b/src/mailman/app/moderator.py
@@ -165,7 +165,7 @@ def handle_message(mlist, id, action,
member = mlist.members.get_member(addresses[0])
if member:
language = member.preferred_language
- with i18n.using_language(language):
+ with i18n.using_language(language.code):
fmsg = UserNotification(
addresses, mlist.bounces_address,
_('Forward of moderated message'),
@@ -234,14 +234,14 @@ def handle_subscription(mlist, id, action, comment=None):
_refuse(mlist, _('Subscription request'),
data['address'],
comment or _('[No reason given]'),
- lang=data['language'])
+ lang=config.languages[data['language']])
elif action is Action.accept:
key, data = requestdb.get_request(id)
enum_value = data['delivery_mode'].split('.')[-1]
delivery_mode = DeliveryMode(enum_value)
address = data['address']
realname = data['realname']
- language = data['language']
+ language = config.languages[data['language']]
password = data['password']
try:
add_member(mlist, address, realname, password,
@@ -329,16 +329,16 @@ def _refuse(mlist, request, recip, comment, origmsg=None, lang=None):
realname = mlist.real_name
if lang is None:
member = mlist.members.get_member(recip)
- if member:
- lang = member.preferred_language
+ lang = (member.preferred_language if member
+ else mlist.preferred_language)
text = Utils.maketext(
'refuse.txt',
{'listname' : mlist.fqdn_listname,
'request' : request,
'reason' : comment,
'adminaddr': mlist.owner_address,
- }, lang=lang, mlist=mlist)
- with i18n.using_language(lang):
+ }, lang=lang.code, mlist=mlist)
+ with i18n.using_language(lang.code):
# add in original message, but not wrap/filled
if origmsg:
text = NL.join(
diff --git a/src/mailman/app/notifications.py b/src/mailman/app/notifications.py
index b1d77dc6f..fcbfe95be 100644
--- a/src/mailman/app/notifications.py
+++ b/src/mailman/app/notifications.py
@@ -73,7 +73,7 @@ def send_welcome_message(mlist, address, language, delivery_mode, text=''):
'optionsurl' : options_url,
'request_address' : mlist.request_address,
'welcome' : welcome,
- }, lang=language, mlist=mlist)
+ }, lang=language.code, mlist=mlist)
if delivery_mode is not DeliveryMode.regular:
digmode = _(' (Digest mode)')
else:
@@ -124,9 +124,9 @@ def send_admin_subscription_notice(mlist, address, full_name, language):
:param language: the language of the address's realname
:type language: string
"""
- with i18n.using_language(mlist.preferred_language):
+ with i18n.using_language(mlist.preferred_language.code):
subject = _('$mlist.real_name subscription notification')
- full_name = full_name.encode(Utils.GetCharSet(language), 'replace')
+ full_name = full_name.encode(language.charset, 'replace')
text = Utils.maketext(
'adminsubscribeack.txt',
{'listname' : mlist.real_name,
diff --git a/src/mailman/app/replybot.py b/src/mailman/app/replybot.py
index 0537f6645..b558e96aa 100644
--- a/src/mailman/app/replybot.py
+++ b/src/mailman/app/replybot.py
@@ -80,7 +80,7 @@ def autorespond_to_sender(mlist, sender, lang=None):
'owneremail': mlist.owner_address,
},
lang=lang)
- with i18n.using_language(lang):
+ with i18n.using_language(lang.code):
msg = Message.UserNotification(
sender, mlist.owner_address,
_('Last autoresponse notification for today'),