When should I use a Localize control instead of a Literal? When should I use a Localize control instead of a Literal? asp.net asp.net

When should I use a Localize control instead of a Literal?


I appreciate this has already been marked as answered, but here is another way to look at it.

<asp:Localize> is used to specify a Resource defined item, which forces the IDE to display some specified text, and still allows it to resolve at runtime, to the language of the website.

This may be useful for the development of a site where the content of the site is actually in a different language. So you would be able to be an English-speaking programmer, creating a website in Turkish, and still know what a <asp:Label> is supposed to without having to learn Turkish.

So as an example:

<asp:Localize runat="server" Text="<%$Resources : Label, Price%>">        Price</asp:Localize>

Now, if my default Label.resx was translated into Turkish, the Labels.resx mapping would be:

Key="Price"Value="fiyat"

At design time, the IDE would display Price (as the inner text of the <asp:Localize> element is Price) but the actual live view of the page in a web browser, would resolve to fiyat.

Therefore:

<div>   <asp:Localize runat="server"                  Text="<%$Resources : Label, Price%>">                      Price   </asp:Localize></div>

Becomes rendered as:

<div>fiyat</div>

But in the IDE Designer, this would be displayed as "Price".

The difference with labels, is that <asp:Label> will resolve to fiyat in both the IDE Designer and at run-time.


This described it best:

The Localize Control lets you localize any element on an .aspx page. It provides a design time feature not offered by its base class, the Literal control; in particular, the Localize control provides design time editing of static content so you can see a default value while working in page design mode.

Found at: http://wiki.asp.net/page.aspx/357/localize/

MSDN (bottom section has a good description)