I'd like to know the best way to specify a that a web page has a translation available for another language. Is there a standard way to do this? I know how to specify the language for a page, but I'm not sure how to specify an an alternate language.
| SitePoint Sponsor |
I'd like to know the best way to specify a that a web page has a translation available for another language. Is there a standard way to do this? I know how to specify the language for a page, but I'm not sure how to specify an an alternate language.


Since you're posting in the HTML and XHTML forum, I assume you're asking about a way to declare this with markup? If so, you can use the link element type (between <head> and </head>),
Few browsers do anything useful with that information, though, and even fewer users know where to look for it.Code HTML4Strict:<link rel="alternate" href="german.html" lang="de" title="Deutsch"> <link rel="alternate" href="swedish.html" lang="sv" title="Svenska"> <link rel="alternate" href="french.html" lang="fr" title="Français">
The simplest way is probable to have a list of regular links within the document,
Code HTML4Strict:<h2>Translations</h2> <ul> <li><a href="german.html" lang="de">Deutsch</a></li> <li><a href="swedish.html" lang="sv">Svenska</a></li> <li><a href="french.html" lang="fr">Français</a></li> </ul>
Birnam wood is come to Dunsinane
Thanks for the tip; I wanted to make sure there wasn't a foolproof automatic way to reroute foreign language traffic to the proper page.


You can do server-side content negotiation, either with a programming language of your choice or by letting the web server do it automatically (at least Apache can do this).
The principle is that you examine the Accept-Language HTTP header sent by the user agent and serve the proper page depending on what it says.
Birnam wood is come to Dunsinane





Heh, I would get very strange results! Some of my browsers are Engrish because the OS is (Windows on Virtual Box), some are in Dutch (though Dutch FF doesn't let me use Aardvark : ( and a few are in Spanish.
Depending on what kind of site it is, one nice (I mean, NICE) feature is a cookie or session-based (or even databased if you have users who log in and set preferences) is to let the user choose from a list.
I might be a Japanese business woman using an Italian computer in an Internet Cafe in Rome. The browser's gonna be in Italian, and everything's going to be configured in Italian, and it won't know I'm a foreigner on business. So if that's an option, consider it. Kinda like letting people select a stylesheet and using the session to keep their chosen style for your page.
Bookmarks