If you want to give your site users to access your website content in different languages like spanish, dutch, german etc. automatically! then this simple script can do it in seconds using google translator. Best part is, you do not even need to know languages yourself!
<?php $defaultLang = 'en'; /* * Don't edit under here */ $hostname = $_SERVER['SERVER_NAME']; $url = 'http://'.$hostname. htmlentities($_SERVER['REQUES T_URI']); ?> <script type="text/javascript"> <!-- function DoTranslate(lang){ if(lang == "<?=$defaultLang?>"){ url = "<?=$url?>"; }else{ url = "http://209.85.135.104/translate_c?hl= <?=$defaultLang?>&langpair=<?=$defaultLang?> |"+lang+"&u=<?=$url?>"; } eval("parent.location='"+url+"'"); } //--> </script> <a href="javascript:DoTranslate('en')">English</a> | <a href="javascript:DoTranslate('es')">Spanish</a> | <a href="javascript:DoTranslate('de')">German</a> | <a href="javascript:DoTranslate('it')">Italian</a> | <a href="javascript:DoTranslate('nl')">Dutch</a> | <a href="javascript:DoTranslate('pt')">Portuguese</a> | <a href="javascript:DoTranslate('zh-CN')">Chinese Simplified</a> | <a href="javascript:DoTranslate('el')">Greek</a> | <a href="javascript:DoTranslate('ar')">Arabic</a> | <a href="javascript:DoTranslate('ru')">Russian</a>
I added 10 languages (English, Spanish, German, Italian, Dutch, Portuguese, Chinese Simplified, Greek, Arabic, Russian) for my project but you can add more languages that google translator support. Please visit google translator site for more reference.
For any advise/help please contact with me.
Thanks…
[Note: Please do understand that the translations are dependent on the quality of language in your site in terms of grammar and spelling. ]
2 responses to " Automatic translation using google translator "
August 1 2009
dont work
October 23 2009
thanks jim for your try. can you post/email me your code so that I can review and may be able to find out problem.
thanks.

Recent Comments