ASP.Net MVC: Localized texts with new line?

asp.net-mvc, asp.net-mvc-3, c#, localization, razor

Solution

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

Problem

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: - Shift+enter: I've got the new line in the resource file, but not in my browser - \r\n : I see the \r\n in my browser - \n : Same - `<br/>` : I see the `<br/>` in my text So 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.

Original source

Related problems