I've an Asp.Net MVC 3 website, which will be localized.
I've several resx files which contains my texts, and I've in my views some
@My.NameSpace.Through.My.LocalizationFile.Key
But I can't make it represent the new line.
I tried:
<br/>
: I see the <br/>
in my textSo what should I do to have a new line?
Edit: I know that I could use Html.Raw, but I just can't ask to translators to put html code in their translation.
Use Shift + Enter to insert a new line. Save this answer. Show activity on this post.
IStringLocalizer uses the ResourceManager and ResourceReader to provide culture-specific resources at run time. The interface has an indexer and an IEnumerable for returning localized strings. IStringLocalizer doesn't require storing the default language strings in a resource file.
Globalization is the process of designing the application in such a way that it can be used by users from across the globe (multiple cultures). Localization, on the other hand, is the process of customization to make our application behave as per the current culture and locale.
To be honest, I know it's not the nicest thing in the world, but it's fool-proof and it means your translators don't have to put any code in their translations:
Building upon the answers already given, why don't you just use Html.Raw
, but before doing so, replacing the \r\n
that using Shift+Enter in the resource file results in, with a <br />
So say for example you had the string named Welcome
in the resource file ApplicationMessage
, you could do:
@Html.Raw(ApplicationMessage.Welcome.Replace("\r\n", "<br />")
That will give you what you need. Here's a similar question:
HTMLencode HTMLdecode
You can put the <br />
for the line breaks and use the @Html.Raw()
method to show the string with the line break instead of the <br />
string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With