Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to translate plurals of a model in the Django admin?
    primarykey
    data
    text
    <p>I have a Django application with a model called <code>Topic</code>. I want to translate the plural of this model in the Django admin (see the red ellipse in the screenshot below).</p> <p><img src="https://i.stack.imgur.com/OYXHt.png" alt="Screenshot"></p> <p>In order to do this, I did following:</p> <p>1) Added a <em>Meta</em> class to the model in <em>models.py</em>:</p> <pre><code>from django.utils.translation import ugettext_lazy as _ class Topic(models.Model): title = models.CharField(max_length=140) def __unicode__(self): return self.title class Meta: verbose_name = _('topic') verbose_name_plural = _('topics') </code></pre> <p>2) Ran <code>django-admin.py makemessages -l ru-RU</code>, which generated a file <code>locale/ru/django.po</code>.</p> <p>3) Added translations to the <code>django.po</code> file:</p> <pre><code>msgid "topic" msgstr "Тема" msgid "topics" msgstr "Темы" </code></pre> <p>4) Ran <code>django-admin.py compilemessages</code>.</p> <p>5) Changed <code>settings.py</code> so that there are following settings there:</p> <pre><code>LANGUAGE_CODE = 'ru-RU' ugettext = lambda s: s LANGUAGES = ( ('ru-RU', ugettext('Russian')), ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.locale.LocaleMiddleware', ) USE_I18N = True USE_L10N = True </code></pre> <p>But it still doesn't work (the marked lettering in the admin still appears in English, not in Russian).</p> <p>What can I do in order to fix this?</p> <p><strong>Update 1 (28.09.2013 13:26):</strong> Maybe something is wrong with my directory structure. Here it is:</p> <p><img src="https://i.stack.imgur.com/YKZ7U.png" alt="Directory structure"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload