[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/f Fix a bug
introduced by r39990: While the templates were indeed
Philipp von Weitershausen
philikon at philikon.de
Thu Nov 10 11:39:22 EST 2005
Log message for revision 40030:
Fix a bug introduced by r39990: While the templates were indeed
translating the label property, the hint property wasn't translated in
the template. This caused a test failure in Five and thus in Zope 2 trunk.
Copied the relevant functional test from there to illustrate the issue.
Changed:
A Zope3/trunk/src/zope/app/form/browser/ftests/i18n.zcml
A Zope3/trunk/src/zope/app/form/browser/ftests/locales/
A Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/
A Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/
A Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.mo
A Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.po
A Zope3/trunk/src/zope/app/form/browser/ftests/locales/formtest.pot
A Zope3/trunk/src/zope/app/form/browser/ftests/test_i18n.py
A Zope3/trunk/src/zope/app/form/browser/i18n.txt
U Zope3/trunk/src/zope/app/form/browser/widget_macros.pt
U Zope3/trunk/src/zope/app/ftesting.zcml
-=-
Added: Zope3/trunk/src/zope/app/form/browser/ftests/i18n.zcml
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/i18n.zcml 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/i18n.zcml 2005-11-10 16:39:21 UTC (rev 40030)
@@ -0,0 +1,17 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ i18n_domain="formtest">
+
+ <browser:addform
+ schema=".test_i18n.IFieldContent"
+ content_factory=".test_i18n.FieldContent"
+ name="addfieldcontent.html"
+ label="Add Field Content"
+ permission="zope.Public"
+ />
+
+ <i18n:registerTranslations directory="locales"/>
+
+</configure>
Property changes on: Zope3/trunk/src/zope/app/form/browser/ftests/i18n.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.mo
===================================================================
(Binary files differ)
Property changes on: Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.po
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.po 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/locales/de/LC_MESSAGES/formtest.po 2005-11-10 16:39:21 UTC (rev 40030)
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: Five form tests\n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: 2005-07-29 11:38+0100\n"
+"Last-Translator: \n"
+"Language-Team: Five Developers <z3-five at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Title"
+msgstr "Titel"
+
+msgid "A short description of the event."
+msgstr "Eine kurze Beschreibung des Ereignisses."
+
+msgid "Description"
+msgstr "Beschreibung"
+
+msgid "A long description of the event."
+msgstr "Eine ausführliche Beschreibung des Ereignisses."
+
+msgid "Some number"
+msgstr "Irgendeine Zahl"
+
+msgid "Some List"
+msgstr "Irgendeine Liste"
+
+msgid "Some item"
+msgstr "Irgendeine Element"
+
+msgid "Edit Field Content"
+msgstr "Felderinhalt bearbeiten"
+
+msgid "Add Field Content"
+msgstr "Felderinhalt hinzufügen"
+
Added: Zope3/trunk/src/zope/app/form/browser/ftests/locales/formtest.pot
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/locales/formtest.pot 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/locales/formtest.pot 2005-11-10 16:39:21 UTC (rev 40030)
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: Five form tests\n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Last-Translator: \n"
+"Language-Team: Five Developers <z3-five at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Title"
+msgstr ""
+
+msgid "A short description of the event."
+msgstr ""
+
+msgid "Description"
+msgstr ""
+
+msgid "A long description of the event."
+msgstr ""
+
+msgid "Some number"
+msgstr ""
+
+msgid "Some List"
+msgstr ""
+
+msgid "Some item"
+msgstr ""
+
+msgid "Edit Field Content"
+msgstr ""
+
+msgid "Add Field Content"
+msgstr ""
Added: Zope3/trunk/src/zope/app/form/browser/ftests/test_i18n.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_i18n.py 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_i18n.py 2005-11-10 16:39:21 UTC (rev 40030)
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test form i18n
+
+$Id$
+"""
+import unittest
+import doctest
+from persistent import Persistent
+from zope.interface import Interface, implements
+from zope.schema import TextLine, Text, Int, List
+from zope.i18nmessageid import MessageFactory
+from zope.app.testing.functional import FunctionalDocFileSuite
+
+_ = MessageFactory('formtest')
+
+__docformat__ = "reStructuredText"
+
+class IFieldContent(Interface):
+
+ title = TextLine(
+ title=_(u"Title"),
+ description=_(u"A short description of the event."),
+ default=u"",
+ required=True
+ )
+
+ description = Text(
+ title=_(u"Description"),
+ description=_(u"A long description of the event."),
+ default=u"",
+ required=False
+ )
+
+ somenumber = Int(
+ title=_(u"Some number"),
+ default=0,
+ required=False
+ )
+
+ somelist = List(
+ title=_(u"Some List"),
+ value_type=TextLine(title=_(u"Some item")),
+ default=[],
+ required=False
+ )
+
+class FieldContent(Persistent):
+ implements(IFieldContent)
+
+def test_suite():
+ return unittest.TestSuite((
+ FunctionalDocFileSuite('i18n.txt', package='zope.app.form.browser',
+ optionflags=doctest.ELLIPSIS)
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: Zope3/trunk/src/zope/app/form/browser/ftests/test_i18n.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/form/browser/i18n.txt
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/i18n.txt 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/form/browser/i18n.txt 2005-11-10 16:39:21 UTC (rev 40030)
@@ -0,0 +1,117 @@
+Internationalization
+====================
+
+Forms are fully internationalized. The field names, descriptions,
+labels, and hints are all automatically translated if they are made
+i18n messages in the schema.
+
+Let's take this simple add form...
+
+ >>> print http(r"""
+ ... GET /+/addfieldcontent.html HTTP/1.1
+ ... Authorization: Basic mgr:mgrpw
+ ... """, handle_errors=False)
+ HTTP/1.1 200 Ok
+ ...
+
+with an error...
+
+ >>> print http(r"""
+ ... POST /+/addfieldcontent.html HTTP/1.1
+ ... Authorization: Basic mgr:mgrpw
+ ... Content-Length: 670
+ ... Content-Type: multipart/form-data; boundary=---------------------------19588947601368617292863650127
+ ...
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="field.title"
+ ...
+ ...
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="field.description"
+ ...
+ ...
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="field.somenumber"
+ ...
+ ... 0
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+ ...
+ ... Hinzufxgen
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="add_input_name"
+ ...
+ ...
+ ... -----------------------------19588947601368617292863650127--
+ ... """, handle_errors=False)
+ HTTP/1.1 200 Ok
+ ...
+ There are <strong>1</strong> input errors.
+ ...
+
+
+Translated
+----------
+
+And now the add form in German:
+
+ >>> print http(r"""
+ ... GET /+/addfieldcontent.html HTTP/1.1
+ ... Accept-Language: de
+ ... Authorization: Basic mgr:mgrpw
+ ... """, handle_errors=False)
+ HTTP/1.1 200 Ok
+ ...Felderinhalt hinzuf...
+ ...Eine kurz...Titel...
+ ...Eine ausf...Beschreibung...
+ ...Irgendeine Zahl...
+ ...Irgendeine Liste...
+ ...hinzuf...
+ ...Auffrischen...
+ ...Hinzuf...
+ ...Objektname...
+
+The same with an input error:
+
+ >>> print http(r"""
+ ... POST /+/addfieldcontent.html HTTP/1.1
+ ... Accept-Language: de
+ ... Authorization: Basic mgr:mgrpw
+ ... Content-Length: 670
+ ... Content-Type: multipart/form-data; boundary=---------------------------19588947601368617292863650127
+ ...
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="field.title"
+ ...
+ ...
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="field.description"
+ ...
+ ...
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="field.somenumber"
+ ...
+ ... 0
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+ ...
+ ... Hinzufxgen
+ ... -----------------------------19588947601368617292863650127
+ ... Content-Disposition: form-data; name="add_input_name"
+ ...
+ ...
+ ... -----------------------------19588947601368617292863650127--
+ ... """, handle_errors=False)
+ HTTP/1.1 200 Ok
+ ...Felderinhalt hinzuf...
+ ...Ein Fehler ist aufgetreten...
+ ...Es gab <strong>1</strong> Eingabefehler...
+ ...Eine kurz...Titel...
+ ...Erforderliche Eingabe fehlt...
+ ...Eine ausf...Beschreibung...
+ ...Irgendeine Zahl...
+ ...Irgendeine Liste...
+ ...hinzuf...
+ ...Auffrischen...
+ ...Hinzuf...
+ ...Objektname...
Property changes on: Zope3/trunk/src/zope/app/form/browser/i18n.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/form/browser/widget_macros.pt
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/widget_macros.pt 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/form/browser/widget_macros.pt 2005-11-10 16:39:21 UTC (rev 40030)
@@ -6,7 +6,8 @@
<div class="label">
<label for="field.name" title="The widget's hint"
tal:attributes="for widget/name; title widget/hint"
- tal:content="widget/label" i18n:translate=""
+ tal:content="widget/label" i18n:attributes="title"
+ i18n:translate=""
>The Label</label>
</div>
<tal:block define="error widget/error"
Modified: Zope3/trunk/src/zope/app/ftesting.zcml
===================================================================
--- Zope3/trunk/src/zope/app/ftesting.zcml 2005-11-10 16:24:01 UTC (rev 40029)
+++ Zope3/trunk/src/zope/app/ftesting.zcml 2005-11-10 16:39:21 UTC (rev 40030)
@@ -6,5 +6,6 @@
<include package=".container.browser.ftests" />
<include package=".pagetemplate.ftests" />
+<include package=".form.browser.ftests" file="i18n.zcml" />
</configure>
More information about the Zope3-Checkins
mailing list