0

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.

3
  • 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
    – johndoe80
    Aug 12, 2022 at 11:18

1 Answer 1

0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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