web/formfields.py
branchstable
changeset 3790 34fdb8fb49d1
parent 3689 deb13e88e037
child 3873 4d95109582c7
equal deleted inserted replaced
3789:fb22b55f80f8 3790:34fdb8fb49d1
   201             if vocab and not isinstance(vocab[0], (list, tuple)):
   201             if vocab and not isinstance(vocab[0], (list, tuple)):
   202                 vocab = [(x, x) for x in vocab]
   202                 vocab = [(x, x) for x in vocab]
   203         else:
   203         else:
   204             vocab = form.form_field_vocabulary(self)
   204             vocab = form.form_field_vocabulary(self)
   205         if self.internationalizable:
   205         if self.internationalizable:
   206             vocab = [(form.req._(label), value) for label, value in vocab]
   206             # the short-cirtcuit 'and' boolean operator is used here to permit
       
   207             # a valid empty string in vocabulary without attempting to translate
       
   208             # it by gettext (which can lead to weird strings display)
       
   209             vocab = [(label and form.req._(label), value) for label, value in vocab]
   207         if self.sort:
   210         if self.sort:
   208             vocab = vocab_sort(vocab)
   211             vocab = vocab_sort(vocab)
   209         return vocab
   212         return vocab
   210 
   213 
   211     def form_init(self, form):
   214     def form_init(self, form):