Hi,
I want to translate my web page to German. The T()"operator" is very fine,
but I could not find any way to translate message like
"enter an integer less than or equal to %(max)g"
in class IS_INT_IN_RANGE.
I think it is very unprofessional to mix English and German words and I have
tried to find a solution.
I have changed the following lines (file validators.py, class
IS_INT_IN_RANGE)
def __init__(
self,
minimum=None,
maximum=None,
error_message=None,
*T=lambda x:x,*
):
self.minimum = self.maximum = None
if minimum is None:
if maximum is None:
if error_message is None:
self.error_message = *T('enter an integer')*
else:
self.maximum = int(maximum)
if error_message is None:
error_message = *T('enter an integer less than or equal
to %(max)g')*
self.error_message = error_message %
dict(max=self.maximum-1)
elif maximum is None:
self.minimum = int(minimum)
if error_message is None:
error_message = *T('enter an integer greater than or equal
to %(min)g')*
self.error_message = error_message % dict(min=self.minimum)
else:
self.minimum = int(minimum)
self.maximum = int(maximum)
if error_message is None:
error_message = *T('enter an integer between %(min)g and
%(max)g')*
self.error_message = error_message % dict(min=self.minimum,
max=self.maximum-1)
And I have used it:
Field('number', type='integer',
requires=IS_INT_IN_RANGE(2,5,*T=T*), label=T('number')),
....
It's full compatible. Are there any disadvantages in my solution? Or is
there any other solution?
Of course the whole file validators.py has to be changed. Maybe the file
tools.py too?
Is it possible to use this proposal in the next release?
Regards,
Martin