I am using the django {% language %}{% endlanguage %} tag to over-rule the language code of text in my django template with a different language code from a html select list, however it is not working!
Here is my code:
{% language '$("#id_language_code").val()' %}
"{% trans 'to Present' %}"
{% endlanguage %}
The $("#id_language_code").val() is definitely changed when the user selects a value from the html select list. If I append the $("#id_language_code").val() to the translation string above, the changed language code is displayed, but the translation string is not changed. For example:
"{% trans 'to Present' %}" + $('#id_language_code').val()
displays this (where de is the language code selected by the user, but the "to Present" is not translated):
to Present de
If I hard code a language code into the {% language %} tag the translation string is translated. For example:
{% language 'de' %}
Can anyone point out what I am doing wrong?