Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django TemplateSyntaxError Invalid block tag: 'trans'

After running the runserver command I get the following error:

TemplateSyntaxError at /questions/ Invalid block tag: 'trans'

Does anybody know that what's the reason?

This is my template syntax:

     {% extends "two_column_body.html" %}
{# 
    this template is split into several
    blocks that are included here
    the blocks are within directory templates/main_page
    relative to the skin directory

    there is no html markup in this file
#}
<!-- questions.html -->
{% block forejs %}
    {% include "main_page/custom_head_javascript.html" %}
{% endblock %}
{% block title %}{% spaceless %}{% trans %}Questions{% endtrans %}{% endspaceless %}{% endblock %}
{% block content %}
    {% include "main_page/tab_bar.html" %}
    {% include "main_page/headline.html" %}
    {# ==== BEGIN: main_page/content.html === #}
    <div id="question-list">
        {% include "main_page/questions_loop.html" %}
    </div>
    {# ==== END: main_page/content.html === #}
    {% include "main_page/paginator.html" %}
{% endblock %}
{% block sidebar %}
    {% include "main_page/sidebar.html" %}
{% endblock %}
{% block endjs %}
    <script type="text/javascript">
        {# cant cache this #}
        askbot['settings']['showSortByRelevance'] = {{ show_sort_by_relevance|as_js_bool }};
        askbot['messages']['questionSingular'] = '{{ settings.WORDS_QUESTION_SINGULAR|escapejs }}';
        askbot['messages']['answerSingular'] = '{{ settings.WORDS_ANSWER_SINGULAR|escapejs }}';
        askbot['messages']['acceptOwnAnswer'] = '{{ settings.WORDS_ACCEPT_OR_UNACCEPT_OWN_ANSWER|escapejs }}';
        askbot['messages']['followQuestions'] = '{{ settings.WORDS_FOLLOW_QUESTIONS|escapejs }}';
    </script>
    {% include "main_page/javascript.html" %}
    {% include "main_page/custom_javascript.html" %}
{% endblock %}
<!-- end questions.html -->
like image 881
Mazdak Avatar asked Jun 27 '14 12:06

Mazdak


1 Answers

{% trans %}Questions{% endtrans %} is not the correct format.

{% load i18n %} should be at the top of your template, or any extended template using translations.

You can use {% trans "Questions." %}

If you're going to use blocks, they need to be in the format below:

{% blocktrans %}{{ value2translate }}{% endblocktrans %}

More info here.

like image 196
chirinosky Avatar answered Sep 20 '22 05:09

chirinosky