Tracking Language Choice

If you are developing a Web site that will support multiple languages, you need a strategy for tracking the language choice made by the user. You can do this by:

  • Storing the language choice in the user profile. One option for tracking a language choice is to persist the choice made by each user in the user profile. Each page retrieves the user profile and then uses the value stored in the language property to make the appropriate selections for text formatting. This is a cost-effective method of storing language preferences, because the only performance cost involved is retrieving and updating the profile. In most cases this will be the most effective method for storing the user language preference. The ASP Profile Sitelet and the ASP.NET-Based Profile Sitelet provided in the SDK demonstrate how to implement this technique.

  • Creating distinct Web sites for each language. If your site contains mostly static HTML pages, you could pre-generate pages for each language. Using this approach, you develop and maintain multiple parallel Web sites, one for each language that is supported. Typically, the links on these pages link to other pages in the same language, while the links that move the user to a different language link to the equivalent page in each supported language. In this approach, the language choice is inherent in the URLs.

    You can minimize the maintenance burden of this approach by pre-generating pages from a reference Web site. The reference Web site should have all language-specific strings expressed as replaceable variables. You could then develop a tool to substitute the appropriate language-specific strings for each of these variables for each language that is supported.

  • Storing the language choice in client-side cookies. Storing the language choice in a client-side cookie is the easiest way to track a language choice, but cookies must be enabled on client browsers. In this approach, you store a language code (for example, "en", "fr", or "nl") in the cookie and read the cookie on every page that displays language-dependent strings. The language code can then be used to make the appropriate selections for text formatting. This is the choice used for the International Retail Solution Site.

    Depending on the expiration date of the cookies, this option may allow language choice to be preserved from session to session.

  • Passing the language choice in URL query strings. You can store the language choice in the query string portion of the URL for each page to track a language choice. If you use this approach, each page must read the language choice from the query string and use it to dynamically append the language choice to all URLs on the page so that that choice can be passed to subsequent pages. The language choice must also be used to make the appropriate selections for text, currency, and date/time formatting.

  • Detect the browsers language. The initial settings of the language choice can be based on the browser settings. This value can then be stored, and the user can change it if a different choice is wanted.

Copyright © 2005 Microsoft Corporation.
All rights reserved.