в конфиге
pyramid.default_locale_name = ru
в main
config.add_translation_dirs('colander:locale')
config.add_translation_dirs('colander:locale')
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ ... config.set_locale_negotiator('myproject.locale_negotiator') ... return config.make_wsgi_app()
def locale_negotiator(request): settings = request.registry.settings available = settings['pyramid.available_languages'].split() return request.accept_language.best_match(available)
[app:myproject] use = egg:myproject ... pyramid.default_locale_name = en pyramid.available_languages = en ru