<s> from __future__ import absolute_import , unicode_literals <EOL> from contextlib import contextmanager <EOL> from functools import wraps <EOL> from django . utils import translation <EOL> @ contextmanager <EOL> def respect_language ( language ) : <EOL> """<STR_LIT>""" <EOL> if language : <EOL> prev = translation . get_language ( ) <EOL> translation . activate ( language ) <EOL> try : <EOL> yield <EOL> finally : <EOL> translation . activate ( prev ) <EOL> else : <EOL> yield <EOL> def respects_language ( fun ) : <EOL> """<STR_LIT>""" <EOL> @ wraps ( fun ) <EOL> def _inner ( * args , ** kwargs ) : <EOL> with respect_language ( kwargs . pop ( '<STR_LIT>' , None ) ) : <EOL> return fun ( * args , ** kwargs ) <EOL> return _inner </s>
