Yes, let’s admit, internationalization (just as security) has not been the favorite of most developers… However, if you take a look at the ASP.NET 2.0 localization support, you just might be pleasantly surprised with how easy and how cool it is!
Here is an example: say you want to change the text property of a label control based on end user’s language preference.
First, you generate a resource file – you can manually add it to App_LocalResources folder, or you can click on Tools -> Generate Local Resource (this menu is only available when you’re in the web page design mode).
Now, you simply add the resource key meta tag to your controls like this:
<asp:Label ID=”Label1″ runat=”server” meta:resourcekey=”Label1″></asp:Label></div>
That’s all you have to do to implicitly bind localized resources. If you have Label1.Text in the page’s resource file, then Label1 will automatically display proper text. You can do same with other properties – control width, fore-color, font, etc.
To explicitly do the same you would use
<asp:Label ID=”Label1″ runat=”server” Text=”<%$ Resources:Label1.Text %>”></asp:Label></div>
Imagine doing proper validation for phone numbers, zip codes, etc. by simply localizing your RegularExpressionValidator controls! No more clunky code in code-behind pages… Now, that’s sexy!