I often run into the mistake of using gettext
in a context where the actual language is not set yet - instead of using the appropriate gettext_lazy
.
Those errors can be difficult to catch - I would like to make them more visible appropriate logging, or possibly even throwing exceptions.
- Would it be correct, to write a wrapper function that logs an error in the case of
get_language() is None
? - Then of course, one would need to enforce that this wrapper is always used - introducing another subtle easy to make mistake. In general, I suppose monkey-patching could be used, but I'd like to avoid that if possible. The whole dispatch behind
django.util.translation
seems already relatively complex. Is there a clean way too hook this functionality in there?
from Logging incorrect translations in Django
No comments:
Post a Comment