Re-enable lazy translation
After enhancements to Oslo Message class, re-enable lazy translation to enable REST API responses to be translated to the requested user locale. bp i18n-messages Change-Id: I4be508858547029d454412746609fd380af415c1
This commit is contained in:
parent
3407a698bd
commit
f864a0c84a
@ -38,7 +38,8 @@ from heat.common import wsgi
|
||||
from heat.openstack.common import gettextutils
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
gettextutils.install('heat', lazy=False)
|
||||
gettextutils.enable_lazy()
|
||||
gettextutils.install('heat', lazy=True)
|
||||
|
||||
LOG = logging.getLogger('heat.api')
|
||||
|
||||
|
@ -40,7 +40,8 @@ from heat.common import wsgi
|
||||
from heat.openstack.common import gettextutils
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
gettextutils.install('heat', lazy=False)
|
||||
gettextutils.enable_lazy()
|
||||
gettextutils.install('heat', lazy=True)
|
||||
|
||||
LOG = logging.getLogger('heat.api.cfn')
|
||||
|
||||
|
@ -40,7 +40,8 @@ from heat.common import wsgi
|
||||
from heat.openstack.common import gettextutils
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
gettextutils.install('heat', lazy=False)
|
||||
gettextutils.enable_lazy()
|
||||
gettextutils.install('heat', lazy=True)
|
||||
|
||||
LOG = logging.getLogger('heat.api.cloudwatch')
|
||||
|
||||
|
@ -32,7 +32,6 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
|
||||
sys.path.insert(0, POSSIBLE_TOPDIR)
|
||||
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from heat.common import notify
|
||||
@ -41,7 +40,8 @@ from heat.openstack.common import log as logging
|
||||
from heat.openstack.common import service
|
||||
from heat.rpc import api as rpc_api
|
||||
|
||||
gettextutils.install('heat', lazy=False)
|
||||
gettextutils.enable_lazy()
|
||||
gettextutils.install('heat', lazy=True)
|
||||
|
||||
LOG = logging.getLogger('heat.engine')
|
||||
|
||||
|
@ -118,6 +118,9 @@ class FaultWrapper(wsgi.Middleware):
|
||||
msg_trace = traceback.format_exc()
|
||||
message = full_message
|
||||
|
||||
if isinstance(ex, exception.HeatException):
|
||||
message = ex.message
|
||||
|
||||
if cfg.CONF.debug and not trace:
|
||||
trace = msg_trace
|
||||
|
||||
|
@ -719,7 +719,11 @@ def log_exception(err, exc_info):
|
||||
|
||||
def translate_exception(exc, locale):
|
||||
"""Translates all translatable elements of the given exception."""
|
||||
exc.message = gettextutils.translate(six.text_type(exc), locale)
|
||||
if isinstance(exc, exception.HeatException):
|
||||
exc.message = gettextutils.translate(exc.message, locale)
|
||||
else:
|
||||
exc.message = gettextutils.translate(six.text_type(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
|
||||
|
Loading…
Reference in New Issue
Block a user