Reputation: 1387
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?
Upvotes: 3
Views: 924
Reputation: 1387
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>
Upvotes: 3