How to encode newlines? #818
-
This is an extremely basic use case and the solution is non-obvious. <p> first line<br />
second line</p> by <p>{{ $t("newLineExample") }}</p> where newLineExample refer a JSON key that in english equal: "first line |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can do this by changing the line breaks in the Translation component and locale messages to look like this: locale messages (JSON resource): {
"oneline": "first line{newline}second line'"
} Translation component: <i18n-t tag="p" keypath="oneline">
<template #newline><br /></template>
</i18n-t> the break line in the resources of locale messages are not very desirable for localization and maintenance considerations. locale messages (JSON resource): {
"first": "first line",
"second": "second line'"
} <p>{{ $t('first') }}<br />{{ $t('second') }}</p> |
Beta Was this translation helpful? Give feedback.
You can do this by changing the line breaks in the Translation component and locale messages to look like this:
locale messages (JSON resource):
Translation component:
the break line in the resources of locale messages are not very desirable for localization and maintenance considerations.
I recommend defining "first line" and "second line" as separate keys in the locale resources and implementing them as follows:
locale messages (JSON resource):