Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to localize text with including Html.ActionLink

I have text to localize like this

<p>Please enter your user name and password. @Html.ActionLink(@Resources.Register, "Register") if you don't have an account. </p>

Very often there is an ActionLink in the text.

Can I use something like {0} for the whole ActionLink

@string.Format(Resources.LogOn_Enter_Message, Html.ActionLink(@Resources.Register, "Register"))

(this doesn't work because the link becomes a string)
or do I have to divide the paragraph into 2 parts?

like image 829
nubm Avatar asked Apr 11 '12 08:04

nubm


1 Answers

You should do it like this:

@Html.Raw(string.Format(Resources.LogOn_Enter_Message, Html.ActionLink(@Resources.Register, "Register")))

And store your localized string:

 <p>Please enter your user name and password. {0} if you don't have an account. </p>
like image 181
ionden Avatar answered Nov 11 '22 19:11

ionden