1
From 40fa30fd741968a182e21f98d70ec256e542d49a Mon Sep 17 00:00:00 2001
2
From: Doug Hellmann <doug@doughellmann.com>
3
Date: Tue, 6 Jan 2015 10:56:10 -0500
4
Subject: [PATCH] Do not use private classes from oslo.i18n
6
Use oslo.i18n.translate() without first testing if the argument being
7
passed is a Message instance. The Message class is meant to be hidden
8
from consumers, and translate() correctly detects untranslatable strings
9
and returns them as given.
11
Change-Id: I6e907adf16d8cf6fbbcf526632c91ca81611ea09
13
heat/common/wsgi.py | 15 ++-------------
14
1 file changed, 2 insertions(+), 13 deletions(-)
16
diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py
17
index 86d6166..28608ec 100644
18
--- a/heat/common/wsgi.py
19
+++ b/heat/common/wsgi.py
20
@@ -744,19 +744,8 @@ def translate_exception(exc, locale):
21
exc.message = i18n.translate(six.text_type(exc), locale)
23
if isinstance(exc, webob.exc.HTTPError):
24
- # If the explanation is not a Message, that means that the
25
- # explanation is the default, generic and not translatable explanation
26
- # from webop.exc. Since the explanation is the error shown when the
27
- # exception is converted to a response, let's actually swap it with
28
- # message, since message is what gets passed in at construction time
30
- if not isinstance(exc.explanation, i18n._message.Message):
31
- exc.explanation = six.text_type(exc)
35
- i18n.translate(exc.explanation, locale)
36
- exc.detail = i18n.translate(exc.detail, locale)
37
+ exc.explanation = i18n.translate(exc.explanation, locale)
38
+ exc.detail = i18n.translate(getattr(exc, 'detail', ''), locale)