Alex Rivera | Logout

How to embed links in localized text

Asked 2009-11-17T04:58:52.223
19

I am internationalizing an ASP.NET MVC application, but I'm unsure how to handle linked text. Take the following as an example:

  • English: "Please login to continue."
  • Português: "Entre por favor para continuar."

Since "login" is hyperlinked, I must have the translator mark which corresponding word or phrase should be hyperlinked when the text is localized, e.g. Entre.

What is the best strategy-solution?

Is there a standard way to mark special text (and a standard way of using the translated results) ... or have I gone down the wrong path in expecting my content and presentation information to be so tightly coupled (although I can't think of any way to remove the coupling in this case).

Current Implementation:

I am currently using local resource files for Views and an extension method on HtmlHelper to get the localized sting:

<%= Html.Resource("LoginMessage")%>

Update: Please see Keith's answer.

I found it most helpful, but the system auto selected another one.

Edit
Report

1 Answer

1

I'd simply look for custom placeholders that index to the link that you want placed around the text. Eg

"Please #123#login#123# to continue"

If you find #n# in your string, you know that the string that it surrounds should be a link to the url specified by index n in your lookup file (db, or whatever).

answered 2009-11-26T15:07:29.790

Your Answer