road...">

Jinja2 link translation

From the Jinja2 template, this is the displayed string, after which (in English):

This is the <a href="roadmap.html">roadmap</a> 

Translation in Dutch should result in:

 Dit is de <a href="roadmap.html">planning</a> 

This Jinja2 line will take me there - almost -

 {{ _('This is the %(roadmap)s.', roadmap='<a href="roadmap.html">roadmap</a>'|safe) }} 

Unfortunately, the word roadmap has not been translated.

What will be the way Jinja2 does this? Link separation in roadmap1 and roadmap2? Hope for something smarter.

+4
source share
1 answer

They should work:

 {{ _('This is the') }} <a href="roadmap.html">{{ _('roadmap') }}</a> {{ _('This is the %(roadmap)s', roadmap=('<a href="roadmap.html">%s</a>' % _('roadmap'))|safe) }} 

Also, if you use webapp2, you can replace href = "roadmap.html", for example. href="{{ uri_for('roadmap') }}"

+1
source

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


All Articles