<html><body>
<p><font size="1" color="#535353" face="Lucida Console">>And I guess all the user-visible message was exception message in REST API<br>
>So as example, the code probably looks like:<br>
>in Controller:<br>
>def index(self, req):<br>
> try:<br>
> res = self._get_(resources)(...)<br>
> except Exception as e:<br>
> LOG.exception(e.message)<br>
> user_locale = get_user_locale_from_request(req)<br>
> t = gettext.tranlsation('xxx-usermsg', languages=user_locale)<br>
> res = {'Error': t.ugettext(e.message.orignal)}<br>
> return res<br>
><br>
>The exception message can log at server side:<br>
>LOG.exception(e.message)<br>
><br>
>And the exception message also can return to user as user-visible <br>
>message too:<br>
>t = gettext.tranlsation('xxx-usermsg', languages=user_locale)<br>
> res = {'Error': t.ugettext(e.message.orignal)}<br>
><br>
>We can wrapper the user-visible message by 'L_()'. And 'L_' should be an <br>
>object. It can return<br>
>server side translation and also can return orignal message that need be <br>
>translated as user request.</font><br>
<br>
<font size="2" face="sans-serif">I have actually been looking into the same issues here independently I guess. My solution is roughly the same as the one mentioned above. i.e. override _() (or L_()) to return a message object with __mod__() overriden as well to save the original message and parameters until it needs to be serialized to a string on write out. Then the message can be localized at print time.</font><br>
<br>
<font size="2" face="sans-serif">I am not sure if this is the best solution however, as the consequence is dealing with python objects instead of strings, which might have issues when passed through AMQP and such.</font><br>
<br>
<font size="2" face="sans-serif">Blueprint I was working on drafting is here:</font><br>
<br>
<font size="2" face="sans-serif"><a href="https://blueprints.launchpad.net/nova/+spec/user-locale-api">https://blueprints.launchpad.net/nova/+spec/user-locale-api</a></font><br>
<br>
<font size="2" face="sans-serif">Mathew Odden, Software Engineer <br>
IBM STG Emerging Solutions Development <br>
mrodden@us.ibm.com</font></body></html>