turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 155 forks source link

HTML markup in a formatted string displays as text #402

Closed AlanFors closed 4 years ago

AlanFors commented 4 years ago

I have strings which need to be formatted, but contain html markup. After formatting in my razor page, it appears the string has been encoded so the html markup is displayed as text. For example, in my cshtml view I have:

[[[Welcome to the Freedom Scientific Software Licensing Portal.]]] @string.Format("[[[<strong>%0</strong> needs to be registered on the licensing portal in order to continue. |||{0}]]]", @userEmail)

When rendered on the page, I see:

Welcome to the Freedom Scientific Software Licensing Portal. <strong>abc@sample.com</strong> needs to be registered on the licensing portal in order to continue.

If I debug the page in a browser, the text is: &lt;strong&gt;abc@sample.com&lt;/strong&gt; needs to be registered on the licensing portal in order to continue.

Is there a way to achieve what I'm trying to do here? I can't imagine this being something others don't need to do. Breaking this into multiple strings would make it very hard for localizers to get right.

AlanFors commented 4 years ago

I've solved my own problem. In the csthml, the formatted string needs to be an HtmlString.

Sorry for the noise.