Search code examples
djangostringinternationalizationescaping

Escape quotes in django's trans method


I'm trying to internationalize my webpages by using the {% trans "string" %} method in django.

However I get an error when I try to use quotes in the string. I've already tried to escape them with a backslash with no luck.

How can I escape something like this:

{% trans "foo's is like "foo"." %}

As I said, this doesn't work:

{% trans "foo\'s is like \"foo\"." %}

Any idea?

Thanks


Solution

  • Use blocktrans instead.

    Example
    {% blocktranslate %}Just an example block to translate with {{value}} and text.{% endblocktranslate %}