Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makemessages ignores {% trans %} block #314

Open
Eroica opened this issue May 14, 2024 · 0 comments
Open

makemessages ignores {% trans %} block #314

Eroica opened this issue May 14, 2024 · 0 comments

Comments

@Eroica
Copy link

Eroica commented May 14, 2024

Hi,

I'm afraid I must be doing something wrong, but with the following setup, I cannot get makemessages to parse anything in {% trans %}...{% enddtrans %} blocks:

pyproject.toml:

[tool.poetry.dependencies]
python = "^3.11"
Django = "^5.0.6"
django-jinja = "^2.11.0"

settings.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'newstyle_gettext': True,
            "extensions": DEFAULT_EXTENSIONS + [
            ],
        },
    },
]

Then a sample template file in /subapp/templates/subapp/index.jinja:

{{ _("This works") }}

{% trans %}This gets ignored{% endtrans %}

{% blocktrans %}This also works{% endblocktrans %}

I then run poetry run python manage.py makemessages -l en -e html,txt,py,jinja which produces this .po file:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-14 16:41+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: .\subapp\templates\subapp\index.jinja:1
msgid "This works"
msgstr ""

#: .\subapp\templates\subapp\index.jinja:5
msgid "This also works"
msgstr ""

My problem is that I would like to use {% trans %}... for more complex strings, and I cannot use blocktrans because then Jinja complains about an unknown tag. Any idea what could be wrong? If required, I'll upload a whole sample project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant