title: Techniques for localizing in ASP.NET?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/59130/what-do-i-need-to-know-to-globalize-an-asp-net-application">What do I need to know to globalize an asp.net application?</a>  </p>
  </blockquote>
  
  
  
  <p>The default Visual Studio sample web-site contains:</p>
  
  <pre><code>&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" 
         AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;
  
  &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
      &lt;h2&gt;Welcome to ASP.NET!&lt;/h2&gt;
      &lt;p&gt;To learn more about ASP.NET visit &lt;a href="http://www.asp.net" title="ASP.NET
            Website"&gt;www.asp.net&lt;/a&gt;.
      &lt;/p&gt;
      &lt;p&gt;
          You can also find &lt;a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;amp;clcid=0x409"
              title="MSDN ASP.NET Docs"&gt;documentation on ASP.NET at MSDN&lt;/a&gt;.
      &lt;/p&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>This is a good trial on needed techniques for localizing a web-site. How would you localize these:</p>
  
  <ol>
  <li><p><code>&lt;h2&gt;Welcome to ASP.NET!&lt;/h2&gt;</code></p></li>
  <li><p><code>&lt;p&gt;To learn more about ASP.NET visit &lt;a href="http://www.asp.net" title="ASP.NET
        Website"&gt;www.asp.net&lt;/a&gt;.&lt;/p&gt;</code></p></li>
  <li><code>&lt;p&gt;You can also find &lt;a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;amp;clcid=0x409"
          title="MSDN ASP.NET Docs"&gt;documentation on ASP.NET at MSDN&lt;/a&gt;.&lt;/p&gt;</code></li>
  </ol>
  
  <p>Note the use cases</p>
  
  <ul>
  <li><p>html element:   </p>
  
  <p><code>&lt;H2&gt;</code>Welcome to ASP!<code>&lt;/H2&gt;</code><br>
    <code>&lt;H2&gt;</code>Bienvenue sur ASP.NET!<code>&lt;/H2&gt;</code><br>
    <code>&lt;H2&gt;</code>ASP.NET xoş gəlmisiniz!<code>&lt;/H2&gt;</code>  </p></li>
  <li><p>text with embedded html (notice how the link moves)</p>
  
  <p><code>&lt;P&gt;</code>To learn more about ASP.NET visit <a href="http://www.asp.net" rel="nofollow noreferrer">www.asp.net</a>.<code>&lt;/P&gt;</code><br>
    <code>&lt;P&gt;</code>Pour en savoir plus sur <a href="http://www.asp.net" rel="nofollow noreferrer">www.asp.net</a> visitez ASP.NET.<code>&lt;/P&gt;</code><br>
    <code>&lt;P&gt;</code>ASP.NET səfər <a href="http://www.asp.net" rel="nofollow noreferrer">www.asp.net</a> haqqında daha ətraflı məlumat üçün.<code>&lt;/P&gt;</code></p></li>
  <li><p>text with embedded html, with embedded localizable text</p>
  
  <p><code>&lt;P&gt;</code>You can also find <code>&lt;A title="Documentation on ASP.net"&gt;</code>documentation<code>&lt;/A&gt;&lt;/P&gt;</code><br>
    <code>&lt;P&gt;</code>Vous pouvez également trouver de la <code>&lt;A title="Documentation sur ASP.net"&gt;</code>documentation<code>&lt;/A&gt;&lt;/P&gt;</code><br>
    <code>&lt;P&gt;</code>Siz həmçinin <code>&lt;A title="ASP.net sənədləşdirilməsi"&gt;</code>sənədlərin<code>&lt;/A&gt;</code> tapa bilərsiniz<code>&lt;/P&gt;</code></p></li>
  </ul>
  
  <h2>See also</h2>
  
  <ul>
  <li><a href="http://www.codeproject.com/KB/aspnet/AspNetLocalization.aspx#htmlcontent" rel="nofollow noreferrer">ASP.NET Localization (Quick Reference)</a></li>
  <li><a href="http://msdn.microsoft.com/en-us/library/dfs80h33%28v=vs.80%29.aspx" rel="nofollow noreferrer">Globalizing and Localizing ASP.NET Web Pages (Visual Studio)</a> </li>
  </ul>
  
  <hr>
  
  <p>One <strong>could</strong> use an <code>asp:Localize</code> element to translate the text in the first example:</p>
  
  <p><code>&lt;H2&gt;&lt;asp:Localize&gt;</code>Welcome to ASP!<code>&lt;/asp:Localize&gt;&lt;/H2&gt;</code><br>
     <code>&lt;H2&gt;&lt;asp:Localize&gt;</code>Bienvenue sur ASP.NET!<code>&lt;/asp:Localize&gt;&lt;/H2&gt;</code><br>
     <code>&lt;H2&gt;&lt;asp:Localize&gt;</code>ASP.NET xoş gəlmisiniz!<code>&lt;/asp:Localize&gt;&lt;/H2&gt;</code> </p>
  
  <p>problem is this solution falls apart in the next case:</p>
  
  <p><code>&lt;P&gt;&lt;asp:Localize&gt;</code>To learn more about ASP.NET visit <a href="http://www.asp.net" rel="nofollow noreferrer">www.asp.net</a>.<code>&lt;/asp:Localize&gt;&lt;/P&gt;</code><br>
     <code>&lt;P&gt;&lt;asp:Localize&gt;</code>Pour en savoir plus sur <a href="http://www.asp.net" rel="nofollow noreferrer">www.asp.net</a> visitez ASP.NET.<code>&lt;/asp:Localize&gt;&lt;/P&gt;</code><br>
     <code>&lt;P&gt;&lt;asp:Localize&gt;</code>ASP.NET səfər <a href="http://www.asp.net" rel="nofollow noreferrer">www.asp.net</a> haqqında daha ətraflı məlumat üçün.<code>&lt;/asp:Localize&gt;&lt;/P&gt;</code></p>
  
  <p>because the localized string cannot contain other HTML elements.</p>
  
  <p>Now it starts to require something like:</p>
  
  <p><code>&lt;P&gt;&lt;asp:Localize&gt;</code>To learn more about ASP.NET visit %s.<code>&lt;/asp:Localize&gt;&lt;/P&gt;</code><br>
     <code>&lt;P&gt;&lt;asp:Localize&gt;</code>Pour en savoir plus sur %s visitez ASP.NET.<code>&lt;/asp:Localize&gt;&lt;/P&gt;</code><br>
     <code>&lt;P&gt;&lt;asp:Localize&gt;</code>ASP.NET səfər %s haqqında daha ətraflı məlumat üçün.<code>&lt;/asp:Localize&gt;&lt;/P&gt;</code></p>
  
  <p>And then the html containing the link can be embedded where %s is. But then the localizer must localize fragmented phrases:</p>
  
  <ul>
  <li>To learn more about ASP.NET visit www.asp.net.</li>
  </ul>
  
  <p>becomes</p>
  
  <ul>
  <li>To learn more about ASP.NET visit %s.</li>
  </ul>
  
  <p>and in other languages it pseudo translates to:</p>
  
  <ul>
  <li>To learn more about %s visit ASP.net</li>
  <li>ASP.net visit %s about to learn more</li>
  </ul>
  
  <p><strong>Edit:</strong> What is the approved technique to localize items in ASP.net.</p>