use*_*656 5 python django translation href hyperlink
我的问题是,如何翻译标签,标签内的链接在哪里。我正在尝试,但我只得到翻译 for ,msgid而不是 for msgid。
网站.html
<label for="id_data_protection" class="checkbox">
{% blocktrans %}Lorem <a href="/en/policy" target="_blank">Lorem ipsum</a> lorem ipsum test test {% endblocktrans %}
</label>
Run Code Online (Sandbox Code Playgroud)
django.po 文件
#: templates/pages/templates/contact.html:72
msgid ""
"Text <a href=\"/de/datenschutz\" target=\"_blank\">Text</a> "
"TextTextTextTextText"
msgstr ""
"Text <a href=\"/en/policy\" target=\"_blank\">Text Text</a> Text "
"TextTextText TextText"
Run Code Online (Sandbox Code Playgroud)
Block trans 允许我们决定哪些部分应该翻译,哪些部分不需要翻译。
对于你的情况,这是一个粗略的尝试(未经测试)
{% blocktrans with link="/en/policy" target="_blank" %}
Lorem <a href="{{ link }}" target="{{ target }}">Lorem ipsum</a> lorem ipsum test test
{% endblocktrans %}
Run Code Online (Sandbox Code Playgroud)
这样翻译人员将跳过链接标签(他应该)和链接位置。这有帮助吗?