Search code examples
pythondjangoreportlab

ugettext_lazy doesn't work with reportlab's Table


When I try to use ugettext_lazy with reportlab's Table class, instead of displaying the default text when there is no translation, the output displays django.utils.functional.__proxy__ object at 0xb54921ec For example,

import ugettext_lazy as _

heading = (_('Service'), _('Price'), _('Note'))
table = Table([heading])

And the output is as described above. Has anyone encoutered this situation?


Solution

  • The code may rely on objects being actual strings and not lazy objects. Try to use regular ugettext. In this case strings will be translated before passing into reportlab

    from django.utils.translation import ugettext as _
    
    heading = (_('Service'), _('Price'), _('Note'))
    table = Table([heading])