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 _()?

John Dennis <jden...@redhat.com>

Looking to carve out IT costs?

Freeipa-devel mailing list

Reply via email to