[openstack-dev] [oslo] i18n Message improvements

Luis A. Garcia luis at linux.vnet.ibm.com
Thu Oct 17 16:22:50 UTC 2013


On 10/16/2013 1:11 PM, Doug Hellmann wrote:
>
>[snip]
> Option 3 is closer to the new plan for Icehouse, which is to have _()
> return a Message, allow Message to work in a few contexts like a string
> (so that, for example, log calls and exceptions can be left alone, even
> if they use % to combine a translated string with arguments), but then
> have the logging and API code explicitly handle the translation of
> Message instances so we can always pass unicode objects outside of
> OpenStack code (to logging or to web frameworks). Since the logging code
> is part of Oslo and the API code can be, this seemed to provide
> isolation while removing most of the magic.
>

I think this is exactly what we have right now inherited form Havana. 
The _() returns a Message that is then translated on-demand by the API 
or in a special Translation log handler.

We just did not make Message look and feel enough like a str() and some 
outside components (jsonifier in Glance and log Formatter all over) did 
not know how to handle non text types correctly when non-ascii 
characters were present.

I think extending from unicode and removing all the implementations in 
place such that the unicode implementation kick in for all magic methods 
will solve the problems we saw at the end of Havana.

Thank you,

-- 
Luis A. García
Cloud Solutions & OpenStack Development
IBM Systems and Technology Group
Ph: (915) 307-6568 | T/L: 363-6276

"Everything should be made as simple as possible, but not simpler."
                                         - Albert Einstein

"Simple can be harder than complex: You have to work hard to get
your thinking clean to make it simple."
                                         – Steve Jobs




More information about the OpenStack-dev mailing list