diff --git a/bin/heat-api b/bin/heat-api index 721d9f189c..1c8bf74d73 100755 --- a/bin/heat-api +++ b/bin/heat-api @@ -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') diff --git a/bin/heat-api-cfn b/bin/heat-api-cfn index abc1b38542..c8876714f1 100755 --- a/bin/heat-api-cfn +++ b/bin/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.cfn') diff --git a/bin/heat-api-cloudwatch b/bin/heat-api-cloudwatch index 4d71609140..055bd9253a 100755 --- a/bin/heat-api-cloudwatch +++ b/bin/heat-api-cloudwatch @@ -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') diff --git a/bin/heat-engine b/bin/heat-engine index f20276c18c..6360c817ac 100755 --- a/bin/heat-engine +++ b/bin/heat-engine @@ -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') diff --git a/heat/api/middleware/fault.py b/heat/api/middleware/fault.py index 76820e92e7..f10b66ce6f 100644 --- a/heat/api/middleware/fault.py +++ b/heat/api/middleware/fault.py @@ -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 diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 11932cf0d3..a29784ea45 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -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