I'm trying to fix a bug that comes when viewing a page in French. The problem is that the French translation strings have apostrophes in them and cause the HTML strings to be closed improperly.
The offending code:
<select data-bind="
optstr: [{value: 'none', label: '{% trans "String one" %}'},
{value: 'open', label: '{% trans "String two" %}'}],
value: actionType
"></select>
Is there a better way to structure this or to escape what comes back from the trans calls?
I resolved this by doing the translations separately and using the escapejs filter.
{% trans "String one" as string_one %}
{% trans "String two" as string_two %}
<select data-bind="
optstr: [{value: 'none', label: '{{ string_one|escapejs }}'},
{value: 'open', label: '{{ string_two|escapejs }}'}],
value: actionType
"></select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With