I used to have something like this:
We suggest you read our @Html.ActionLink("help page", "Help", "Home") before
proceeding.
nice and clean. then I decided we needed to internationalise the app. I couldn’t figure out a better way to deal with the above than to store the following string in the resource file:
We suggest you read our [HelpPage] before proceeding.
and then on the view I have to do:
@MvcHtmlString.Create(this.Resource("Help").ToString()
.Replace("[HelpPage]",
@Html.ActionLink("help page", "Help", "Home").ToString()
)
)
What other strategies can you use to internationalize using Razor?
this.Resource() is a page extension that calls .GetLocalResourceObject() and returns an MvcHtmlString
so here’s what I ended up writing:
where the tag replacements gets done like this:
so in my code I can now call it like this:
and elsewhere:
any suggestions for improvement most welcome