Ticket #8543: internationalized_order_and_delete_labels_for_formsets.diff

File internationalized_order_and_delete_labels_for_formsets.diff, 5.6 KB (added by Javier de la Rosa, 16 years ago)

Patch file and regression test.

  • django/conf/locale/es/LC_MESSAGES/django.po

     
    39423942msgid "Enter a valid IPv4 address."
    39433943msgstr "Introduzca una dirección IPv4 válida."
    39443944
     3945#: forms/formsets.py:242
     3946#: forms/formsets.py:244
     3947msgid "Order"
     3948msgstr "Orden"
     3949
    39453950#: forms/models.py:514
    39463951msgid "Select a valid choice. That choice is not one of the available choices."
    39473952msgstr "Escoja una opción válida. Esa opción no está entre las disponibles."
  • django/forms/formsets.py

    No se puede mostrar: el archivo está marcado como binario.
    svn:mime-type = application/octet-stream
     
    11from forms import Form
    22from django.utils.encoding import StrAndUnicode
    33from django.utils.safestring import mark_safe
     4from django.utils.translation import ugettext_lazy as _
    45from fields import IntegerField, BooleanField
    56from widgets import Media, HiddenInput
    67from util import ErrorList, ValidationError
     
    238239        if self.can_order:
    239240            # Only pre-fill the ordering field for initial forms.
    240241            if index < self._initial_form_count:
    241                 form.fields[ORDERING_FIELD_NAME] = IntegerField(label='Order', initial=index+1, required=False)
     242                form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_(u'Order'), initial=index+1, required=False)
    242243            else:
    243                 form.fields[ORDERING_FIELD_NAME] = IntegerField(label='Order', required=False)
     244                form.fields[ORDERING_FIELD_NAME] = IntegerField(label=_(u'Order'), required=False)
    244245        if self.can_delete:
    245             form.fields[DELETION_FIELD_NAME] = BooleanField(label='Delete', required=False)
     246            form.fields[DELETION_FIELD_NAME] = BooleanField(label=_(u'Delete'), required=False)
    246247
    247248    def add_prefix(self, index):
    248249        return '%s-%s' % (self.prefix, index)
  • tests/regressiontests/forms/formsets.py

     
    432432[{'votes': 900, 'DELETE': True, 'ORDER': 2, 'choice': u'Fergie'}]
    433433
    434434
     435# FormSets with ordering + deletion and internationalization ##################
     436
     437>>> from django.utils.translation import activate, deactivate
     438>>> ChoiceFormSet = formset_factory(Choice, can_order=True, can_delete=True)
     439
     440>>> initial = [
     441...     {'choice': u'Calexico', 'votes': 100},
     442...     {'choice': u'Fergie', 'votes': 900},
     443...     {'choice': u'The Decemberists', 'votes': 500},
     444... ]
     445>>> formset = ChoiceFormSet(initial=initial, auto_id=False, prefix='choices')
     446>>> for form in formset.forms:
     447...    print form.as_ul()
     448<li>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></li>
     449<li>Votes: <input type="text" name="choices-0-votes" value="100" /></li>
     450<li>Order: <input type="text" name="choices-0-ORDER" value="1" /></li>
     451<li>Delete: <input type="checkbox" name="choices-0-DELETE" /></li>
     452<li>Choice: <input type="text" name="choices-1-choice" value="Fergie" /></li>
     453<li>Votes: <input type="text" name="choices-1-votes" value="900" /></li>
     454<li>Order: <input type="text" name="choices-1-ORDER" value="2" /></li>
     455<li>Delete: <input type="checkbox" name="choices-1-DELETE" /></li>
     456<li>Choice: <input type="text" name="choices-2-choice" value="The Decemberists" /></li>
     457<li>Votes: <input type="text" name="choices-2-votes" value="500" /></li>
     458<li>Order: <input type="text" name="choices-2-ORDER" value="3" /></li>
     459<li>Delete: <input type="checkbox" name="choices-2-DELETE" /></li>
     460<li>Choice: <input type="text" name="choices-3-choice" /></li>
     461<li>Votes: <input type="text" name="choices-3-votes" /></li>
     462<li>Order: <input type="text" name="choices-3-ORDER" /></li>
     463<li>Delete: <input type="checkbox" name="choices-3-DELETE" /></li>
     464
     465>>> activate('es')
     466>>> for form in formset.forms:
     467...    print form.as_ul()
     468<li>Choice: <input type="text" name="choices-0-choice" value="Calexico" /></li>
     469<li>Votes: <input type="text" name="choices-0-votes" value="100" /></li>
     470<li>Orden: <input type="text" name="choices-0-ORDER" value="1" /></li>
     471<li>Eliminar: <input type="checkbox" name="choices-0-DELETE" /></li>
     472<li>Choice: <input type="text" name="choices-1-choice" value="Fergie" /></li>
     473<li>Votes: <input type="text" name="choices-1-votes" value="900" /></li>
     474<li>Orden: <input type="text" name="choices-1-ORDER" value="2" /></li>
     475<li>Eliminar: <input type="checkbox" name="choices-1-DELETE" /></li>
     476<li>Choice: <input type="text" name="choices-2-choice" value="The Decemberists" /></li>
     477<li>Votes: <input type="text" name="choices-2-votes" value="500" /></li>
     478<li>Orden: <input type="text" name="choices-2-ORDER" value="3" /></li>
     479<li>Eliminar: <input type="checkbox" name="choices-2-DELETE" /></li>
     480<li>Choice: <input type="text" name="choices-3-choice" /></li>
     481<li>Votes: <input type="text" name="choices-3-votes" /></li>
     482<li>Orden: <input type="text" name="choices-3-ORDER" /></li>
     483<li>Eliminar: <input type="checkbox" name="choices-3-DELETE" /></li>
     484>>> deactivate()
     485
    435486# FormSet clean hook ##########################################################
    436487
    437488FormSets have a hook for doing extra validation that shouldn't be tied to any
Back to Top