translation.py 491 B

1234567891011121314151617181920
  1. from django.utils import translation
  2. def ugettext_lazy(string):
  3. """
  4. Custom wrapper that preserves untranslated message on lazy translation string object
  5. """
  6. t = translation.ugettext_lazy(string)
  7. t.message = string
  8. return t
  9. def get_msgid(gettext):
  10. """
  11. Function for extracting untranslated message from lazy translation string object
  12. made trough ugettext_lazy
  13. """
  14. try:
  15. return gettext.message
  16. except AttributeError:
  17. return None