www.webdeveloper.com
Results 1 to 7 of 7

Thread: Multiple languages on a website. How?

  1. #1
    Join Date
    Oct 2010
    Posts
    25

    Multiple languages on a website. How?

    I was wondering how one best programs support for many different languages on a website.
    I suppose every piece of text on the website has to be stored somewhere, variable or database and in the different languages and the right one will be displayed according to what setting has been chosen.

    Is there any method which is considered the best?

  2. #2
    Join Date
    Aug 2006
    Posts
    1,906
    Quote Originally Posted by andx85 View Post
    I suppose every piece of text on the website has to be stored somewhere, variable or database and in the different languages and the right one will be displayed according to what setting has been chosen.
    Yes, basically. There is another option I've seen, which is on the end of "cheap, easy, and not too good" which is to pass your entire site through Google's translation API on the fly. That lets you build a site that works in a whole bunch of languages very easily, but the translated results are pretty bad.

    Personally I have a site I do in three languages by storing all the content in XML files with tags like:
    <title lang="en">Good Morning</title>
    <title lang="fr">Bonjour</title>

    It does get tedious both on the page development and the maintenance of the XML content, but the result is very nice.

    Dave

  3. #3
    Join Date
    Oct 2010
    Posts
    25
    Interesting. The XML, looks like a real good solution. Thanks

  4. #4
    Join Date
    Oct 2010
    Posts
    25
    Oh and also, you wouldn't happen to know any simple open source code/site that does this, that I could have a look at?

  5. #5
    Join Date
    Aug 2006
    Posts
    1,906
    Quote Originally Posted by andx85 View Post
    Oh and also, you wouldn't happen to know any simple open source code/site that does this, that I could have a look at?
    I don't, sorry. There doesn't seem to be a lot of discussion on the topic, and when I went to do it I couldn't find much in the way of solid examples. It's not difficult from a coding perspective, it's just a bit nitty-gritty in terms of trying to make the end result manageable as you add content.

    Basically you've got two (almost independent) components to address. Firstly how you will determine the language the user wants to see and how to make that language known in your code (e.g. little pictures of flags, cookie, session variable, browser query), and then secondly is building a set of useful routines to import the XML and display blocks of text in the appropriate language.

    Dave

  6. #6
    Join Date
    Oct 2010
    Posts
    25
    hmm.. I see. I'm gonna have to think this through a bit before I start.
    You've been very helpfull, thanks!

  7. #7
    Join Date
    Mar 2010
    Location
    Singapore
    Posts
    367
    One easy way I see websites does is upon login there are icons for you to choose which language you want. Then based on what you choose, it will direct you to the language-specific web-pages. I would presume they maintain multiple sets of web-pages for different languages ?!?!

    The other way involve server side language help. In Java we have libraries called i18n or something similar. We store all translations into different language properties iles. E.g en_US store key=value for english, zh_CN store key=value for chinese. The key must be the SAME in both of them.

    Then in our main program we will reference "key" and then depending on locale setting the i18n libraries will look up the corresponding language properties file and grep the "value" based on the "key".

    This second approach sound complex and tedious but to me this is the most "correct" solution to handle web-pages with different language translations.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles