I want to dynamically translate a html button title attribute in my django project using _("to be translated")
or {% trans "to be translated" %}
in a javascript file.
The compilation of the .po files for internationalisation works fine for the .html files:
<li data-toggle="popover" title="{% trans 'to be translated' %}"
In my .js file, I return a HTML element from within a function:
return $('<button title="{% trans 'to be translated' %}" type="button" class="gk btn btn-default pull-right"></button>').click(onclick);
Due to nested quotes ("{% trans 'to be translated' %}" )
and blanks (_("to be translated")
) returning a html element from a .js file including a translation does not seem to work.
Is there any workaround for this in django? Thank you!