B
    `/
                 @   s,   d dl Z d dlmZ G dd de jeZdS )    N)PY3c               @   sN   e Zd ZdZdZdefddZddefddZeeZdd	 Zd
d Z	dZ
dS )Translationsz&An extended translation catalog class.messagesNc             C   sF   t jj| |d tdt|ddg| _|| _i | _|dk	rB|  dS )zInitialize the translations catalog.

        :param fileobj: the file-like object the translation should be read
                        from
        )fpNname)	gettextGNUTranslations__init__filtergetattrfilesdomain_domainsclose)selffileobjr    r   l/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/translationstring/tests/translations.pyr	   	   s    zTranslations.__init__c             C   s:   |dk	rdd |D }t |||}t|d}| ||dS )a  Load translations from the given directory.

        :param dirname: the directory containing the ``MO`` files
        :param locales: the list of locales in order of preference (items in
                        this list can be either `Locale` objects or locale
                        strings)
        :param domain: the message domain
        :return: the loaded catalog, or a ``NullTranslations`` instance if no
                 matching translations were found
        :rtype: `Translations`
        Nc             S   s   g | ]}t |qS r   )str).0localer   r   r   
<listcomp>#   s    z%Translations.load.<locals>.<listcomp>rb)r   r   )r   findopen)clsdirnameZlocalesr   filenamer   r   r   r   load   s
    
zTranslations.loadc             C   s0   t r| j|| |S | j|| |S dS )zVLike ``ugettext()``, but look the message up in the specified
        domain.
        N)r   r   getr   Zugettext)r   r   messager   r   r   	dugettext)   s    zTranslations.dugettextc             C   s8   t r| j|| |||S | j|| |||S dS )zVLike ``ungettext()`` but look the message up in the specified
        domain.
        N)r   r   r   ngettextZ	ungettext)r   r   Zsingularpluralnumr   r   r   
dungettext2   s
    
zTranslations.dungettextz%s%s)__name__
__module____qualname____doc__ZDEFAULT_DOMAINr	   r   classmethodr!   r%   ZCONTEXT_ENCODINGr   r   r   r   r      s   	r   )r   Ztranslationstring.compatr   r   objectr   r   r   r   r   <module>   s   