Closed pacahon closed 3 years ago
@wizpig64 can you check please?
Same problem here.
Could you check please.
TL;DR workaround for django 3.1 users:
If you are using django 3.1 or higher, convert your DLT templates to use {% translate myvar %}
instead of {% trans myvar %}
, and things ought to work again using the current django-jinja 2.7.0.
exhaustive explanation:
I was able to replicate this issue by converting the repo's i18n_test.jinja
to DTL. At first it looked like nothing was wrong, but after re-reading the ticket I realized I was using {% translate %}
and not {% trans %}
. switching got it to raise the initially-misleading message SyntaxError: Translation blocks must not include other block tags: trans 'Year' as t_year (file testapp/templates/i18n_test.html, line 6)
.
Here's what's happening in this particular failure: Django is trying to prevent nested {% blocktrans(late) %}
/{% endblocktrans(late) %}
blocks, but the name of jinja's equivalent to these ({% trans %}
/{% endtrans %}
) collides with django's standalone {% trans myvar %}
tag. Because our monkey patched makemessages command processes both types of templates with the same collection of regexes, and I was unaware of this at the time of 2.7.0, my faulty regex change treated a DTL {% trans myvar %}
tag like a {% blocktrans(late) %}
tag, which breaks things as it expects a closing {% endblocktrans(late) %}
.
My new regex uses a different approach to solve #255 that seems to work with the right tags in the right engines.
@pacahon @hugokernel I've submitted a change that fixed this in my test template, and should not necessitate upgrading to the translate
tag as above. Please test it out with your templates, as they might break differently than mine did.
@pacahon @hugokernel I've submitted a change that fixed this in my test template, and should not necessitate upgrading to the
translate
tag as above. Please test it out with your templates, as they might break differently than mine did.
I had try the new regexp and it works well.
Thx
It works for me too. Thanks.
Hello.
Looks like it's impossible to use
{% trans myvar %}
syntax in DTL files after this change https://github.com/niwinz/django-jinja/commit/e3764f65560c9e9edab71b858e345cc641621441 was introduced.