class FormFactory(object):

    def __init__(self, localizer):
        self.localizer = localizer
_ = self.localizer
self.required_msg = _('This field is required.')
self.invalid_email_msg = _('Invalid email address.')
self.password_not_match_msg = _('Password must match')

def make_contact_form(self):
    _ = self.localizer


class ContactForm(Form):
    email = TextField(_('Email address'), [validators.Required(self.
        required_msg), validators.Email(self.invalid_email_msg)])
content = TextAreaField(_('Content'), [validators.Required(self.required_msg)]
    )
return ContactForm
How to use Pyramid i18n outside of views and templates?