Ńň
ĘĽWJc        
   @   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 g Z d S(   i˙˙˙˙N(   t   add_fallbackt   LanguageErrort   get_lang(   t   configt   sessionc       
   C   sG  t  i i i   }  t } t  i oŚ t i d d  } | t  i j o t i	 d t  i |  y t  i
 i t  i |  Wn* t j
 o t i	 d t  i |  qÄ Xt } t i	 d t  i |  qČ n |  ot xP |  D]G } y t |  Wq× t j
 o$ |  i |  t i	 d |  q× Xq× W|  o | o t |   qCn d S(   sď   Checks to see if there is a lang in session.
    If not, tries to guess best match and applies it.
    
    Automatically called by tg controllers to setup i18n.
    Should only be manually called if you override controllers function.
    t   lang_session_keyt   tg_langs   Language %s found in sessions   Language %s: not supporteds   Set request language to %ss   Skip language %s: not supportedN(   t   pylonst   requestt   accept_languaget   best_matchest   FalseR   R   t   gett   logt   debugt   i18nt   set_langR   t   TrueR    t   removet   set_temporary_lang(   t	   languagest   use_session_langR   t   lang(    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/i18n.pyt
   setup_i18n   s2    
			 c      
   C   s˘   y t  i i |   Wn' t j
 o t i d |  d  n Xt i d |  d  y t |   Wn' t j
 o t i d |  d  n Xt i d |  d  d S(   s˝   Set the current language used for translations without touching
    session language.
    
    languages should be a list.
    First lang will be used as main lang, others as fallbacks
    s   Language %s: not supportedi    s   Set request language to %ss(   Language %s: not supported by FormEncodes)   Set request language for FormEncode to %sN(   R   R   R   R   R   t   infot   set_formencode_translation(   R   (    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/i18n.pyR   =   s    		c         K   sE   t  |  g  t i o* t i d d  } |  t | <t i   n d S(   sv   Set the current language used for translations
    in current call and session.
    
    lang should be a string.
    R   R   N(   R   R   R   R   R   t   save(   R   t   kwargsR   (    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/i18n.pyR   U   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(   s3   Set request specific translation of FormEncode
    i˙˙˙˙(   t   translationt
   FormEncodeR   t	   localedirs   IOError: %sN(
   t   gettextR   t
   formencodet   apit   get_localedirt   IOErrorR   R   t   ct   formencode_translation(   R   R   t   tt   ioe(    (    se   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/i18n.pyR   c   s    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.1-py2.6.egg/tg/i18n.pyt   <module>   s   	2			