Language translation for web site

Discussion in 'PHP' started by championaire12, Jan 20, 2008.

  1. #1
    Hi there guys I am building a hotel website now as part of my school project and I would like to know whether is it possible to use PHP to translate our web pages into a different language. Our proposed website have 3 language links--English, Chinese and Japanese. Of cos the default language is english, but when users click on the chinese or Japanese links the web pages will automatically translate to the respective languages

    Is it possible to use PHP to do that? If possible pls provide some useful links here

    Thanks!!
     
    championaire12, Jan 20, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You could use PHP to connect to online Language converters (such as Google), and then cache the result (like with the Acme Cache PHP Kit).

    Jay
     
    jayshah, Jan 20, 2008 IP
  3. championaire12

    championaire12 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ya I know that, but we don't want it to be this way, looks very unprofessional

    This is a reference to how I want my project to be like: http://www.shangri-la.com/

    U can see at the top there are 3 language links. If u click the chinese links the chinese version of the page will appear in the web site interface directly without having to go through the google translation process. Is there a way to do this without manual translation, either by PHP or any other technologies
     
    championaire12, Jan 20, 2008 IP
  4. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #4
    You clearly mis-read what I said. I said use PHP to connect to google, post the text, parse the response and give the response to the user. NOT send the user to Google. You obviously don't want my help.
     
    jayshah, Jan 20, 2008 IP
  5. championaire12

    championaire12 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Wah relax lah, don't need to make a mountain out of a molehill isn't it? Just a mis-interpretation on my part

    One question, do google translate your words blindly word for word, or do they translate into proper sentences that makes sense. Chinese and English words may not appear in the same order for sentences of similar meaning. I hope you get what I mean
     
    championaire12, Jan 20, 2008 IP
  6. Erthy

    Erthy Peon

    Messages:
    254
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The way the site you mentioned does this (http://www.shangri-la.com/) is not using PHP, they simply have 3 versions of the same website in different languages. PHP can't translate text.

    As for you second question, Google translations are generally messy and nonsensical.
     
    Erthy, Jan 20, 2008 IP
  7. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #7
    I doubt Google translate it word-for-word, but I can't vouch for it. No automated translation service is perfect, unless you write one yourself.

    Jay
     
    jayshah, Jan 20, 2008 IP
  8. championaire12

    championaire12 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ya this is my main concern
     
    championaire12, Jan 20, 2008 IP
  9. pubdomainshost.com

    pubdomainshost.com Peon

    Messages:
    1,277
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #9
    PHP can't do magic translation for you, however what is done at most sites (example wordpress.org) is to have key text elements defined either in database, or a define file. Thus when user selects a particular language, as an example all navigation links would show in selected langugage (picked on runtime from either database or the define file)

    You may checkout oscommerce source code to see how is it done, apart from other open source software that is developed for multiple languages.

    Hope this helps,
    GS
     
    pubdomainshost.com, Jan 20, 2008 IP
  10. championaire12

    championaire12 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Any links on how to set up this translation function?
     
    championaire12, Jan 20, 2008 IP
  11. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #11
    Not really. Just learn to use either cURL's post function, or if you know how POST'ing data though sockets work, use PHP's fsockopen to re-create the request. cURL (if it's enabled), is easier for beginners.

    Jay
     
    jayshah, Jan 20, 2008 IP
  12. logondotinfo

    logondotinfo Peon

    Messages:
    314
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #12
    simple method is to have a variable (for example $lang), set it with a default value of 'eng' (for example to be english). Just after this variable is declared on every page (if no session variable is present, default value used) then query your database for results from a table called languages where lang=$lang. Then set up a 3 column table (language) with headers of 'key', 'lang', 'value' - you can then populate this table (example would be 'SITE_TITLE', 'eng', 'My Cool Site').

    Once you have queried the db, do a simple loop through all returned values setting up define($key, $value). Now anywhere you want text to appear on your page you simply use the php key - in this example SITE_TITLE. You add a new line to db for each language/key pair, and away you go. No its not automated, but its a hell of a lot more reliable and gives you full control over your site. You can then add a language selector which saves language value into your session, and if you like you can cache the results as simple files on your server.

    osCommerce goes a fair way into this, but the file based system makes it an absolute nightmare to track things down for the un-initiated. Take a look at the source code by all means to see a working example, and its worth looking at the new MS3 alpha release which (I believe) will move all language definitions into either the db or xml format, speeding up the whole process.

    ANY automated system is going to have mis-translations and probably damage your sites professional appearance, it is far better to employ a translator for a one time fee and save the translations into your sites db....a professional site (especially for a hotel website) will translate into sales form foreign visitors...if you cant translate accurately, better not to translate at all in my opinion.
     
    logondotinfo, Jan 20, 2008 IP
  13. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Yes, if you want it to look professional, you need to hire a professional translator. Championaire12, from how you write, it sounds like you may be in Malaysia, in that case you know you can find cheap Chinese translators under any rock. Japanese more difficult but not impossible.
     
    SmallPotatoes, Jan 20, 2008 IP
  14. futhey

    futhey Peon

    Messages:
    389
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Japanese via google translate is horrid. I wouldn't recommend it.
     
    futhey, Jan 20, 2008 IP