Reputation: 1093
Using Django 1.7.1 under Python 3.4, I have a problem where I did not find any answer to, despite seeming banal, andhaving seen many similar problems all over the internet. No solution that I understood thus far.
I have a simple django template, boiled down to the essential part. It is a simle "trans"-tag translated string within a content block that overrides the admin/base content block.
{% extends "admin/base.html" %}
{% block content %}
{% trans "Entries" %}
{% endblock %}
With this I get a TemplateSyntaxError:
Invalid block tag: 'trans', expected 'endblock'
What I learned until now it that you need to use a blocktrans for something like that. But I don't get it - WHY the heck does this not work?
Funny thing is, if I replace the {% trans "Entries" %}
with a {{ _("Entries") }}
everything works as expected.
But I need the additional benefits you get with the trans tag.
There are plenty of examples, like here, which use exactly that pattern above - and it whould work. Any help welcome.
Upvotes: 2
Views: 3387
Reputation: 121
i tried using this command:
python manage.py makemessages zh_SG
instead of
python manage.py makemessages zh-sg
(note the underscore and capital letters ending) and also made sure that each app has a locale folder (makemessages may create locale folder outside the apps which is a wrong location)
This worked for me, hope it will help you (https://stackoverflow.com/a/1833340/5798298)
Upvotes: 0
Reputation: 33843
Possibly you are missing this instruction at the top of your template?
{% load i18n %}
https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#internationalization-in-template-code
Upvotes: 11