aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman
diff options
context:
space:
mode:
authorYasuhito FUTATSUKI at POEM <futatuki@poem.co.jp>2018-06-22 01:23:09 +0900
committerYasuhito FUTATSUKI at POEM <futatuki@poem.co.jp>2018-06-22 01:23:09 +0900
commit6a3bbdd20a8fac82f161f353c40604387f52cb09 (patch)
tree4d752b4a3f0f4bd3100108bc9cf584438772d778 /Mailman
parent388b4a41ece74d11298e640429bef5f903221d09 (diff)
downloadmailman2-6a3bbdd20a8fac82f161f353c40604387f52cb09.tar.gz
mailman2-6a3bbdd20a8fac82f161f353c40604387f52cb09.tar.xz
mailman2-6a3bbdd20a8fac82f161f353c40604387f52cb09.zip
enhance i18n of listinfo overview
* make sure list's description charset as its preferred_language's * get description as a string of charset caller wanted
Diffstat (limited to 'Mailman')
-rw-r--r--Mailman/Cgi/admin.py2
-rw-r--r--Mailman/Cgi/listinfo.py2
-rw-r--r--Mailman/Gui/GUIBase.py8
-rw-r--r--Mailman/MailList.py21
4 files changed, 31 insertions, 2 deletions
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py
index f77b358e..f028052d 100644
--- a/Mailman/Cgi/admin.py
+++ b/Mailman/Cgi/admin.py
@@ -295,7 +295,7 @@ def admin_overview(msg=''):
else:
advertised.append((mlist.GetScriptURL('admin'),
mlist.real_name,
- mlist.description))
+ mlist.GetDescription()))
# Greeting depends on whether there was an error or not
if msg:
greeting = FontAttr(msg, color="ff5060", size="+1")
diff --git a/Mailman/Cgi/listinfo.py b/Mailman/Cgi/listinfo.py
index b55c263d..f1b455da 100644
--- a/Mailman/Cgi/listinfo.py
+++ b/Mailman/Cgi/listinfo.py
@@ -114,7 +114,7 @@ def listinfo_overview(msg=''):
else:
advertised.append((mlist.GetScriptURL('listinfo'),
mlist.real_name,
- Utils.websafe(mlist.description)))
+ Utils.websafe(mlist.GetDescription())))
if msg:
greeting = FontAttr(msg, color="ff5060", size="+1")
else:
diff --git a/Mailman/Gui/GUIBase.py b/Mailman/Gui/GUIBase.py
index 95d7d177..67e79036 100644
--- a/Mailman/Gui/GUIBase.py
+++ b/Mailman/Gui/GUIBase.py
@@ -138,6 +138,14 @@ class GUIBase:
def _setValue(self, mlist, property, val, doc):
# Set the value, or override to take special action on the property
if not property.startswith('_') and getattr(mlist, property) <> val:
+ if property == 'preferred_language':
+ ocs = Utils.GetCharSet(getattr(mlist, property)) or 'us-ascii'
+ ncs = Utils.GetCharSet(val) or 'us-ascii'
+ odesc = getattr(mlist, 'description')
+ if ocs != ncs and not isinstance(odesc, unicode):
+ setattr(mlist, 'description',
+ Utils.xml_to_unicode(odesc, ocs).encode(
+ ncs, 'xmlcharrefreplace'))
setattr(mlist, property, val)
def _postValidate(self, mlist, doc):
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 83717f40..8e2518c5 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -262,6 +262,27 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
user = Utils.ObscureEmail(user)
return '%s/%s' % (url, urllib.quote(user.lower()))
+ def GetDescription(self, cset=None, errors='xmlcharrefreplace'):
+ # Get list's description in charset specified by cset.
+ # If cset is None, it uses charset of context language.
+ mcset = Utils.GetCharSet(self.preferred_language)
+ if cset is None:
+ # translation context may not be initialized
+ trns = i18n.get_translation()
+ if trns is None:
+ ccset = 'us-ascii'
+ else:
+ ccset = i18n.get_translation().charset() or 'us-ascii'
+ else:
+ ccset = cset
+ if isinstance(self.description, unicode):
+ return self.description.encode(ccset, errors)
+ if mcset == ccset:
+ return self.description
+ return Utils.xml_to_unicode(self.description, mcset).encode(ccset,
+ errors)
+
+
#
# Instance and subcomponent initialization