Access untranslated string of Django

Django provides a powerful mean to extract and translate string in our projects. Click here for more details.

Sometimes I like to use a key to reference messages, for example:

UNREAD_MESSAGE = _('unread_message')

unread_message is a key that will generate the translate pattern in the PO file, as shown bellow:

#: notification/
msgid "unread_message"
msgstr "Hy {user} you have messages unread."

If you need to access an untranslated string to do anything you need to read the first element in the tuple _proxy____args, see:

if hasattr(verb, '_proxy____args'):
    verb = verb._proxy____args[0]

The variable verb consists in a type of django.utils.functional.__proxy__, an object that is a lazy translation and it is a reference to UNREAD_MESSAGE.

You can test running this code: UNREAD_MESSAGE._proxy____args[0].

See you.