14
I'm looking for a sane way to get to the untranslated content of a ugettext_lazyied string. I found two ways, but I'm not happy with either one:
the_string = ugettext_lazy('the content')
the_content = the_string._proxy____args[0] # ewww!
or
from django.utils.translation import activate, get_language
from django.utils.encoding import force_unicode
the_string = ugettext_lazy('the content')
current_lang = get_language()
activate('en')
the_content = force_unicode(the_string)
activate(current_lang)
The first piece of code accesses an attribute that has been explicitly marked as private, so there is no telling how long this code will work. The second solution is overly verbose and slow.
Of course, in the actual code, the definition of the ugettext_lazyied string and the code that accesses it are miles appart.