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

Best practice for including line breaks in long strings? #160

Open
JohnMcLear opened this issue Apr 1, 2018 · 5 comments
Open

Best practice for including line breaks in long strings? #160

JohnMcLear opened this issue Apr 1, 2018 · 5 comments

Comments

@JohnMcLear
Copy link

Just wondering what you guys recommend to do? I have a lot of TOS / T&C licenses we translate down and I want to keep them as individual strings in my JSON files if poss :)

@Nikerabbit
Copy link
Member

Splitting per paragraph would be beneficial for translators as well. But you can use \n inside the strings, it just gets very ugly to edit them manually.

@JohnMcLear
Copy link
Author

\n doesn't work @Nikerabbit - Are you sure \n is the right approach? It makes sense but it's weird that it doesn't work!

@Nikerabbit
Copy link
Member

Are you expecting the newlines to appear in rendered HTML? That won't work. You need to add <br>s or <p> wrappings to the string or do something like $dom.append( htmlescape( $.i18n( key ) ).replace( / /\n/, '<br>' ) ).

Or just split the paragraphs in the file :)

@JohnMcLear
Copy link
Author

Yes I was hoping the newlines to appear in rendered HTML.. I'm being totally dumb here.. Can you provide a HTML / JSON / JS file showing example? I tried adding
to the string and no dice with that.. I can't imagine I have to do a replace on language change, that seems far too clunky just to add line breaks!

@Nikerabbit
Copy link
Member

It is very clunky indeed, hence my persistent recommendation to use separate messages per paragraph :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants