aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/i18n.py
diff options
context:
space:
mode:
authorbwarsaw <>2003-03-31 21:49:43 +0000
committerbwarsaw <>2003-03-31 21:49:43 +0000
commitde777e10950eed3aff489e74908578b5759003bb (patch)
tree10711cb2e58ce6b83faf021b0cd084de58d22bc4 /Mailman/i18n.py
parentfb97bfb122d119977a719f3a33673edaaae5bd37 (diff)
downloadmailman2-de777e10950eed3aff489e74908578b5759003bb.tar.gz
mailman2-de777e10950eed3aff489e74908578b5759003bb.tar.xz
mailman2-de777e10950eed3aff489e74908578b5759003bb.zip
Backporting from trunk
Diffstat (limited to '')
-rw-r--r--Mailman/i18n.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/Mailman/i18n.py b/Mailman/i18n.py
index d38eba85..c5853438 100644
--- a/Mailman/i18n.py
+++ b/Mailman/i18n.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 2000-2003 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -17,7 +17,7 @@
import sys
import time
import gettext
-from types import StringType
+from types import StringType, UnicodeType
from Mailman import mm_cfg
from Mailman.SafeDict import SafeDict
@@ -74,8 +74,19 @@ def _(s):
# missing key in the dictionary.
dict = SafeDict(frame.f_globals.copy())
dict.update(frame.f_locals)
- # Translate the string, then interpolate into it.
- return _translation.gettext(s) % dict
+ # Translating the string returns an encoded 8-bit string. Rather than
+ # turn that into a Unicode, we turn any Unicodes in the dictionary values
+ # into encoded 8-bit strings. BAW: Returning a Unicode here broke too
+ # much other stuff and _() has many tentacles. Eventually I think we want
+ # to use Unicode everywhere.
+ tns = _translation.gettext(s)
+ charset = _translation.charset()
+ if not charset:
+ charset = 'us-ascii'
+ for k, v in dict.items():
+ if isinstance(v, UnicodeType):
+ dict[k] = v.encode(charset, 'replace')
+ return tns % dict