I'm doing a localization of a Django app.
The front-end website works fine and the Django admin site picks up the selected language as well.
But it only applies the language settings in some places and uses the default English versions of field and column names, even though these have been translated. Why? How can I make it use the translated names for column and field names in the admin interface?
Example:
class Order(models.Model):
OPTIONS = ( (0, _("Bank transfer") ), (1, _("Cash on delivery") ), )
user = models.ForeignKey(User, name=_("User") )
payment = models.IntegerField(choices=self.OPTIONS, name=_("Payment"))
For which I get:
I'm using Django 1.0.2. The texts that are not getting translated did appear in the locale files along with those that work.
Sub-question: is it possible to localize the app names?
gettext_lazy() In definitions like forms or models you should use gettext_lazy because the code of this definitions is only executed once (mostly on django's startup); gettext_lazy translates the strings in a lazy fashion, which means, eg.
To change the admin site header text, login page, and the HTML title tag of our bookstore's instead, add the following code in urls.py . The site_header changes the Django administration text which appears on the login page and the admin site. The site_title changes the text added to the <title> of every admin page.
It turned out I was setting a translated version for name instead of verbose_name.
This works:
class Order(models.Model):
OPTIONS = ( (0, _("Bank transfer") ), (1, _("Cash on delivery") ), )
user = models.ForeignKey(User, verbose_name=_("User") )
payment = models.IntegerField(choices=self.OPTIONS, verbose_name=_("Payment"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With