[Freeipa-devel] localized strings

Dmitri Pal dpal at redhat.com
Wed Nov 11 17:03:17 UTC 2009


John Dennis wrote:
> I was writing some new code and wanted to return an error message.
> Error messages need to be localized. Typically this is done via the
> _() method. But _() has to be defined and there are several ways that
> can happen. So I went looking for existing usage in our code base. I
> was surprised at how little I found which makes me wonder if I'm not
> understanding how we're handling messages. errors.py does define _()
> which makes sense, but a lot of the usage of the error classes in
> errors.py involves providing a customized error detail message,
> usually via the 'reason' keyword, for example:
>
> raise errors.NotFound(reason="Group '%s' does not exist" % kw['group'])
>
> but it seems to me this should be:
>
> raise errors.NotFound(reason=_("Group '%s' does not exist") %
> kw['group'])
>
>
> Virtually all of the examples I found of returning a detailed error
> message omitted the _() localization method. Why? Am I missing
> something about how we're supposed to be coding this? This also raised
> the question in my mind about how we're binding _(), the only example
> I could find was this:
>
> from request import ugettext as _
>
> Is this what all the modules are supposed to be doing to bind _()?
>
>
Jason, Pavel, Rob we talked about this many months ago and agreed that
we will be writing "translation ready code".
I think we need to clean it up. I will add a task to the iteration to
clean this up.
Pavel I suspect it will fall on your shoulders. Ok?
 

-- 
Thank you,
Dmitri Pal

Engineering Manager IPA project,
Red Hat Inc.


-------------------------------
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/




More information about the Freeipa-devel mailing list