Mercurial > p > roundup > code
changeset 4537:61cd652da1cd
Allow to turn off translation of generated html options in menu method...
...of LinkHTMLProperty and MultilinkHTMLProperty -- default is translation
as it used to be
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Fri, 30 Sep 2011 09:35:34 +0000 |
| parents | f2e6b303aa8a |
| children | fd972e18b21a |
| files | CHANGES.txt roundup/cgi/templating.py |
| diffstat | 2 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Wed Sep 28 15:50:20 2011 +0000 +++ b/CHANGES.txt Fri Sep 30 09:35:34 2011 +0000 @@ -10,6 +10,9 @@ - issue2550678: Allow pagesize=-1 which returns all results. Suggested and implemented by John Kristensen. Tested by Satchidanand Haridas. (Bernhard) +- Allow to turn off translation of generated html options in menu method + of LinkHTMLProperty and MultilinkHTMLProperty -- default is + translation as it used to be (Ralf) Fixed:
--- a/roundup/cgi/templating.py Wed Sep 28 15:50:20 2011 +0000 +++ b/roundup/cgi/templating.py Fri Sep 30 09:35:34 2011 +0000 @@ -1973,7 +1973,7 @@ **kwargs) def menu(self, size=None, height=None, showid=0, additional=[], value=None, - sort_on=None, html_kwargs = {}, **conditions): + sort_on=None, html_kwargs={}, translate=True, **conditions): """ Render a form select list for this property "size" is used to limit the length of the list labels @@ -1986,6 +1986,11 @@ (direction, property) where direction is '+' or '-'. A single string with the direction prepended may be used. For example: ('-', 'order'), '+name'. + "html_kwargs" specified additional html args for the + generated html <select> + "translate" indicates if we should do translation of labels + using gettext -- this is often desired (e.g. for status + labels) but sometimes not. The remaining keyword arguments are used as conditions for filtering the items in the list - they're passed as the @@ -2074,7 +2079,10 @@ lab = lab + ' (%s)'%', '.join(m) # and generate - lab = cgi.escape(self._(lab)) + tr = str + if translate: + tr = self._ + lab = cgi.escape(tr(lab)) l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab)) l.append('</select>') return '\n'.join(l) @@ -2198,7 +2206,8 @@ return self.input(name=self._formname, size=size, **kwargs) def menu(self, size=None, height=None, showid=0, additional=[], - value=None, sort_on=None, html_kwargs = {}, **conditions): + value=None, sort_on=None, html_kwargs={}, translate=True, + **conditions): """ Render a form <select> list for this property. "size" is used to limit the length of the list labels @@ -2299,7 +2308,10 @@ lab = lab + ' (%s)'%', '.join(m) # and generate - lab = cgi.escape(self._(lab)) + tr = str + if translate: + tr = self._ + lab = cgi.escape(tr(lab)) l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab)) l.append('</select>')
