2

I want to translate a string in a Django template:

{% trans "Thank you. You may <a href=\"/logout\">log out</a> now." %}

So in English, the result would be:

Thank you, You may <log out> now.

But - as an example in German, I need:

Vielen Dank. Sie können sich nun <ausloggen>.

Where the text in <> is the hyperlink. Now the problem is that the order of words has changed, and I do not find a way how to do this. I did see in the documentation that this can be done in Python code, with "placeholders". But I need it in templates. Is there a way to do it? Also, to ease translation, I don't like HTML in my translation file. Any help is highly appreciated!

Daniel
  • 1,515
  • 3
  • 17
  • 30
  • maybe this will help http://stackoverflow.com/questions/4640084/django-templates-best-practice-for-translating-text-block-with-html-in-it – fsw May 09 '13 at 19:59
  • I don't undestand what is your problem. Just write the words in the translation in any order you want. It absolutely doesn't matter that there's a hyperlink in the string. – Spc_555 May 10 '13 at 08:50

1 Answers1

0

As @fsw recommended, see this.

You should not hardcode the "/logout", you have to use {% url "urlname" %} tag. See here

maybe that? (i didnt test it)

{% url "logout" as logoutvar %}

{% blocktrans with logoutvar as logoutvar %}

"Thank you. You may <a href="{{ logoutvar }}">log out</a> now."

{% endblocktrans %}
Community
  • 1
  • 1
Leandro
  • 2,217
  • 15
  • 18
  • Daniel, Did you solve the words order with bloktrans ?? I have similar issues with spanish - english – Daniel May 30 '14 at 21:39