a
    Šxd  ã                   @  s   U d Z ddlmZ ddlZddlZddlmZ g d¢Z	de 
¡ iZded< eƒ Zdd	ddd
œZddddœZddœdd„Zddœdd„Zd/ddddœdd„Zddœdd„Zdddœdd„Zddddœdd „Zddd!dd"œd#d$„Zdddœd%d&„Zddd'd(œd)d*„Zddœd+d,„Zddœd-d.„ZdS )0z*Activate, get and deactivate translations.é    )ÚannotationsN)Úlocal)ÚactivateÚ
deactivateÚdecimal_separatorÚthousands_separatorz1dict[str | None, gettext_module.NullTranslations]Ú_TRANSLATIONSÚ.ú )Úde_DEÚfr_FRÚit_ITÚpt_BRú,)r   r   r   z
str | None)Úreturnc                   C  s@   z&t d u rW d S tj tj t ¡d¡W S  ty:   Y d S 0 d S )NÚlocale)Ú__file__ÚosÚpathÚjoinÚdirnameÚ	NameError© r   r   úE/var/www/html/Ranjet/env/lib/python3.9/site-packages/humanize/i18n.pyÚ_get_default_locale_path    s    r   zgettext_module.NullTranslationsc                	   C  s0   zt tj W S  ttfy*   t d   Y S 0 d S )N)r   Ú_CURRENTr   ÚAttributeErrorÚKeyErrorr   r   r   r   Úget_translation)   s    r   Ústr)r   r   r   c                 C  sP   |du rt ƒ }|du r"d}t|ƒ‚| tvrBt 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   Úmsgr"   r   r   r   r   0   s    ÿr   ÚNonec                   C  s
   dt _dS )z Deactivate internationalisation.N)r   r   r   r   r   r   r   O   s    r   )Úmessager   c                 C  s   t ƒ  | ¡S )zvGet translation.

    Args:
        message (str): Text to translate.

    Returns:
        str: Translated text.
    )r   Úgettext©r%   r   r   r   Ú_gettextT   s    	r(   )Úmsgctxtr%   r   c                 C  sP   zt ƒ  | |¡W S  tyJ   | d | }t ƒ  |¡}||krB|n| Y S 0 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&   )r)   r%   Úkeyr"   r   r   r   Ú	_pgettext`   s    r-   Úint)r%   ÚpluralÚnumr   c                 C  s   t ƒ  | ||¡S )a6  Plural version of _gettext.

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

    Returns:
        str: Translated text.
    )r   Úngettext)r%   r/   r0   r   r   r   Ú	_ngettexty   s    r2   c                 C  s   | S )aa  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_noopˆ   s    r3   ztuple[str, str])Úsingularr/   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   )r4   r/   r   r   r   Ú_ngettext_noop›   s    r5   c               	   C  s.   zt tj } W n ttfy(   d} Y n0 | S )ztReturn the thousands separator for a locale, default to comma.

    Returns:
         str: Thousands separator.
    r   )Ú_THOUSANDS_SEPARATORr   r   r   r   ©Úsepr   r   r   r   ¯   s
    
r   c               	   C  s.   zt tj } W n ttfy(   d} Y n0 | S )znReturn the decimal separator for a locale, default to dot.

    Returns:
         str: Decimal separator.
    r	   )Ú_DECIMAL_SEPARATORr   r   r   r   r7   r   r   r   r   ¼   s
    
r   )N)Ú__doc__Ú
__future__r   r&   r!   Úos.pathr   Ú	threadingr   Ú__all__ÚNullTranslationsr   Ú__annotations__r   r6   r9   r   r   r   r   r(   r-   r2   r3   r5   r   r   r   r   r   r   Ú<module>   s8   ÿü	ý	