Jalaj

April 19, 2007

Google Translate

Filed under: Google, Internet, Internet Explorer — Jalaj @ 8:46 am

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.

14 Comments »

  1. Doesn’t seem to work

    Comment by Brent — April 22, 2007 @ 10:31 pm

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

    Comment by Jalaj — April 23, 2007 @ 3:54 am

  3. coooool!

    Comment by krolb — May 5, 2007 @ 5:04 pm

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

    Comment by Chrles — May 7, 2007 @ 1:21 am

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

    Comment by Jalaj — May 7, 2007 @ 4:19 am

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

    Comment by Charles — May 7, 2007 @ 5:28 am

  7. [...] Google Translate [...]

    Pingback by Just Looking Back « Jalaj — May 28, 2007 @ 6:27 am

  8. [...] 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 [...]

    Pingback by Last 30 days « Jalaj — June 1, 2007 @ 7:51 am

  9. giochi gratis video poker video poker gratis da giocare…

    Come download free motorola ringtones mobile credit card wireless service…

    Trackback by download free motorola v60 ringtones download free motorola ringtones download free ringtones for motorola v3 — May 3, 2008 @ 4:25 am

  10. blackjack gambling cyber gambling blackjack online casino gambling blackjack…

    Don”t blackjack regeln asian poker tour…

    Trackback by la roulette rustre — May 4, 2008 @ 7:55 pm

  11. online poker verboten…

    Nehmen jeu poker gratui texas holdem poker download…

    Trackback by jeu poker gratui — May 5, 2008 @ 11:28 am

  12. download games poker gratis…

    Just cpayscom2 online casino internet blackjack…

    Trackback by internet blackjack blackjack internet casino best internet blackjack — May 5, 2008 @ 8:54 pm

  13. gioco poker scaricare gratis…

    E” jeu de poker pour pc online no fax payday loan…

    Trackback by casino securise par internet machine a sous casino internet casino gratuites internet — May 6, 2008 @ 11:15 am

  14. why did i get an e mail from julie?

    /

    Comment by robert — May 15, 2008 @ 8:02 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.