Merge "Re-enable lazy translation"

This commit is contained in:
Jenkins 2014-02-17 17:58:58 +00:00 committed by Gerrit Code Review
commit 1864efa320
6 changed files with 14 additions and 7 deletions

View File

@ -33,7 +33,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
from heat.openstack.common import gettextutils
gettextutils.install('heat', lazy=False)
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
from oslo.config import cfg

View File

@ -35,7 +35,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
from heat.openstack.common import gettextutils
gettextutils.install('heat', lazy=False)
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
from oslo.config import cfg

View File

@ -35,7 +35,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
from heat.openstack.common import gettextutils
gettextutils.install('heat', lazy=False)
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
from oslo.config import cfg

View File

@ -36,7 +36,8 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
from heat.openstack.common import gettextutils
gettextutils.install('heat', lazy=False)
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
from oslo.config import cfg

View File

@ -119,11 +119,14 @@ class HeatException(Exception):
raise exc_info[0], exc_info[1], exc_info[2]
def __str__(self):
return str(self.message)
return unicode(self.message).encode('UTF-8')
def __unicode__(self):
return unicode(self.message)
def __deepcopy__(self, memo):
return self.__class__(**self.kwargs)
class MissingCredentialError(HeatException):
msg_fmt = _("Missing required credential: %(required)s")

View File

@ -758,7 +758,7 @@ def log_exception(err, exc_info):
def translate_exception(exc, locale):
"""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 the explanation is not a Message, that means that the
# 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
# in the API
if not isinstance(exc.explanation, gettextutils.Message):
exc.explanation = str(exc)
exc.explanation = unicode(exc)
exc.detail = ''
else:
exc.explanation = \