Is it possible to use translations with nl2br?

I tried {{ "This offer may \n interest you"|nl2br|t }}, but it doesn't translate the string because it contains a '\n' character.

I already tried with {% trans %}{% endtrans %} instead of |t, but the result is same.

  • It doesn't seem like this should be a problem - t doesn't know/care how the string came to be. You should find the translation source under This offer may <br /> interest you
    – Clive
    Aug 12, 2022 at 10:20
  • Do you actually want a line break to display?
    – cilefen
    Aug 12, 2022 at 10:22
  • The solution would surely be to include \n in the translation but I think It's not really a good solution
    – johndoe555
    Aug 12, 2022 at 11:18

1 Answer 1


Did you try {{ "This offer may \n interest you"|nl2br|striptags|t }}?

  • Yes I already tried but I still doesn't have my translation
    – johndoe555
    Aug 12, 2022 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.