Skip to content

Commit f6a978f

Browse files
author
Ralf Schlatterbeck
committed
Allow to turn off translation of generated html options in menu method...
...of LinkHTMLProperty and MultilinkHTMLProperty -- default is translation as it used to be
1 parent 2869884 commit f6a978f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Features:
1010
- issue2550678: Allow pagesize=-1 which returns all results.
1111
Suggested and implemented by John Kristensen.
1212
Tested by Satchidanand Haridas. (Bernhard)
13+
- Allow to turn off translation of generated html options in menu method
14+
of LinkHTMLProperty and MultilinkHTMLProperty -- default is
15+
translation as it used to be (Ralf)
1316

1417
Fixed:
1518

roundup/cgi/templating.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ def field(self, showid=0, size=None, **kwargs):
19731973
**kwargs)
19741974

19751975
def menu(self, size=None, height=None, showid=0, additional=[], value=None,
1976-
sort_on=None, html_kwargs = {}, **conditions):
1976+
sort_on=None, html_kwargs={}, translate=True, **conditions):
19771977
""" Render a form select list for this property
19781978
19791979
"size" is used to limit the length of the list labels
@@ -1986,6 +1986,11 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
19861986
(direction, property) where direction is '+' or '-'. A
19871987
single string with the direction prepended may be used.
19881988
For example: ('-', 'order'), '+name'.
1989+
"html_kwargs" specified additional html args for the
1990+
generated html <select>
1991+
"translate" indicates if we should do translation of labels
1992+
using gettext -- this is often desired (e.g. for status
1993+
labels) but sometimes not.
19891994
19901995
The remaining keyword arguments are used as conditions for
19911996
filtering the items in the list - they're passed as the
@@ -2074,7 +2079,10 @@ def menu(self, size=None, height=None, showid=0, additional=[], value=None,
20742079
lab = lab + ' (%s)'%', '.join(m)
20752080

20762081
# and generate
2077-
lab = cgi.escape(self._(lab))
2082+
tr = str
2083+
if translate:
2084+
tr = self._
2085+
lab = cgi.escape(tr(lab))
20782086
l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab))
20792087
l.append('</select>')
20802088
return '\n'.join(l)
@@ -2198,7 +2206,8 @@ def field(self, size=30, showid=0, **kwargs):
21982206
return self.input(name=self._formname, size=size, **kwargs)
21992207

22002208
def menu(self, size=None, height=None, showid=0, additional=[],
2201-
value=None, sort_on=None, html_kwargs = {}, **conditions):
2209+
value=None, sort_on=None, html_kwargs={}, translate=True,
2210+
**conditions):
22022211
""" Render a form <select> list for this property.
22032212
22042213
"size" is used to limit the length of the list labels
@@ -2299,7 +2308,10 @@ def menu(self, size=None, height=None, showid=0, additional=[],
22992308
lab = lab + ' (%s)'%', '.join(m)
23002309

23012310
# and generate
2302-
lab = cgi.escape(self._(lab))
2311+
tr = str
2312+
if translate:
2313+
tr = self._
2314+
lab = cgi.escape(tr(lab))
23032315
l.append('<option %svalue="%s">%s</option>'%(s, optionid,
23042316
lab))
23052317
l.append('</select>')

0 commit comments

Comments
 (0)