diff options
author | Yasuhito FUTATSUKI at POEM <futatuki@poem.co.jp> | 2018-06-22 01:23:09 +0900 |
---|---|---|
committer | Yasuhito FUTATSUKI at POEM <futatuki@poem.co.jp> | 2018-06-22 01:23:09 +0900 |
commit | 6a3bbdd20a8fac82f161f353c40604387f52cb09 (patch) | |
tree | 4d752b4a3f0f4bd3100108bc9cf584438772d778 /Mailman/MailList.py | |
parent | 388b4a41ece74d11298e640429bef5f903221d09 (diff) | |
download | mailman2-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 '')
-rw-r--r-- | Mailman/MailList.py | 21 |
1 files changed, 21 insertions, 0 deletions
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 |