Question

I am writing a method to my class and I like internationalize my projects. Now I'm developing a really multilingual system. I want to translate documentation.
About how to translate new line after the definition of the method is nothing in the django documentation.
I'm try write:

from django.utils.translation import ugettext_lazy as _
class Items(Model):
    ...
    ...
    def total(self):
        _(""" Method: Count total order price""")
        return self.__total

but in the admin-doc has no effect.

Was it helpful?

Solution

If you specifiy __doc__ attribute as first statement, it should be literal and not expression.

I think this could work:

from django.utils.translation import ugettext_lazy as _
class Items(Model):
    __doc__ = _('translatable description for Items')

    def total(self):
        return self.__total
    total.__doc__ = _(""" Method: Count total order price""")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top