ASP.NET 2.0 Unleashed
You can localize an ASP.NET website so that it supports multiple languages and cultures. For example, you might need to create both an English language and Spanish language version of the same website. One approach to localization is to simply create multiple copies of the same website and translate each copy into a different language. This is a common approach when building ASP Classic (or even ASP.NET 1.1) websites. The problem with this approach is it creates a website maintenance nightmare. Whenever you need to make a change to the websiteno matter how simpleyou must make the change in each copy of the website. When building ASP.NET 2.0 applications, you do not need to create multiple copies of a website to support multiple languages. Instead, you can take advantage of resource files. A resource file contains language-specific content. For example, one resource file might contain a Spanish version of all the text in your website, and a second resource file might contain the Indonesian version of all the text in your website. In this chapter, you learn how to localize ASP.NET applications. First, you learn how to set the culture of the current page. You learn how to use both the Culture and UICulture properties. You also learn how to detect users' preferred languages automatically through their browser settings. Next, local resources are explored. A local resource contains content that is scoped to a particular file such as an ASP.NET page. You learn how to use both implicit and explicit resource expressions. This chapter also examines global resources. A global resource contains content that can be used in any page within an application. For example, you can place the title of your website in a global resource file. Finally, the ASP.NET Localize control is discussed. You learn how to use this control in your pages to localize big chunks of page text. |
Категории