josephj1989
josephj1989

Reputation: 9709

ASP.NET localization translating HTML Content

I am localizing an ASP.NET site using automatic feature , where it creates a local resource file and adds the meta keyword to asp.net controls. However I have a lot of HTML like below

<h2> Welcome to our page"</h2>
<li> Option one </li>

Is there a way to get these automatically translated using the automatic localize utility ? I tried adding the runat="server" for these tags but to no avail.

Also instead of localizing page by page is there a way to localize bulk - it a directory or a site at one go

thanks

Upvotes: 3

Views: 2958

Answers (1)

VinayC
VinayC

Reputation: 49185

You need to use Localize control for static text - for example,

<h2>
   <asp:Localize runat=server ID="WelcomeMessage" 
    Text="Welcome to our page" meta:resourcekey="WelcomeMessage" />
</h2>

Alternatively,

<h2>
   <asp:Localize runat=server ID="WelcomeMessage" 
    Text="<%$ Resources:WebResources, WelcomeMessage %>" />
</h2>

You can also use syntax such as

<h2><%= Resources.WebResources.WelcomeMessage %></h2>

where Resources.WebResources is strongly typed resource class generated by Visual Studio resource generator. For across page resources, you can create global resources and then refer then using syntax as shown above (meta key will not work for global resources).

See MSDN for more information.

Upvotes: 6

Related Questions