Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#15172 closed (worksforme)

Admin do not translate models.

Reported by: aledr Owned by: nobody
Component: Internationalization Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

According to Django's docs the above code should show a translated model name in admin but it stills showing its name only in english.

# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _

# Create your models here.
class Activity(models.Model):
    """This model describes the customer activities."""

    name = models.CharField(_(u'Activity'), max_length=100)
    description = models.CharField(_(u'Description'), max_length=100)

    class Meta:
        verbose_name = _(u'Activity')
        verbose_name_plural = _(u'Activities')

    def __unicode__(self):
        return unicode(self.name)

Attachments (1)

django.po (1.8 KB) - added by aledr 6 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 6 years ago by Russell Keith-Magee

Resolution: worksforme
Status: newclosed

The translations don't happen by magic. Using _() just marks a string as available for translation. You then need to use createmessages to generate a local, manually translate all the string, then run makemessages to compile the translations.

If you do all those steps (which are also documented), admin woks as expected.

Changed 6 years ago by aledr

Attachment: django.po added

comment:2 Changed 6 years ago by aledr

Resolution: worksforme
Status: closedreopened

All steps are done according documentation...

Folder 'project/locale/pt_BR/LC_MESSAGES/' contains: django.mo and django.po files.

.po file is attached. As I said, just model names are not translated in Django's admin.

Thanks.

comment:3 Changed 6 years ago by Russell Keith-Magee

Resolution: worksforme
Status: reopenedclosed

I've tried this myself, and it definitely works as advertised.

Please ask on django-users (either the mailing list or IRC channel) to narrow down the source of your problem. I'm going to guess there's something wrong with your configuration, but Trac isn't the place to narrow down the problem.

If the result of that process determines a specific bug in Django, feel free to reopen this ticket with more details. However, as currently presented, the ticket is incorrect. Admin models *are* translated.

comment:4 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top