fadedbee
fadedbee

Reputation: 44807

Django {%trans%} not working, despite django.po being generated

I have a template file templates/admin/base_site.html which includes one trans tag: {% trans "Event List" %}.

settings.py includes:

LANGUAGE_CODE = 'sv'
LOCALE_PATHS = (
    '/srv/mysite/locale/',
)

The Django-admin pages are correctly translated into Swedish, apart from the text in the trans tag.

When I run python manage.py makemessages -l sv it correctly generates a locale/sv/LC_MESSAGES/django.po file, whose last few lines are:

#: templates/admin/base_site.html:9
msgid "Event List"
msgstr "Event List"

I then change it to:

#: templates/admin/base_site.html:9
msgid "Event List"
msgstr "Händelselista"

When I run python manage.py runserver again, the string is not translated on the web page.

The rest of the admin page is still translated into Swedish, as it was before.

What am I missing?

Upvotes: 1

Views: 1066

Answers (2)

Antoine Pinsard
Antoine Pinsard

Reputation: 35012

django.po files are only meant for editing purpose. You must compile them to django.mo files so that they are interpreted:

python manage.py compilemessages

See also Django docs.

Upvotes: 2

Gary
Gary

Reputation: 1106

Have you restarted the webserver? It won't be serving the newly compiled po files if you haven't.

Edit: and be sure to restart Django server after you do as well.

Upvotes: 0

Related Questions