human
Solve the following python programming problem given the following code:
@contextmanager
def respect_language(language):
assistant
#Here is the Python program you requested.

    """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
    """
    if language:
        prev = translation.get_language()
        translation.activate(language)
        try:
            (yield)
        finally:
            translation.activate(prev)
    else:
        (yield)