@view_config(renderer="templates/form.pt", name="i18n")
@demonstrate("Internationalization")
def i18n(self):
minmax = {"min": 1, "max": 10}
locale_name = get_locale_name(self.request)
class Schema(colander.Schema):
number = colander.SchemaNode(
colander.Integer(),
title=_("A number between ${min} and ${max}", mapping=minmax),
description=_(
"A number between ${min} and ${max}", mapping=minmax
),
validator=colander.Range(1, 10),
)
_LOCALE_ = colander.SchemaNode(
colander.String(),
widget=deform.widget.HiddenWidget(),
default=locale_name,
)
schema = Schema()
form = deform.Form(
schema, buttons=[deform.Button("submit", _("Submit"))]
)
return self.render_form(form, is_i18n=True)