Google Translate
I recently added Links on the sidebar to translate the current page to other languages as available at Google Translate. My inspiration was Lorelle on WordPress, where links took you to the Translation of front page of the site, from where you can continue to surf in that language as all links are suitably modified by Google.
I wanted to implement the translation for the Current page, which was possible only if JavaScript could be implemented on the link. However, wordpress.com don’t allow embedded JavaScripts for security reasons. And the solution was to let some other page hosted at other location to do this work. So the translation links on my Blog calls a static page with JavaScript code as below.
<script>
var referrer = document.referrer;
if (referrer.length==0)
{
referrer = 'http://jalaj.net';
location.href='http://translate.google.com/translate_c?u='+
escape(referrer)+'&hl=en&langpair=en|fr&tbb=1&ie=utf-8';
}
else
{
var fromGoogle = referrer.indexOf('translate_c');
if (fromGoogle > 0)
{
var urlStart = referrer.indexOf('&u=') + 3;
var urlEnd = referrer.indexOf('&',urlStart)
location.href='http://translate.google.com/translate_c?u='+
escape(referrer.substring(urlStart,urlEnd))+
'&hl=en&langpair=en|fr&tbb=1&ie=utf-8';
}
else
{
location.href='http://translate.google.com/translate_c?u='+
escape(referrer)+'&hl=en&langpair=en|fr&tbb=1&ie=utf-8';
}
}
</script>
The static page when called checks for the referrer. If there was no referrer (which normally should not happen), the translated front page is called. Otherwise it checks if the referrer page was a translated page itself (trying to translate this page would have raised error page). If so, the original url is extracted from the url and translation for corresponding page called. In all other cases the translation for referrer page is presented.
All’s well except that my posts mostly contain Codes which too are translated in the run making them unusable for the visitor unless he checks the original page too.
Google allows web page itself to guide as to modify its behaviour, as introduction of rel=”nofollow” to prevent comment spam discussed on this blog at Rel=”NoFollow”.
I wish to suggest Google to work on a similar solution to allow web pages to mark page content which should not be translated.



Here is program for translation of massive amount of text using google translate. Maybe not for online web usage but for translation of basic information!
http://vbaexcel.eu/vba-macro-code/google-translate-by-internet-explorer-automation
Teo
March 2, 2009 at 10:07 pm
I have admire your unselfishness in taking the time to make this web site.
tip
December 11, 2008 at 10:58 pm
poker online mac…
Chi regolamento texas holdem online poker cheat ganar dinero real linea party poker bonus code casinos portales internet…
poker online mac
June 29, 2008 at 2:56 pm
why did i get an e mail from julie?
/
robert
May 15, 2008 at 8:02 pm
gioco poker scaricare gratis…
E” jeu de poker pour pc online no fax payday loan…
casino securise par internet machine a sous casino internet casino gratuites internet
May 6, 2008 at 11:15 am
download games poker gratis…
Just cpayscom2 online casino internet blackjack…
internet blackjack blackjack internet casino best internet blackjack
May 5, 2008 at 8:54 pm
online poker verboten…
Nehmen jeu poker gratui texas holdem poker download…
jeu poker gratui
May 5, 2008 at 11:28 am
blackjack gambling cyber gambling blackjack online casino gambling blackjack…
Don”t blackjack regeln asian poker tour…
la roulette rustre
May 4, 2008 at 7:55 pm
giochi gratis video poker video poker gratis da giocare…
Come download free motorola ringtones mobile credit card wireless service…
download free motorola v60 ringtones download free motorola ringtones download free ringtones for motorola v3
May 3, 2008 at 4:25 am
[...] Asc() and Chr() in JavaScript VB Forms in Hindi Unicode Fonts Storing Unicode Data in Databases Google Translate Accessing Clipboard from VB WinAPI : Working with Windows [...]
Last 30 days « Jalaj
June 1, 2007 at 7:51 am
[...] Google Translate [...]
Just Looking Back « Jalaj
May 28, 2007 at 6:27 am
Cool one,
Exactly, That’s why I think Google would be the best candidate to handle this “under the hood” translation, so the user is seemlessly in the same language across pages, without web sites doing any translation.
Its like saying “Google would be a search engine and a translator when required, based on the search context”.
I think Google is headed for this.
See ya,
Nice articles and Good thoughts.
Charles
Charles
May 7, 2007 at 5:28 am
Hi Charles,
Thanks fr your feedback.
First of all I should clarify what I meant with not working on Netscape. I aimed at translating the same page which was being viewed when clicked on translate button and not the home page of my blog.
IE and Safari worked as I intended and Netscape didn’t. Following you comment I visited your site and tried to translate this page and I ended up with being served the home page of your blog. This behaviour was same for IE, Netscape (both IE and Firefox engines).
So your implementation was not the one that I wanted to follow. You see most of my visitors reach my blog through Search Engine Results.
Say the visitor was interested about getting info on Tweaking Internet Explorer and landed up at this page Tweaking Registry for Internet Explorer. Alas he wanted it to get translated to French. Now should I expect the visitor to move to french translation of the front page and then try searching for corresponding page (hard if link doesnot appear on that page) or faciliate him getting instant translation of that page.
Jalaj
May 7, 2007 at 4:19 am
Hi Jalaj,
Check out my tech blog. I have a nice translation technique which works in IE. Opera, Mozilla-Firefox and on LINUX too. Also, check out my radio blog (if you scroll down on my blog) and play my favourite music from my blog.
Have fun & Take Care,
Charles
Chrles
May 7, 2007 at 1:21 am
coooool!
krolb
May 5, 2007 at 5:04 pm
Perhaps you might be using a browser other than IE. Don’t know why? but Netscape is not supporting it neither using IE engine nor Firefox engine. Working fine on Safari/Mac. Will probe into it and ensure that works fine across all browsers.
Thanks
Jalaj
April 23, 2007 at 3:54 am
Doesn’t seem to work
Brent
April 22, 2007 at 10:31 pm