Ñò
(xµJc           @   s®   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k l Z l Z l Z d  d k l Z l Z e  i	 e
  Z d   Z d   Z d   Z d   Z d d	 d
 d d g Z d S(   iÿÿÿÿN(   t   add_fallbackt   LanguageErrort   get_lang(   t   configt   sessionc          C   s   t  i oP t  i i t i d d   }  |  o! t |  t  o |  g }  qV q` g  }  n g  }  |  i t  i i i	    t
 |   d S(   s  Set languages from the request header and the session.

    The session language(s) take priority over the request languages.

    Automatically called by tg controllers to setup i18n.
    Should only be manually called if you override controllers function.
    t   lang_session_keyt   tg_langN(   t   pylonsR   t   getR   t
   isinstancet
   basestringt   extendt   requestt   accept_languaget   best_matchest   set_temporary_lang(   t	   languages(    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.3-py2.6.egg/tg/i18n.pyt
   setup_i18n   s    
	
c      	   C   s   y t  i i |   Wn# t j
 o t i d |   n Xt i d |   y t |   Wn# t j
 o t i d |   n Xt i d |   d S(   sØ   Set the current language(s) used for translations without touching
    the session language.

    languages should be a string or a list of strings.
    First lang will be used as main lang, others as fallbacks.
    s   Language %s: not supporteds   Set request language to %ss(   Language %s: not supported by FormEncodes)   Set request language for FormEncode to %sN(   R   t   i18nt   set_langR   t   logt   infot   set_formencode_translation(   R   (    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.3-py2.6.egg/tg/i18n.pyR   #   s    c         K   s<   t  |   t i o$ |  t t i d d  <t i   n d S(   sÎ   Set the current language(s) used for translations
    in current call and session.

    languages should be a string or a list of strings.
    First lang will be used as main lang, others as fallbacks.
    R   R   N(   R   R   R   R   R   t   save(   R   t   kwargs(    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.3-py2.6.egg/tg/i18n.pyR   8   s    

c      
   C   sm   d d k  l } y% | d d |  d t i i   } Wn% t j
 o } t d |   n X| t i _	 d S(   s/   Set request specific translation of FormEncode.iÿÿÿÿ(   t   translationt
   FormEncodeR   t	   localedirs   IOError: %sN(
   t   gettextR   t
   formencodet   apit   get_localedirt   IOErrorR   R   t   tmpl_contextt   formencode_translation(   R   R   R"   t   error(    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.3-py2.6.egg/tg/i18n.pyR   F   s    	R   R   R   R    R   (   t   loggingR   R   t   pylons.i18nR    R   R   R   R   t	   getLoggert   __name__R   R   R   R   R   t   __all__(    (    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.3-py2.6.egg/tg/i18n.pyt   <module>   s   				