Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put line breaks inside translatable string #595

Closed
suarezjulian opened this Issue Jun 8, 2014 · 5 comments

Comments

Projects
None yet
6 participants
@suarezjulian
Copy link

suarezjulian commented Jun 8, 2014

Hi, first of all thanks for this great library, I started using it a couple of days ago, and I like it very much so for.

I have a couple of translations that need line breaks on a translatable string. I've tried adding \n and
, but none seem to work, are they supposed to work? is there any quick way of doing this?

thanks

@PascalPrecht

This comment has been minimized.

Copy link
Member

PascalPrecht commented Jun 11, 2014

You can use html elements like <p> or <br> in your translations and they get interpreted when translating them along with the directive. There's no support for \n.

@hohwille

This comment has been minimized.

Copy link

hohwille commented Feb 7, 2017

Just as a feedback: using HTML markup is bad for security as it opens the door for injections. Allowing newlines would be safe when using in pre or verbatim tag.

@xiaolei

This comment has been minimized.

Copy link

xiaolei commented Sep 21, 2017

\n will show as line break if you apply below style to the element:
white-space: pre-wrap

@elron

This comment has been minimized.

Copy link

elron commented Jul 10, 2018

While xiaolei's answer works,
it doesn't replace two break-lines into a paragraph. I've created a pipe for this, I wrote an answer here: https://stackoverflow.com/questions/35999185/angular2-pipes-output-raw-html/51236958#51236958

It works like wordpress's wpautop()

@foluis

This comment has been minimized.

Copy link

foluis commented Feb 22, 2019

\n will show as line break if you apply below style to the element:
white-space: pre-wrap

<div style="white-space: pre-line;">
     {{content}}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.