When extracting body of a document in HTML source format (i.e. without pandoc conversion before display), use BeautifilSoup, which is more tolerant, instead of xml.dom.minidom, which crashes too often.
from django.utils.translation.trans_real import translation
def translate_to(value, language_code):
t = translation(language_code)
return getattr(t, 'gettext')(value)