title: How to use Pyramid i18n outside of views and templates?
body: <p><a href="http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/narr/i18n.html#performing-a-translation" rel="nofollow">Pyramid documentation</a> shows us how to use i18n inside views (and <a href="http://blog.abourget.net/2011/1/13/pyramid-and-mako%3a-how-to-do-i18n-the-pylons-way/" rel="nofollow">templates as well</a>). But how to does one use it outside of views and templates where we have no access to current <code>request</code> (for example, in <code>forms</code> and <code>models</code>)?</p>
  
  <p>@Michael said to pass <code>request</code> to models and forms. But is it right? I mean if form fields defines before <code>__init__()</code> method calls, the same with models. They don't see any parameters from views...</p>
  
  <p>In Pylons we could simply use <code>get_lang()</code> and <code>set_lang()</code> and define preferable language in parent controller and then use <code>ugettext()</code> and <code>ungettext()</code> in any place we want without calling it from <code>request</code> directly every possible time (in views).</p>
  
  <p>How to do that in Pyramid? Note that the language must be set from user's settings (session, cookies, db, etc).</p>