Author: gh
Date: 2006-10-03 09:24:57 -0600 (Tue, 03 Oct 2006)
New Revision: 1971
Modified:
FormEncode/branches/gettext-enabled/formencode/api.py
FormEncode/branches/gettext-enabled/formencode/schema.py
Log:
UnicodeEncodeError Bug, Factor out get_localedir
Modified: FormEncode/branches/gettext-enabled/formencode/api.py
===================================================================
--- FormEncode/branches/gettext-enabled/formencode/api.py 2006-10-03
04:48:02 UTC (rev 1970)
+++ FormEncode/branches/gettext-enabled/formencode/api.py 2006-10-03
15:24:57 UTC (rev 1971)
@@ -13,9 +13,11 @@
import gettext
+def get_localedir():
+ return "%s%s%s" % (os.path.dirname(formencode.__file__), os.path.sep,
"i18n")
+
def set_stdtranslation(domain="FormEncode", languages=None, \
- localedir = "%s%s%s" % \
- (os.path.dirname(formencode.__file__), os.path.sep,
"i18n")):
+ localedir = get_localedir()):
t = gettext.translation(domain=domain, \
languages=languages, \
@@ -174,11 +176,17 @@
if self.use_builtins_gettext:
import __builtin__
trans = __builtin__._
+
else:
trans = _stdtrans
+
except AttributeError:
trans = _stdtrans
+
+ if not callable(trans):
+ trans = _stdtrans
+
try:
return trans(self._messages[msgName], **self.gettextargs) % kw
except KeyError, e:
Modified: FormEncode/branches/gettext-enabled/formencode/schema.py
===================================================================
--- FormEncode/branches/gettext-enabled/formencode/schema.py 2006-10-03
04:48:02 UTC (rev 1970)
+++ FormEncode/branches/gettext-enabled/formencode/schema.py 2006-10-03
15:24:57 UTC (rev 1971)
@@ -291,7 +291,7 @@
if isinstance(v, Exception):
try:
return str(v)
- except UnicodeDecodeError:
+ except (UnicodeDecodeError, UnicodeEncodeError):
# There doesn't seem to be a better way to get a str()
# version if possible, and unicode() if necessary, because
# testing for the presence of a __unicode__ method isn't
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs