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:

  • Creating distinct Web sites for each language. If your site contains mostly static HTML pages, consider using pre-generated pages. 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, currency, and date/time formatting.

    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.

  • Storing the language choice in the user profile. Another option for tracking a language choice is to persist the choice made by each user in the user profile. This approach requires you to add a language property to the user profile, which you initialize when the user first chooses a language, or changes languages. Each page retrieves the user profile and then uses the value stored in the language property to make the appropriate selections for text, currency, and date/time formatting. This is a cost-effective method of storing language preferences, because the only performance cost involved is retrieving and updating the profile.


All rights reserved.