mozilla-services/cornice — pull request #206 by amarandon (2013-12-13 16:56:35+00:00)
Title: Allow i18n of colander error messages

Fix #200

After investigating the issue further, I realized that not everything can be done by Colander. Colander can only provide translation strings but it cannot perform the translation itself because it doesn't depend on Pyramid and doesn't know about localizers. As suggested earlier, I've proposed a change to Colander so that we can pass a translation callable to the ``asdict`` method: https://github.com/Pylons/colander/pull/157

However it's still up to Cornice to provide a callback that is aware of the current locale.
Since Cornice aims at following HTTP conventions, I've added support for the HTTP ``Accept-Language`` header. I've also added some configuration code that sets up a localizer depending on configuration variables based on suggestions from the Pyramid documentation:
* [``pyramid.default_locale_name``](http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/i18n.html#localization-related-deployment-settings) to specify the default locale
* [``available_languages``](http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/i18n.html#detecting-available-languages) to specify the list of available languages