18 October 2006

Tweaking web translators.

I just added a web translator to the blog of 'Exchange in Guimaraes'. But it
wasn't easy to get the desired result.

First I tried with the Google translator, but it doesn't work when you want to
keep a permanent link, i.e. a link to translate your web.

Surfing I found a static one, Babelfish. But there was a problem, all the
links on the web are translated by Babelfish after change the language, so
there was no way to come back to the original language.

Inspecting the source code of the webs, I found this:

<script language="JavaScript">
<!--
var babelTF="TF";
function babelOrigWin(babelOrigUrl){
var myWin =
window.open(babelOrigUrl,"myWin","location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=600,height=400")
}
var origURL = 'http://e-um.blogspot.com';
document.write("<a target='_self' href='javascript:babelOrigWin(origURL)'
class=xs alt='origURL'>View page in its original Language</a>");
document.close();
// --></script>

Which open another small window and other things that I don't want. I just
want to come back to the original language!!

Playing with the code, I discovered that changing it like this

<script language="JavaScript">
<!--
var babelTF="TF";
function babelOrigWin(babelOrigUrl){
var myWin =
window.open(babelOrigUrl,"myWin","location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=600,height=400")
}
var origURL = 'http://e-um.blogspot.com';
document.write("<a target='_self' href='' class=xs alt='origURL'>View page in
its original Language</a>");
document.close();
// --></script>

The result was good, but I wanted a British flag as link to come back to the
original language.

<li><script language="JavaScript">
<!--
var babelTF="TF";
function babelOrigWin(babelOrigUrl){
var myWin =
window.open(babelOrigUrl,"myWin","location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=600,height=400")
}
var origURL = 'http://e-um.blogspot.com';
document.write("<li><a target='_self' href=''><img
src='http://www.whistlersinn.com/images/flagbritish.gif' width='50'
alt='English Version' class=xs alt='origURL'></a></li>");
document.close();
// --></script></li>

The desired result is obtained. Great!!
I think it's possible to cut out half of the code, but if it doesn't disturb I
prefer to let it there.

-------------

Illusion is the first of all pleasures.
-- Voltaire

"What man has done, man can aspire to do."
-- Jerry Pournelle, about space flight

0 Comments:

Post a Comment

<< Home

Too Cool for Internet Explorer