@contextmanager
def uselocale(locale):
 currlocale = translation.get_language()
 translation.activate(locale)
 (yield)
 translation.activate(currlocale)

@ contextmanager def uselocale ( locale ) : currlocale = translation . get_language ( ) translation . activate ( locale ) ( yield ) translation . activate ( currlocale )
context manager for setting locale and returning to previous locale .