Make the lines inside the trans tag top

In my template, sometimes I want the translated string to go through the upper filter. For example, I want to display “Related Links” as “RELATED LINKS”. However, when I tried, for example:

 {% trans "Related links"|upper %} 

TemplateSyntaxError . Any suggestions?

+6
source share
2 answers

Just use:

 {% trans "Related links" as rel %}{{ rel|upper }} 

This temporarily stores the hyphenation in a variable, which can then be used to apply filters to it.

Source: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#trans-template-tag

+13
source

Starting with Django 1.10, you can avoid aliases and just use:

 {% trans "Related links"|upper %} 
0
source

Source: https://habr.com/ru/post/1446082/


All Articles