The topics in this document assume you have already read the basic concepts presented in Globalization and Localization Primer.
One feature added in ASP.NET v2.0 is automatic detection of browser language, which can be used to easily adapt an application’s behavior to the user’s culture simply by determining the language of the requesting browser.
Most browsers allow users to set their language or culture preferences in their browsers. For example, in Microsoft Internet Explorer, on the Tools menu, users can click Internet Options, and on the General tab, click Language, and then set their language preference.
HTTP allows browsers to send this list of preferred languages to the Web server using the Accept-Language HTTP request header field.
ASP.NET can automatically set the Culture and UICulture for a Web page based on the values that are sent by a browser, if the enableClientBasedCulture attribute of the globalization element in the Web.config
file is set to true.
To have ASP.NET set the culture and UI culture to the first language that is specified in the current browser settings, set Culture and UICulture to auto.
Alternatively, you can set this value to auto:culture_name, where culture_name is a valid CultureInfo name, such as en-US.
The following table lists all the CultureInfo names predefined in the .NET framework.
NOTE: Not all international fonts and code pages may be available or supported in your system, hence some characters or symbols may not render correctly. You can optionally install supplemental language support using the Regional and Language Options in Control Panel.
Show me
The setting can apply to all pages, or to an individual page, as we shall later see.
If the first language in the list matches the name of a specific culture supported by the .NET Framework, ASP.NET will set the current culture and UI culture of the running thread to this culture.
If the first language in the list is not a culture supported by the .NET Framework, ASP.NET will fall back to the culture specified after the colon in the culture declaration.
It is not good practice, though, to rely exclusively on browser settings to determine the UI culture for a page. In some cases the culture chosen by auto-detection may not be suitable for the user or the application. Moreover, users frequently use browsers that are not set to their preferences ( for example, in an Internet cafe ).
One approach would be to provide a way for users to explicitly choose a language or language and locale for the page, and store the selection using the new ASP.NET v2.0 Profiles feature.