
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
U
    su]a                     @   s   d Z ddlZddlZddlmZ dddddgZde iZ	e Z
d	d
iZdd Zdd ZdddZdd Zdd Zdd Zdd Zdd Zdd ZedddZdS )z*Activate, get and deactivate translations.    N)localactivate
deactivategettextngettextthousands_separatorfr_FR c                   C   sB   z&t d krW d S tjtjt dW S  tk
r<   Y d S X d S )Nlocale)__file__ospathjoindirname	NameError r   r   >/opt/alt/python38/lib/python3.8/site-packages/humanize/i18n.py_get_default_locale_path   s    r   c                	   C   s2   zt tj W S  ttfk
r,   t d   Y S X d S )N)_TRANSLATIONS_CURRENTr
   AttributeErrorKeyErrorr   r   r   r   get_translation   s    r   c                 C   sL   |dkrt  }|dkrtd| tkr>td|| g}|t| < | t_t|  S )aR  Activate internationalisation.

    Set `locale` as current locale. Search for locale in directory `path`.

    Args:
        locale (str): Language name, e.g. `en_GB`.
        path (str): Path to search for locales.

    Returns:
        dict: Translations.

    Raises:
        Exception: If humanize cannot find the locale folder.
    NznHumanize cannot determinate the default location of the 'locale' folder. You need to pass the path explicitly.Zhumanize)r   	Exceptionr   gettext_moduletranslationr   r
   )r
   r   r   r   r   r   r   "   s    c                   C   s
   dt _dS )z Deactivate internationalisation.N)r   r
   r   r   r   r   r   @   s    c                 C   s   t  | S )zvGet translation.

    Args:
        message (str): Text to translate.

    Returns:
        str: Translated text.
    )r   r   messager   r   r   r   E   s    	c                 C   sR   zt  | |W S  tk
rL   | d | }t  |}||krD|n| Y S X dS )a   Fetches a particular translation.

    It works with `msgctxt` .po modifiers and allows duplicate keys with different
    translations.

    Args:
        msgctxt (str): Context of the translation.
        message (str): Text to translate.

    Returns:
        str: Translated text.
    N)r   pgettextr   r   )Zmsgctxtr   keyr   r   r   r   r   Q   s    r   c                 C   s   t  | ||S )a5  Plural version of gettext.

    Args:
        message (str): Singular text to translate.
        plural (str): Plural text to translate.
        num (str): The number (e.g. item count) to determine translation for the
            respective grammatical number.

    Returns:
        str: Translated text.
    )r   r   )r   pluralnumr   r   r   r   j   s    c                 C   s   | S )a^  Mark a string as a translation string without translating it.

    Example usage:
    ```python
    CONSTANTS = [gettext_noop('first'), gettext_noop('second')]
    def num_name(n):
        return gettext(CONSTANTS[n])
    ```

    Args:
        message (str): Text to translate in the future.

    Returns:
        str: Original text, unchanged.
    r   r   r   r   r   gettext_noopy   s    r#   c                 C   s   | |fS )a  Mark two strings as pluralized translations without translating them.

    Example usage:
    ```python
    CONSTANTS = [ngettext_noop('first', 'firsts'), ngettext_noop('second', 'seconds')]
    def num_name(n):
        return ngettext(*CONSTANTS[n])
    ```

    Args:
        singular (str): Singular text to translate in the future.
        plural (str): Plural text to translate in the future.

    Returns:
        tuple: Original text, unchanged.
    r   )Zsingularr!   r   r   r   ngettext_noop   s    r$   )returnc               	   C   s0   zt tj } W n ttfk
r*   d} Y nX | S )ztReturn the thousands separator for a locale, default to comma.

    Returns:
         str: Thousands separator.
    ,)_THOUSANDS_SEPARATORr   r
   r   r   )sepr   r   r   r      s
    
)N)__doc__r   r   os.pathr   	threadingr   __all__NullTranslationsr   r   r'   r   r   r   r   r   r   r#   r$   strr   r   r   r   r   <module>   s&    	
