Blue Reef Technical Support Blue Reef Virtual Server Reseller ProgramInstallation instructions, manuals, how-tos, and more!About Blue Reef Consulting, Inc.

About Blue Reef Virtual ServersEcommerce Solutions for your Virtual ServerSearch the Blue Reef Virtual Server web site
Return to Blue Reef Virtual Servers Home Page
Order virtual servers, software, computers, and more!
Return to Blue Reef Main Home Page
Site Map
Support Solutions to help you do business with your Virtual Server.

Blue Reef Virtual Servers
Support Menu
Featured Solutions
Featured Solutions Overview
Support Archive
Request Help
Order a Blue Reef Virtual Server now!

Serving Documents
Based on Language Preference

Featured: July 1998

The Apache Web Server has the ability to look at the language preference specified by a browser client and return the content of different files depending on that preference. This ability, termed "language content negotiation", is a simple yet very powerful feature of the Apache server that is not often used.

There are essentially two approaches to content negotiation. The first uses a "variants" file (or a "var" file) which essentially lists document resources file by file and identifies them with a specific language. This may be convenient for small sites or if you only want to provide language typing for an entry page of a web site (which would then explicitly link to web content authored in different languages). The second approach uses file extensions (just like MIME types) to associate a file with a language.

Please find below a list of the steps necessary to configure the web services on your Virtual Server to perform language content negotiation by file extension. More information about configuring language content negotiation on a file by file basis can be found by reading the reference documents included at the bottom of this page.
  1. Add language type definitions to your srm.conf file

    Using whatever method you find convenient, edit the file srm.conf (located in your ~/www/conf directory) and add language definitions using the AddLanguage directive. For example, add the following lines to your srm.conf file:

      AddLanguage en .en
      AddLanguage es .es
      AddLanguage fr .fr
      AddLanguage de .de
      AddLanguage it .it
      AddLanguage jp .jp

    Basically, this will associate the file extensions, .en .es .fr .de .it .jp, with the corresponding language abbreviations, en es fr de it and jp. The abbreviations are pre-defined and can be located in any of the latest generations of browser clients. For example, in Netscape 4.x they are found in "Edit->Preferences->Navigator->Language->Add(button)". In MSIE 4.x they are found in "View->Internet Options->General(tab)->Languages(button)->Add(button)".
  2. Add language priority definition to your srm.conf file

    Using whatever method you find convenient, edit the file srm.conf (located in your ~/www/conf directory) and add a language priority definition using the LanguagePriority directive. For example, add the following line to your srm.conf file:

      LanguagePriority en es fr de

    The language priority directive allows you to give precedence to some languages in case of a "tie" during content negotiation or if the browser client does not specify a language priority (older browsers). Just list the languages in decreasing order of preference.
  3. Modify the Options definition for your htdocs area to include "MultiViews"

    Using whatever method you find convenient, edit the file access.conf (located in your ~/www/conf directory) and add the MultiViews option to the Options directive that is part of your htdocs Directory definition. For example, your Options line may look something like this:

      Options Indexes FollowSymLinks MultiViews

    The MultiViews option can also be added to the Options definition in .htaccess files.
That's it! Now you will need to author content and upload it to your Virtual Server using appropriate extensions. For example, you would create "index.html.en", "", "", etc. instead of an "index.html". When the browser client requests "index.html", the server will analyze the language preference of the browser client and serve the appropriate "index.html.*" file seamlessly and transparently.

There is at least one snag. If the language preference the browser submits does match any of the type definitions on your server and documents you have authored. The server will return a 406 error (i.e. the resource was found, but could not be delivered because the type of the resource is incompatible with the acceptable types indicated by the accept or accept-encoding headers sent to the server by the client). So, for example, if a client will only accept Greek content (el) and nothing else, but you have only authored content in English, Spanish, and German, the client will receive a 406 error. It may be wise to capture the 406 errors with a custom ErrorDocument script.


Configuring your Web Server

Serving Multi-Language Documents


Apache: Web Server Directives Guidebook Apache: Web Server Directives Guidebook

Apache Server For Dummies Apache Server For Dummies
$23.99 logo
Search for :
Enter keywords...