Merge "Re-enable lazy translation"
This commit is contained in:
commit
1864efa320
|
@ -33,7 +33,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
|
||||||
|
|
||||||
from heat.openstack.common import gettextutils
|
from heat.openstack.common import gettextutils
|
||||||
|
|
||||||
gettextutils.install('heat', lazy=False)
|
gettextutils.enable_lazy()
|
||||||
|
gettextutils.install('heat', lazy=True)
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
|
||||||
|
|
||||||
from heat.openstack.common import gettextutils
|
from heat.openstack.common import gettextutils
|
||||||
|
|
||||||
gettextutils.install('heat', lazy=False)
|
gettextutils.enable_lazy()
|
||||||
|
gettextutils.install('heat', lazy=True)
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
|
||||||
|
|
||||||
from heat.openstack.common import gettextutils
|
from heat.openstack.common import gettextutils
|
||||||
|
|
||||||
gettextutils.install('heat', lazy=False)
|
gettextutils.enable_lazy()
|
||||||
|
gettextutils.install('heat', lazy=True)
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
|
||||||
|
|
||||||
from heat.openstack.common import gettextutils
|
from heat.openstack.common import gettextutils
|
||||||
|
|
||||||
gettextutils.install('heat', lazy=False)
|
gettextutils.enable_lazy()
|
||||||
|
gettextutils.install('heat', lazy=True)
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
|
@ -119,11 +119,14 @@ class HeatException(Exception):
|
||||||
raise exc_info[0], exc_info[1], exc_info[2]
|
raise exc_info[0], exc_info[1], exc_info[2]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.message)
|
return unicode(self.message).encode('UTF-8')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(self.message)
|
return unicode(self.message)
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
return self.__class__(**self.kwargs)
|
||||||
|
|
||||||
|
|
||||||
class MissingCredentialError(HeatException):
|
class MissingCredentialError(HeatException):
|
||||||
msg_fmt = _("Missing required credential: %(required)s")
|
msg_fmt = _("Missing required credential: %(required)s")
|
||||||
|
|
|
@ -758,7 +758,7 @@ def log_exception(err, exc_info):
|
||||||
|
|
||||||
def translate_exception(exc, locale):
|
def translate_exception(exc, locale):
|
||||||
"""Translates all translatable elements of the given exception."""
|
"""Translates all translatable elements of the given exception."""
|
||||||
exc.message = gettextutils.translate(str(exc), locale)
|
exc.message = gettextutils.translate(unicode(exc), locale)
|
||||||
if isinstance(exc, webob.exc.HTTPError):
|
if isinstance(exc, webob.exc.HTTPError):
|
||||||
# If the explanation is not a Message, that means that the
|
# If the explanation is not a Message, that means that the
|
||||||
# explanation is the default, generic and not translatable explanation
|
# explanation is the default, generic and not translatable explanation
|
||||||
|
@ -767,7 +767,7 @@ def translate_exception(exc, locale):
|
||||||
# message, since message is what gets passed in at construction time
|
# message, since message is what gets passed in at construction time
|
||||||
# in the API
|
# in the API
|
||||||
if not isinstance(exc.explanation, gettextutils.Message):
|
if not isinstance(exc.explanation, gettextutils.Message):
|
||||||
exc.explanation = str(exc)
|
exc.explanation = unicode(exc)
|
||||||
exc.detail = ''
|
exc.detail = ''
|
||||||
else:
|
else:
|
||||||
exc.explanation = \
|
exc.explanation = \
|
||||||
|
|
Loading…
Reference in New Issue