SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Location
    Florida
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Providing alternate language for web page

    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.

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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>),
    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">
    Few browsers do anything useful with that information, though, and even fewer users know where to look for it.

    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

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Location
    Florida
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  5. #5
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,234
    Mentioned
    47 Post(s)
    Tagged
    1 Thread(s)
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •