3
(h                 @   s  d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	d
dddddddddddddddddddddd d!d"gZd#ZG d$d% d%eZG d&d' d'eZe Z[d(d ZeZd)d Zd*d Zd+d Zd,d Zd-d Zd.d  ZeeeZeeejZeeejZdId/d0Z d1d2 Z!dJd3dZ"dKd4dZ#dLd5d!Z$d6d Z%d7d	 Z&G d8d
 d
eZ'd9d Z(d:d Z)d;d Z*d<d Z+dMd>dZ,d?d@ Z-dNdAdZ.dBd Z/dCdD Z0ee0ejZ1dEd Z2ej3dFZ4dGdH Z5dS )Oz
Internationalization support.
    )unicode_literalsN)six)ContextDecorator)
force_text)lazyactivate
deactivateoverridedeactivate_allget_languageget_language_from_requestget_language_infoget_language_bidicheck_for_language	to_locale
templatizestring_concatgettextgettext_lazygettext_noopugettextugettext_lazyugettext_noopngettextngettext_lazy	ungettextungettext_lazypgettextpgettext_lazy	npgettextnpgettext_lazyLANGUAGE_SESSION_KEYZ	_languagec               @   s   e Zd ZdS )TranslatorCommentWarningN)__name__
__module____qualname__ r&   r&   E/tmp/pip-install-q3hcpn_q/Django/django/utils/translation/__init__.pyr"      s   r"   c               @   s   e Zd ZdZdd ZdS )Transa  
    The purpose of this class is to store the actual translation function upon
    receiving the first call to that function. After this is done, changes to
    USE_I18N will have no effect to which function is served upon request. If
    your tests rely on changing USE_I18N, you can delete all the functions
    from _trans.__dict__.

    Note that storing the function with setattr will have a noticeable
    performance effect, as access to the function goes the normal path,
    instead of using __getattr__.
    c             C   sH   ddl m} |jr ddlm} nddlm} t| |t|| t||S )Nr   )settings)
trans_real)
trans_null)Zdjango.confr)   ZUSE_I18NZdjango.utils.translationr*   r+   setattrgetattr)selfZ	real_namer)   Ztransr&   r&   r'   __getattr__7   s    zTrans.__getattr__N)r#   r$   r%   __doc__r/   r&   r&   r&   r'   r(   *   s   r(   c             C   s
   t j| S )N)_transr   )messager&   r&   r'   r   F   s    c             C   s
   t j| S )N)r1   r   )r2   r&   r&   r'   r   L   s    c             C   s   t j| ||S )N)r1   r   )singularpluralnumberr&   r&   r'   r   P   s    c             C   s
   t j| S )N)r1   r   )r2   r&   r&   r'   r   T   s    c             C   s   t j| ||S )N)r1   r   )r3   r4   r5   r&   r&   r'   r   X   s    c             C   s   t j| |S )N)r1   r   )contextr2   r&   r&   r'   r   \   s    c             C   s   t j| |||S )N)r1   r   )r6   r3   r4   r5   r&   r&   r'   r   `   s    c                sv   t tjr&d< tf }nLj G fddd t fdd f }fdd|_|S )Nr5   c                   s0   e Zd ZfddZdd Z fddZdS )z&lazy_number.<locals>.NumberAwareStringc                s   t  d S )Nr3   )bool)r.   )kwargsr&   r'   __bool__p   s    z/lazy_number.<locals>.NumberAwareString.__bool__c             S   s   t | j| S )N)typer9   )r.   r&   r&   r'   __nonzero__s   s    z2lazy_number.<locals>.NumberAwareString.__nonzero__c                sz   t |tr>r>y| }W qB tk
r:   td Y qBX n|}|d<  f }y|| }W n tk
rt   Y nX |S )Nz|Your dictionary lacks key '%s'. Please provide it, because it is required to determine whether string is singular or plural.r5   )
isinstancedictKeyError	TypeError)r.   rhsZnumber_valueZ
translated)funcr8   r5   r&   r'   __mod__v   s    
z.lazy_number.<locals>.NumberAwareString.__mod__N)r#   r$   r%   r9   r;   rB   r&   )rA   r8   r5   r&   r'   NumberAwareStringo   s   rC   c                 s     S )Nr&   )r8   )rC   r&   r'   <lambda>   s    zlazy_number.<locals>.<lambda>c                  s   t  ffS )N)_lazy_number_unpickler&   )rA   r5   original_kwargsresultclassr&   r'   rD      s    )r<   r   integer_typesr   copy
__reduce__)rA   rG   r5   r8   proxyr&   )rC   rA   r8   r5   rF   rG   r'   lazy_numberh   s    rL   c             C   s   t | |fd|i|S )Nr5   )rL   )rA   rG   r5   r8   r&   r&   r'   rE      s    rE   c             C   s   t tt| ||dS )N)r3   r4   r5   )rL   r   str)r3   r4   r5   r&   r&   r'   r      s    c             C   s   t ttj| ||dS )N)r3   r4   r5   )rL   r   r   	text_type)r3   r4   r5   r&   r&   r'   r      s    c             C   s   t ttj| |||dS )N)r6   r3   r4   r5   )rL   r   r   rN   )r6   r3   r4   r5   r&   r&   r'   r       s    c             C   s
   t j| S )N)r1   r   )languager&   r&   r'   r      s    c               C   s   t j S )N)r1   r   r&   r&   r&   r'   r      s    c               @   s&   e Zd Zd	ddZdd Zdd ZdS )
r	   Fc             C   s   || _ || _d S )N)rO   r   )r.   rO   r   r&   r&   r'   __init__   s    zoverride.__init__c             C   s(   t  | _| jd k	rt| j nt  d S )N)r   old_languagerO   r   r
   )r.   r&   r&   r'   	__enter__   s    
zoverride.__enter__c             C   s.   | j d krt  n| jr t  n
t| j  d S )N)rQ   r
   r   r   )r.   exc_type	exc_value	tracebackr&   r&   r'   __exit__   s
    
zoverride.__exit__N)F)r#   r$   r%   rP   rR   rV   r&   r&   r&   r'   r	      s   
c               C   s   t j S )N)r1   r   r&   r&   r&   r'   r      s    c               C   s   t j S )N)r1   r   r&   r&   r&   r'   r      s    c             C   s
   t j| S )N)r1   r   )	lang_coder&   r&   r'   r      s    c             C   s
   t j| S )N)r1   r   )rO   r&   r&   r'   r      s    Fc             C   s   t j| |S )N)r1   r   )request
check_pathr&   r&   r'   r      s    c             C   s
   t j| S )N)r1   get_language_from_path)pathr&   r&   r'   rZ      s    rZ   c             C   s   t j| |S )N)r1   r   )srcoriginr&   r&   r'   r      s    c               C   s   t j S )N)r1   r
   r&   r&   r&   r'   r
      s    c              G   s   dj dd | D S )zu
    Lazy variant of string concatenation, needed for translations that are
    constructed from multiple parts.
     c             s   s   | ]}t |V  qd S )N)r   ).0sr&   r&   r'   	<genexpr>   s    z!_string_concat.<locals>.<genexpr>)join)stringsr&   r&   r'   _string_concat   s    rd   c             C   s   ddl m} y2||  }d|kr8d|kr8t|d d }n|}W nh tk
r   d| krbtd|  | jdd }y|| }W n$ tk
r   td| |f Y nX Y nX |rt|d |d< |S )	Nr   )	LANG_INFOfallbackname-zUnknown language code %s.z Unknown language code %s and %s.Zname_translated)Zdjango.conf.localere   r   r>   splitr   )rW   re   Z	lang_infoinfoZgeneric_lang_coder&   r&   r'   r      s"    z\s*
\s*c             C   s   t jd| j S )N )trim_whitespace_resubstrip)r`   r&   r&   r'   trim_whitespace   s    ro   )N)N)N)N)F)N)6r0   
__future__r   reZdjango.utilsr   Zdjango.utils.decoratorsr   Zdjango.utils.encodingr   Zdjango.utils.functionalr   __all__r!   SyntaxWarningr"   objectr(   r1   r   r   r   r   r   r   r   r   rM   r   rN   r   r   rL   rE   r   r   r    r   r   r	   r   r   r   r   r   rZ   r   r
   rd   r   r   compilerl   ro   r&   r&   r&   r'   <module>   sl   

(





