Changeset 8024 for main/waeup.kofa/trunk


Ignore:
Timestamp:
3 Apr 2012, 07:37:37 (13 years ago)
Author:
Henrik Bettermann
Message:

Use customized translations for sequence widgets.

Attention: The call method of the original SequenceDisplayWidget? had to be patched because it contains a bug (mail will follow).

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/facultypage.pt

    r7811 r8024  
    11<div i18n:domain="waeup.kofa" i18n:translate="" tal:condition="python: not len(context.keys())">
    2 There no subobjects registered yet.
     2There are no subobjects registered yet.
    33</div>
    44
  • main/waeup.kofa/trunk/src/waeup/kofa/locales/de/LC_MESSAGES/zope.po

    r8023 r8024  
    22msgstr ""
    33"Project-Id-Version: WAeUP.KOFA\n"
    4 "PO-Revision-Date: 2012-04-03 07:03+0100\n"
     4"PO-Revision-Date: 2012-04-03 09:28+0100\n"
    55"Last-Translator: Henrik Bettermann <henrik@waeup.org>\n"
    66"Language-Team: WAeUP Germany <henrik@waeup.org>\n"
     
    3939msgstr "--"
    4040
     41#. Default: "(no value available)"
     42#: src/zope/app/form/browser/sequencewidget.py:256
     43msgid "sequence-value-not-provided"
     44msgstr "--"
     45
     46#. Default: "(no values)"
     47#: src/zope/app/form/browser/sequencewidget.py:259
     48msgid "sequence-value-is-empty"
     49msgstr "--"
     50
  • main/waeup.kofa/trunk/src/waeup/kofa/locales/en/LC_MESSAGES/zope.po

    r8023 r8024  
    22msgstr ""
    33"Project-Id-Version: WAeUP.KOFA\n"
    4 "PO-Revision-Date: 2012-04-03 07:02+0100\n"
     4"PO-Revision-Date: 2012-04-03 08:19+0100\n"
    55"Last-Translator: Henrik Bettermann <henrik@waeup.org>\n"
    66"Language-Team: WAeUP Germany <henrik@waeup.org>\n"
     
    3939msgstr "--"
    4040
     41#. Default: "(no value available)"
     42#: src/zope/app/form/browser/sequencewidget.py:256
     43msgid "sequence-value-not-provided"
     44msgstr "--"
     45
     46#. Default: "(no values)"
     47#: src/zope/app/form/browser/sequencewidget.py:259
     48msgid "sequence-value-is-empty"
     49msgstr "--"
     50
  • main/waeup.kofa/trunk/src/waeup/kofa/locales/zope.pot

    r8023 r8024  
    3737msgid "vocabulary-missing-multiple-value-for-edit"
    3838msgstr ""
     39
     40#. Default: "(no value available)"
     41#: src/zope/app/form/browser/sequencewidget.py:256
     42msgid "sequence-value-not-provided"
     43msgstr ""
     44
     45#. Default: "(no values)"
     46#: src/zope/app/form/browser/sequencewidget.py:259
     47msgid "sequence-value-is-empty"
     48msgstr ""
  • main/waeup.kofa/trunk/src/waeup/kofa/widgets/sequencewidget.py

    r7819 r8024  
    2222"""
    2323import grok
     24from zope.i18n import translate
    2425from zope.browserpage import ViewPageTemplateFile
    2526from zope.formlib.interfaces import IInputWidget, IDisplayWidget
     
    4748    itemTag = 'div'
    4849
     50    def __call__(self):
     51    """This is is a patch for the orginal __call__ method which doesn't call
     52    the translate function properly.
     53    """
     54
     55        # get the data to display:
     56        if self._renderedValueSet():
     57            data = self._data
     58        else:
     59            data = self.context.get(self.context.context)
     60
     61        # deal with special cases:
     62        if data == self.context.missing_value:
     63            return translate(self._missingValueMessage, context=self.request)
     64        data = list(data)
     65        if not data:
     66            return translate(self._emptySequenceMessage, context=self.request)
     67
     68        parts = []
     69        for i, item in enumerate(data):
     70            widget = self._getWidget(i)
     71            widget.setRenderedValue(item)
     72            s = widget()
     73            if self.itemTag:
     74                s = "<%s>%s</%s>" % (self.itemTag, s, self.itemTag)
     75            parts.append(s)
     76        contents = "\n".join(parts)
     77        if self.tag:
     78            contents = "\n%s\n" % contents
     79            contents = renderElement(self.tag,
     80                                     cssClass=self.cssClass,
     81                                     extra=self.extra,
     82                                     contents=contents)
     83        return contents
     84
    4985# Register our sequence widgets as default for lists.
    5086@grok.adapter(IList, IField, IBrowserRequest)
Note: See TracChangeset for help on using the changeset viewer.