Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 3 years ago by aledr

comment:2 Changed 3 years ago by aledr

  • Resolution worksforme deleted
  • Status changed from closed to reopened

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 3 years ago by russellm

  • Resolution set to worksforme
  • Status changed from reopened to closed

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 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.