[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/ Widget
error messages has been made translatable
Dmitry Vasiliev
dima at hlabs.spb.ru
Mon Mar 14 05:45:38 EST 2005
Log message for revision 29459:
Widget error messages has been made translatable
Changed:
U Zope3/trunk/src/zope/app/form/browser/exception.py
U Zope3/trunk/src/zope/app/form/browser/textwidgets.py
-=-
Modified: Zope3/trunk/src/zope/app/form/browser/exception.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/exception.py 2005-03-14 10:40:45 UTC (rev 29458)
+++ Zope3/trunk/src/zope/app/form/browser/exception.py 2005-03-14 10:45:38 UTC (rev 29459)
@@ -20,6 +20,7 @@
from cgi import escape
from zope.interface import implements
+from zope.i18n import translate
from zope.app.form.interfaces import IWidgetInputError
from zope.app.form.browser.interfaces import IWidgetInputErrorView
@@ -55,5 +56,6 @@
>>> view.snippet()
u'<span class="error">Could not convert to float.</span>'
"""
- return u'<span class="error">%s</span>' %(
- escape(self.context.doc()))
+ message = self.context.doc()
+ translated = translate(message, context=self.request, default=message)
+ return u'<span class="error">%s</span>' % escape(translated)
Modified: Zope3/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2005-03-14 10:40:45 UTC (rev 29458)
+++ Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2005-03-14 10:45:38 UTC (rev 29459)
@@ -27,7 +27,9 @@
from zope.app.datetimeutils import parseDatetimetz
from zope.app.datetimeutils import DateTimeError
+from zope.app.i18n import ZopeMessageIDFactory as _
+
def escape(str):
if str is not None:
str = saxutils.escape(str)
@@ -149,7 +151,7 @@
try:
value = unicode(input)
except ValueError, v:
- raise ConversionError("Invalid text data", v)
+ raise ConversionError(_("Invalid text data"), v)
return unescape(value)
@@ -161,7 +163,7 @@
try:
value = value.encode('ascii')
except UnicodeError, v:
- raise ConversionError("Invalid textual data", v)
+ raise ConversionError(_("Invalid textual data"), v)
return value
@@ -303,7 +305,7 @@
try:
value = unicode(value)
except ValueError, v:
- raise ConversionError("Invalid unicode data", v)
+ raise ConversionError(_("Invalid unicode data"), v)
else:
value = unescape(value)
value = value.replace("\r\n", "\n")
@@ -408,7 +410,7 @@
seek = input.seek
read = input.read
except AttributeError, e:
- raise ConversionError('Form input is not a file object', e)
+ raise ConversionError(_('Form input is not a file object'), e)
else:
seek(0)
data = read()
@@ -441,7 +443,7 @@
try:
return int(input)
except ValueError, v:
- raise ConversionError("Invalid integer data", v)
+ raise ConversionError(_("Invalid integer data"), v)
class FloatWidget(TextWidget):
@@ -455,7 +457,7 @@
try:
return float(input)
except ValueError, v:
- raise ConversionError("Invalid floating point data", v)
+ raise ConversionError(_("Invalid floating point data"), v)
class DatetimeWidget(TextWidget):
@@ -470,7 +472,7 @@
try:
return parseDatetimetz(input)
except (DateTimeError, ValueError, IndexError), v:
- raise ConversionError("Invalid datetime data", v)
+ raise ConversionError(_("Invalid datetime data"), v)
class DateWidget(TextWidget):
@@ -486,7 +488,7 @@
try:
return parseDatetimetz(input).date()
except (DateTimeError, ValueError, IndexError), v:
- raise ConversionError("Invalid datetime data", v)
+ raise ConversionError(_("Invalid datetime data"), v)
class DateDisplayWidget(DisplayWidget):
More information about the Zope3-Checkins
mailing list