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!!
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
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
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.
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
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.
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
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
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
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.
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.