
    Ri                       U d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ddlmZ erddlZddlmZmZ dd	l
mZ  e	ed
      Z G d d      Zi Zded<   	 	 d!	 	 	 	 	 	 	 	 	 d"dZ	 	 d#	 	 	 	 	 d$dZ	 d!	 	 	 	 	 d%dZ	 d!	 	 	 	 	 d&dZd'd(dZ ed      Z edd      Z ed       ed       ed       ed       ed       ed       ed       ed       ed       ed      d 
Zy))zLocale utilities.    )annotationsN)NullTranslationstranslation)Path)TYPE_CHECKING)package_dir)CallableIterable)Anylocalec                      e Zd ZdZdZddZddZddZddZddZ	ddZ
dd	Zdd
ZddZddZddZddZd dZd dZd!dZd"dZd#dZd$dZd!dZd%dZy)&_TranslationProxyzThe proxy implementation attempts to be as complete as possible, so that
    the lazy objects should mostly work as expected, for example for sorting.
    
_catalogue
_namespace_messagec                .    || _         || _        || _        y Nr   )self	catalogue	namespacemessages       N/home/agent/.friday_env/lib/python3.12/site-packages/sphinx/locale/__init__.py__init__z_TranslationProxy.__init__   s    ##    c                    	 t         | j                  | j                  f   j                  | j                        S # t
        $ r | j                  cY S w xY wr   )translatorsr   r   gettextr   KeyErrorr   s    r   __str__z_TranslationProxy.__str__!   sG    	!t?@HHWW 	!== 	!s   7: AAc                     t        t              S r   )dirstrr    s    r   __dir__z_TranslationProxy.__dir__(   s    3xr   c                6    t        | j                         |      S r   )getattrr!   )r   names     r   __getattr__z_TranslationProxy.__getattr__+   s    t||~t,,r   c                H    | j                   | j                  | j                  fS r   r   r    s    r   __getstate__z_TranslationProxy.__getstate__.   s    >>r   c                .    |\  | _         | _        | _        y r   r   )r   tups     r   __setstate__z_TranslationProxy.__setstate__1   s    :=7$-r   c                X    t        | j                  | j                  | j                        S r   )r   r   r   r   r    s    r   __copy__z_TranslationProxy.__copy__4   s     $//4==QQr   c           	         	 d| j                         S # t        $ rD | j                  j                  d| j                   d| j
                   d| j                   dz   cY S w xY w)Ni(z, ))r!   	Exception	__class____name__r   r   r   r    s    r   __repr__z_TranslationProxy.__repr__7   sh    	t||~()) 	''doo&b(9DMM?!LM	s    A
A"!A"c                (    | j                         |z   S r   r!   r   others     r   __add__z_TranslationProxy.__add__@       ||~%%r   c                (    || j                         z   S r   r:   r;   s     r   __radd__z_TranslationProxy.__radd__C       t||~%%r   c                (    | j                         |z  S r   r:   r;   s     r   __mod__z_TranslationProxy.__mod__F   r>   r   c                (    || j                         z  S r   r:   r;   s     r   __rmod__z_TranslationProxy.__rmod__I   rA   r   c                (    | j                         |z  S r   r:   r;   s     r   __mul__z_TranslationProxy.__mul__L   r>   r   c                (    || j                         z  S r   r:   r;   s     r   __rmul__z_TranslationProxy.__rmul__O   rA   r   c                4    t        | j                               S r   )hashr!   r    s    r   __hash__z_TranslationProxy.__hash__R   s    DLLN##r   c                (    | j                         |k(  S r   r:   r;   s     r   __eq__z_TranslationProxy.__eq__U   s    ||~&&r   c                (    | j                         |k  S r   r:   )r   strings     r   __lt__z_TranslationProxy.__lt__X   s    ||~&&r   c                &    || j                         v S r   r:   )r   chars     r   __contains__z_TranslationProxy.__contains__[   s    t||~%%r   c                4    t        | j                               S r   )lenr!   r    s    r   __len__z_TranslationProxy.__len__^   s    4<<>""r   c                (    | j                         |   S r   r:   )r   indexs     r   __getitem__z_TranslationProxy.__getitem__a   s    ||~e$$r   N)r   r$   r   r$   r   r$   returnNone)r[   r$   )r[   z	list[str])r(   r$   r[   r   )r[   tuple[str, str, str])r-   r]   r[   r\   )r[   r   )r<   r$   r[   r$   )r<   r   r[   r$   )r[   int)r<   objectr[   bool)rP   r$   r[   r`   )rS   r$   r[   r`   )rY   zint | slicer[   r$   )r7   
__module____qualname____doc__	__slots__r   r!   r%   r)   r+   r.   r0   r8   r=   r@   rC   rE   rG   rI   rL   rN   rQ   rT   rW   rZ    r   r   r   r      ss     7I 
!-?>R&&&&&&$''&#%r   r   z'dict[tuple[str, str], NullTranslations]r   sphinxc                   t         j                  ||f      }|j                  t        u rd}|r|g}nd}| D ]'  }	 t	        |||      }||}n|j                  |       ) |d}nt               }d}|t         ||f<   ||fS # t        $ r Y Uw xY w)a  Look for message catalogs in `locale_dirs` and *ensure* that there is at
    least a NullTranslations catalog set in `translators`. If called multiple
    times or if several ``.mo`` files are found, their contents are merged
    together (thus making ``init`` reentrant).
    N)	localedir	languagesTF)r   getr6   r   r   add_fallbackr5   )	locale_dirslanguagecatalogr   
translatorri   dir_transhas_translations	            r   initrs   h   s     )W!56J//
'/j		  		49ME!"
''.	 %'
&0K	7"#&&  		s   $B  	BBc                    | t         } t        j                  dk(  rd}n'	 t        j                  t        j
                        \  }}t        | g||d      S # t        $ r d}Y w xY w)z>Initialize locale for console.

    .. versionadded:: 1.8
    Nwin32console)_LOCALE_DIRsysplatformr   	getlocaleLC_MESSAGESAttributeErrorrs   )
