@view_config(route_name='front_pages.contact_us', renderer=
    'myweb:templates/front_pages/contact_us.genshi')
def contact_us(request):
    """Display contact us form or send mail
    """
_ = get_localizer(request)
factory = FormFactory(_)
ContactForm = factory.make_contact_form()
form = ContactForm(request.params)
return dict(form=form)
How to use Pyramid i18n outside of views and templates?