AddThis Social Bookmark Button


Localization in ASP.NET 2.0
Pages: 1, 2, 3, 4

Double-click on Default.aspx.zh-CN.resx to edit the resources contained within. In particular, enter the following (see Figure 5, highlighted in red) in Chinese.

figure 5
Figure 5. Entering the resources in Chinese

To use the auto-culture handling feature of ASP.NET 2.0, ensure that the following two attributes are present in the Page directive:

  • Culture="auto"
  • UICulture="auto"

<%@ Page Language="VB" AutoEventWireup="false" 
   CodeFile="Default.aspx.vb" Inherits="_Default" 
   Culture="auto"  UICulture="auto" %>

That's it! You can now press F5 to test using Internet Explorer. By default, you should see that IE displays your page in English. To change to Chinese, in IE go to Tools -> Internet Options…. Click the Languages… button and then click the Add… button to add the "Chinese (China) [zh-cn]" language to your browser. Ensure that the newly added Chinese language is now at the top of the preferences (see Figure 6). Click OK twice to dismiss the dialog boxes.

figure 6
Figure 6. Setting language preference in IE

Refresh IE and your web page should now display in Chinese (see Figure 7).

figure 7
Figure 7. Viewing the page

To switch back to English, simply configure IE to display English as the preferred language. This method of localization that you have just seen is known as implicit localization.

Pages: 1, 2, 3, 4

Next Pagearrow