How to embed links in localized text

hyperlink option html
select link to page
option value link href
html drop down list with links
select option anchor
html select option title
select box links
anchor tag in select

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.

What I'm currently using is he following setup:

I have a global resource file containing my primary texts, named Strings.resx (Strings.NL-nl.resx etc). Next to this I have my global file containing all localizations of my actionlinks. That is: ActionLinks.resx and locals.

Now what I do is, in my Strings.resx I have something like:


Please {0} to continue

Local language Strings.NL-nl.resx

{0} om verder te gaan

Now the trick is to do something like:

<%= Html.Encode(string.Format(Resources.Strings.ControllernameViewnameKey, 
Html.ActionLink(Resources.ActionLinks.login, "Account", "LogOn")))

If you need more than one variable in your link you can give an array of objects to


The keynaming is my own convention to understand where the maintext is used (what page). Since my maintexts are very specific. Of course keys can be made yourself.

For more information on how I do it you can have a look at my answer on my own question: here


Of course you can use local files instead of global files but I like my strongly typed resources too much for that :).

WhP #15 How to manage hyperlinks with localization, Hyperlinks can be a techpub team's nightmare and localization makes things worse. Here's how Hyperlinks are often treated as static text. We used In the topics, you just insert the links by writing the following: <p>Please� Add the link. After you’ve marked the destination, you’re ready to add the link. Select the text or object you want to use as a hyperlink. Right-click and then click Hyperlink . Under Link to, click Place in This Document. In the list, select the heading or bookmark that you want to link to.

I think this comes down to 4 choices:

  1. Put a link in your localisation: "Please <a href="#">login</a> to continue"
  2. Multiple localisations - either:
    1. "Please {0} to continue" and "login", or
    2. "Please", "login" and " to continue"
  3. Markup inside your localisations, for instance:
    1. "Please {0}login{1} to continue"
    2. "Please {start-login}login{end-login} to continue"
    3. "Please <a href="{0}">login</a> to continue"
  4. Just don't support it - make the whole sentence a link

I think there is a major reason to avoid 1 - you mix up localisations and application navigation.

Option 2 ends up with multiple resources for each block of text, but as long as you have good ways of managing all your localisations it shouldn't be an issue. It can be a pain for 3rd-party translators though - you need some way to tell them the context or you get some very weird translations of the individual words.

Option 3 is my preferred solution. You still create issues for your translators though - most will not understand your tokens/HTML/markup in the text. Ours already do some HTML, so 3.3 has worked for us.

Option 4 might be worth considering - do you gain enough in having the link embedded in order to make it worth the extra work and maintenance? It's an important question specific to your application: if the whole sentence is the link (rather than just the active verb - which is link best practice) do you really lose enough to make option 2 or 3 worth the additional effort?

I think this might be why there aren't more standardised ways of doing this as for most projects (maybe 9 times out of 10) option 4 is sufficient, so this only ends up as a problem for some special cases. We have a complex application with around 11,000 pieces of localised text and go for 4 the vast majority of the time, and have only 4 or 5 places where we've had to go with 3.3

Our technical implementation is similar to yours:

<%= Html.Localise("Controller/Action/KeyOfTextOnPage") %>

For links we have a specific helper:

<%= Html.LocaliseLink("Controller/Action/KeyOfTextOnPage", "~/link.aspx") %>
<%= Html.LocaliseAction("Controller/Action/KeyOfTextOnPage", "action", "controller") %>

When adding a link on a localized web page to an English (or , Inlink anchor text (link text) serves two purposes, the primary one being user guidance and web page to an English (or source) language page, should the link text be localized? Where is the best place to insert script tags in a webpage ? To include a link in any text message, just type or paste the full URL into your message. Most messaging platforms will automatically turn the URL into a link that allows recipients of the message to click and access the linked page or content. You can also use a URL shortener to reduce the length of a URL to include in your message.

I have to agree with other answers - separate in 2.

That said I would add that don't consider the 2 words separated / unrelated. Stick to a simple convention all around like: LoginMessage & LoginMessageLink, corresponding to the whole text of the sentence & the text of the link.

That's neutral & if that's what needed for the language the translator can have the whole sentence be the link.

If you find yourself needing to link several times to the same page, then instead have some markers for it. Like:

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

Using <select> to Link to Localized Content, Key disadvantages of using select for links to localized pages or sites are: users may not have fonts for all the option text, and graphics cannot be used avoid using a pull-down menu altogether and simply include links directly on the page. However, this solution is not very friendly to localization; it is particularly problematic in the case where sentences require rearranging in the process of localization. I would much prefer to be able to specify something like "[Retry]({0}) or [go back.]({1})." in a resx file and dynamically insert the hyperlinks into the localized string.

I know this is an old question but I figured this might help.

In Core 2.2, you can have a resource file containing:

AllText: There are 2 links and one string. Links are {0} and {1}, the string is {2}
Link1Text: link1
Link2Text: link2
String1: something special

Then you have the view where you inject the localizer:

@using Microsoft.AspNetCore.Mvc.Localization

@inject IViewLocalizer Localizer

And finally in your HTML:


No need to encode or decode anything, just provide the parameters to the Localizer.

How to make a text with hyperlink translatable in WordPress , to include more than one placeholder for each translatable string may be " dangerous". If the translator is not a developer, they will easily break the page rendering. Purpose. This helper template can be used to link to translatable pages in the user's language. It uses the special page prefix Special:MyLanguage/, which checks if there is a translated version of a page in the user's language, and links to it if there is one, and links to a fallback language where available, or the default wiki language version (English in MediaWiki) if there isn't.

I'd suggest separating the resource into two values, like this - 1: Please {0} to continue. - 2: login

or for Português - 1: {0} por favor para continuar. - 2: Entre

And then combine them to build the link and message. {0} is substitued for the link/actionlink/whatever you need.

Localization content best practices, Important: always include the localization note with this format if you use a LOCALIZATION NOTE(tos-text): {{link}} will be replaced at run-time� On the Insert tab, click Hyperlink. You can also right-click the text or picture and click Hyperlink on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box. Note: If you don't see the Address box, make sure Existing File or Web Page is selected under Link to.

Internationalization tips for linking to headings & figures, For the link text, include all the markup inside the heading tag, not just the to be included in the link text, ensure that it is easily localised for translated content. Purpose []. This helper template can be used to link to translatable pages in the user's language. It uses the special page prefix Special:MyLanguage/, which checks if there is a translated version of a page in the user's language, and links to it if there is one, and links to a fallback language where available, or the default wiki language version (English in MediaWiki) if there isn't.

Dynamic or static links and HTML in translatable strings, This achieves HTML and text separation but makes life hard for you and translators alike. In these simple cases, just include the inline markup,�

Localize the UI with Translations Editor, Figure 1. The Translations Editor showing app text before translation In strings. xml, click the Open editor link in the upper-right corner.

  • I think separating the translations of the action links from the rest of the sentence could be risky. Your suggestion would always work if a sentence can be broken into segments, translated independently and pieced back together without introducing poor word choices and poor word ordering. But since sentence structures are different from one language to the next and word choices are context sensitive, I think the sentences must be translated as a whole. Have you run across that problem? Thanks for the input! I like a lot of what you have done and it is defiantly helpful.
  • ... or perhaps "definitely" helpful. :-)
  • Hm, what you say does make sense but I have not run into that problem yet. Maybe because I do not have that much of text which is static. If you find a solution for this be sure to message me I would love to hear one, because it indeed may be a problem.
  • In languages like German and English, a verb can be broken into two pieces that are not next to each other such as "Log the account for the application in". Of course in English we tend to prefer "Log in the account for the application", but other languages may not. In addition, some languages use a non-root form of a word such as the Spanish example using "Entre" instead of "Entrar". The translator needs to see the whole sentence to know the correct word form to choose.
  • Excellent response! Our translators can work around html tags and we have decided use 3.3 in most instances. This is working well.
  • Thank you for posting. See my comment on bastijn's post about the risks of poor word choice or word order with translations that are not done in complete sentences. I think that would apply here as well.
  • Definitely. We've suggested basically the same solution. I'd say that in the example, you can't reuse the strings for 1-2 for anything else.