Fixed localization and error reporting with exceptions thrown in celery

This commit is contained in:
Raphael Michel
2016-03-21 17:47:02 +01:00
parent 2d91319955
commit fde5fffd3c
4 changed files with 49 additions and 23 deletions

View File

@@ -342,3 +342,16 @@ def language(lng):
yield
finally:
translation.activate(_lng)
class LazyLocaleException(Exception):
def __init__(self, msg, msgargs=None):
self.msg = msg
self.msgargs = msgargs
super().__init__(msg, msgargs)
def __str__(self):
if self.msgargs:
return ugettext(self.msg) % self.msgargs
else:
return ugettext(self.msg)