Automatically choosing between different languages for your site

  1. Create your different language files. I recommend naming them like this:

    • Info.en.html (English)
    • (French)
    • (German)
    • (Spanish)
    • Info.eo.html (Esperanto)

    Just remember that HTML markup (i.e. <STRONG>) is always in English, but stuff like the text inside <IMG ALT=""> can be in your language.

  2. Create a .htvl file (For example, Info.htvl) with contents like this:

    URI: Info.en.html
    Content-type: text/html
    Content-language: en
    Content-type: text/html
    Content-language: en
    Content-type: text/html
    Content-language: en
    Content-type: text/html
    Content-language: en
    URI: Info.eo.html
    Content-type: text/html; charset=ISO-8859-3
    Content-language: eo

    NOTE: Language codes are defined in RFC 2068, section 3.10 (page 28 or so). Make sure that the code is correct. They will usually be either a two letter code or a two letter code, a dash, and a two letter country abbreviation if you are using different dialects.

  3. Create a .htaccess file with this line and only this line in it. It must be uploaded to the directory you plan to put the other files. (If you work in Windows, you'll have to upload this file with a different name, and then rename it on

    AddHandler type-map htvl
  4. Upload to the server, and make sure your link is always to the .htvl file, and never to the individual file.

    To test this out, check for this registry key in Windows 95 (and probably NT)versions of IE (I know this works in 4.0. For earlier versions, your mileage may vary.) and change it to the language code you'd like to test out.

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International

    (Just for a side note, en-us means the us variant of English. Foreign language installations may say something completely different. "en-gb" is British English. And yes, you can use the "subdivision codes" in your htvl files, if you wish.)

    I have a file at that tests this capability out. It has English and Esperanto variants.(Change AcceptLanguage to "eo; q=1.0, en; q=0.9" to try this. You should get a message saying you got the Esperanto version (in English, sorry).

    And no, I don't know how Netscape sets the language to accept, so don't ask me.

Page Author: Curtis Jewell - Send Feedback
Last Updated: Thu Sep 5 11:39:49 2002
Visited at least 1 times since Thu Jul 20 23:19:55 2000.