[Zope3-checkins]
SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/
backported from trunk:
Yvo Schubbe
y.2005- at wcm-solutions.de
Wed Jul 27 12:58:41 EDT 2005
Log message for revision 37493:
backported from trunk:
-r29459 (Widget error messages has been made translatable)
Changed:
U Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/exception.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/tests/test_exception.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/textwidgets.py
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/exception.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/exception.py 2005-07-27 16:10:06 UTC (rev 37492)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/exception.py 2005-07-27 16:58:41 UTC (rev 37493)
@@ -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/branches/ZopeX3-3.0/src/zope/app/form/browser/tests/test_exception.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/tests/test_exception.py 2005-07-27 16:10:06 UTC (rev 37492)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/tests/test_exception.py 2005-07-27 16:58:41 UTC (rev 37493)
@@ -16,11 +16,13 @@
$Id$
"""
import unittest
+from zope.app.tests.placelesssetup import setUp, tearDown
from zope.testing.doctestunit import DocTestSuite
def test_suite():
return unittest.TestSuite((
- DocTestSuite('zope.app.form.browser.exception'),
+ DocTestSuite('zope.app.form.browser.exception',
+ setUp=setUp, tearDown=tearDown),
))
if __name__ == '__main__':
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/textwidgets.py 2005-07-27 16:10:06 UTC (rev 37492)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/textwidgets.py 2005-07-27 16:58:41 UTC (rev 37493)
@@ -26,7 +26,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)
@@ -148,7 +150,7 @@
try:
value = unicode(input)
except ValueError, v:
- raise ConversionError("Invalid text data", v)
+ raise ConversionError(_("Invalid text data"), v)
return unescape(value)
@@ -160,7 +162,7 @@
try:
value = value.encode('ascii')
except UnicodeError, v:
- raise ConversionError("Invalid textual data", v)
+ raise ConversionError(_("Invalid textual data"), v)
return value
@@ -268,7 +270,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")
@@ -373,7 +375,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()
@@ -406,7 +408,7 @@
try:
return int(input)
except ValueError, v:
- raise ConversionError("Invalid integer data", v)
+ raise ConversionError(_("Invalid integer data"), v)
class FloatWidget(TextWidget):
@@ -420,7 +422,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):
@@ -435,7 +437,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):
@@ -451,4 +453,4 @@
try:
return parseDatetimetz(input).date()
except (DateTimeError, ValueError, IndexError), v:
- raise ConversionError("Invalid datetime data", v)
+ raise ConversionError(_("Invalid datetime data"), v)
More information about the Zope3-Checkins
mailing list