InternationalizationΒΆ
Deform is fully internationalizable and localizable. gettext
.mo
files exist in the deform
and colander
packages
which contain (currently incomplete) translations to various languages
for the purpose of rendering localized error messages.
The following should get you started with i18n
in pyramid
:
import deform
from pkg_resources import resource_filename
from pyramid.i18n import get_localizer
from pyramid.threadlocal import get_current_request
def main(global_config, **settings):
config = Configurator(settings=settings)
config.add_translation_dirs(
'colander:locale',
'deform:locale',
)
def translator(term):
return get_localizer(get_current_request()).translate(term)
deform_template_dir = resource_filename('deform', 'templates/')
zpt_renderer = deform.ZPTRendererFactory(
[deform_template_dir],
translator=translator,
)
deform.Form.set_default_renderer(zpt_renderer)
See the Internationalization demo for an example of how Deform error and status messages can be localized. This demonstration uses the internationalization and localization features of Pyramid to render Deform error messages into Chameleon form renderings.