niwinz / django-jinja

Simple and nonobstructive jinja2 integration with Django.
http://niwinz.github.io/django-jinja/latest/
BSD 3-Clause "New" or "Revised" License
360 stars 102 forks source link

added jinja2 policies in template options, makemessages respects ext.i18n.trimmed policy #285

Closed wizpig64 closed 3 years ago

wizpig64 commented 3 years ago

Fixes #284.

In their 2.9, Jinja2 added a policies dict on the base Environment, which controls rendering behaviours.

This change adds the ability to set those policies via django settings, and adds a section about it in the docs.

I tested this out by adding the ext.i18n.trimmed setting to the testapp's template options dict, and indeed the i18n view started rendering with everything trimmed.

Update: I've now figured out how to get this trimming policy to work with our custom makemessages command, by inserting trimmed in all the right places, assuming ext.i18n.trimmed is enabled.

To test this feature out in your project, you can install this branch thusly:

pip install -e git+https://github.com/wizpig64/django-jinja.git@ade847b3e5e4140809e7ea5a46c51ae175af3d31#egg=django_jinja
wizpig64 commented 3 years ago

Pausing this PR until I can figure out adding auto trimming support to the makemessages command.

wizpig64 commented 3 years ago

@paris-ci says this fixed their issue. if nobody else comments here with knowledge of a regression, i'll probably merge this next week and release it as 2.9.0.

pinging known users from previous makemessages issues: @canassa @pacahon @hugokernel