o
    MhúR_  ã                   @   sL   d dl mZmZ d dlmZ d dlmZ d dlmZ edd„ ƒZ	dd„ Z
d	S )
é    )Úabsolute_importÚunicode_literals)Úcontextmanager©Úwraps)Útranslationc              	   c   sF   � | rt  ¡ }t  | ¡ zdV  W t  |¡ dS t  |¡ w dV  dS )ai  Context manager that changes the current translation language for
    all code inside the following block.

    Can e.g. be used inside tasks like this::

        from celery import task
        from djcelery.common import respect_language

        @task
        def my_task(language=None):
            with respect_language(language):
                pass
    N)r   Úget_languageÚactivate)ÚlanguageÚprev© r   úA/var/www/html/env/lib/python3.10/site-packages/djcelery/common.pyÚrespect_language	   s   €

r   c                    s   t ˆ ƒ‡ fdd„ƒ}|S )at  Decorator for tasks with respect to site's current language.
    You can use this decorator on your tasks together with default @task
    decorator (remember that the task decorator must be applied last).

    See also the with-statement alternative :func:`respect_language`.

    **Example**:

    .. code-block:: python

        @task
        @respects_language
        def my_task()
            # localize something.

    The task will then accept a ``language`` argument that will be
    used to set the language in the task, and the task can thus be
    called like:

    .. code-block:: python

        from django.utils import translation
        from myapp.tasks import my_task

        # Pass the current language on to the task
        my_task.delay(language=translation.get_language())

        # or set the language explicitly
        my_task.delay(language='no.no')

    c                     sB   t | dd ¡ƒ� ˆ | i |¤ŽW  d   ƒ S 1 sw   Y  d S )Nr
   )r   Úpop)ÚargsÚkwargs©Úfunr   r   Ú_innerD   s   $ÿz!respects_language.<locals>._innerr   )r   r   r   r   r   Úrespects_language#   s   !r   N)Ú
__future__r   r   Ú
contextlibr   Ú	functoolsr   Údjango.utilsr   r   r   r   r   r   r   Ú<module>   s    