locale_dirrn   rm   _s       r   init_consoler      sj      

||w	 **6+=+=>KHa h;;  	H	s   &A A#"A#c                B    t         j                  || ft                     S r   )r   rj   r   rn   r   s     r   get_translatorr      s     ??Iw/1A1CDDr   c                    || ft         v S r   )r   r   s     r   is_translator_registeredr      s     w;..r   c                     d fd}|S )a8  Get a translation function based on the *catalog* and *namespace*.

    The extension can use this API to translate the messages on the
    extension::

        from pathlib import Path
        from sphinx.locale import get_translation

        MESSAGE_CATALOG_NAME = 'myextension'  # name of *.pot, *.po and *.mo files
        _ = get_translation(MESSAGE_CATALOG_NAME)
        text = _('Hello Sphinx!')


        def setup(app):
            package_dir = Path(__file__).resolve().parent
            locale_dir = package_dir / 'locales'
            app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir)

    With this code, sphinx searches a message catalog from
    ``${package_dir}/locales/${language}/LC_MESSAGES/myextension.mo``.
    The :confval:`language` is used for the searching.

    .. versionadded:: 1.8
    c                p    t              st        |       S t              }|j                  |       S r   )r   r   r   r   )r   ro   rn   r   s     r   r   z get_translation.<locals>.gettext   s9    ';$WiAA';J%%g..r   )r   r$   r[   r$   re   )rn   r   r   s   `` r   get_translationr      s    4/ Nr   rv   	AttentionCautionDangerErrorHint	ImportantNotezSee alsoTipWarning)
	attentioncautiondangererrorhint	importantnoteseealsotipwarning)rf   general)
rl   z'Iterable[str | os.PathLike[str] | None]rm   z
str | Nonern   r$   r   r$   r[   tuple[NullTranslations, bool])Nrf   )r}   zstr | os.PathLike[str] | Nonern   r$   r[   r   )rn   r$   r   r$   r[   r   )rn   r$   r   r$   r[   r`   )r   )rn   r$   r   r$   r[   zCallable[[str], str])rc   
__future__r   r   rx   r   r   r   pathlibr   typingr   rf   r   oscollections.abcr	   r
   r   rw   r   r   __annotations__rs   r   r   r   r   r~   __admonitionlabelsre   r   r   <module>r      sj    "  
 1    2;)M% M%` 8:4 9 	('8('(' (' 	('
 #('X 15<-<< #<. /8EE(+EE /8//(+/	/"P H Xy)
 ;|kwZfI;fI}U8| r   