Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 04:08 pm EST
Geeklog Forums
Automated Translation Link using Babelfish for multilingual sites
My ,
This is both a sort of contribution to multilingual sites, and a request for more help. And what it definitely is: _not_ an elegant "hack", it is just a cheap html trick.
I apologize if anyone has thought of this before and posted it somewhere around here. I couldn't find it.
After Euan finished helping me install his excellent switchlanguage script, I realized my world-wide audience would need a little more help than I can provide. I can only translate my articles to and from English and Spanish, and that's more than enough work for me...
No automated translator is really that good, specially if free, but it does help in a crunch. So, if anyone wanted to translate your page... are you sure they are going to bother to cut and paste your URL, run over to altavista's babelfish and give it a go?
Most of us would just put in the altavista code for babelfish's javascript to make sure they stay in-site.
This of course load's Babelfish's image, which, if repeated on every article, is not a nice thing, assuming you, like me, want a specific article translated, not the whole page including header and blocks! You are not supposed to change their image.
(In all fairness I DO use their image when the user is in English language preference... minor code change to Euan's hack).
Put this somewhere in your storytext.thtml file, preferably at the bottom:
<tr align="center">
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=es_en&target=translate&url={article_url}%26mode=print">Spanish-English</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=es_fr&target=translate&url={article_url}%26mode=print">Espagnol-Français</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_fr&target=translate&url={article_url}%26mode=print">Anglais-français</a></td>
</tr><tr align="center">
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_nl&target=translate&url={article_url}%26mode=print">Engels-Nederlands</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_it&target=translate&url={article_url}%26mode=print">Inglese-italiano</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_ru&target=translate&url={article_url}%26mode=print">English-Russian</a></td>
</tr>
</table>
Obviously you add css, etc. to it to make it look nice. That table is very basic and simple. Even better, make nice buttons instead of text, or even an imagemap. That is easy.
As it is, the table has links to six different translations of the article's URL as I need them on my site. Spanish source only allows for English or French translations. If your article is in English, then you have plenty more options. Visit www.babelfish.altavista.com for all the possibilities. Usually they involve starting language code (i.e., en for English), and translated language code (i.e., fr for French).
Your featured story will not show this table. You need to add the same code to your featuredstorytext.thtml. I am lazy and haven't done it yet myself.
Now, because babelfish is slow, specially if you give it a lot of text, I choose to send them the Print version of the article only. You could remove the &mode=print tag to have the whole page translated at once.
See it in action in one of my articles at www.realpanama.org. Remember to switch the site to English before trying the english source translations!
I would really enjoy to see this as a plugin by someone.
My biggest problem right now is that I wanted to use the url_rewrite feature to make my site google-friendly, but that somehow breaks the babelfish translation. No clue why, probably the '&mode=print' has something to do with it.
Problem #2. I am probably in violation of some Altavista usage agreement by doing this(not showing their image), and you might be too. I do respect rights and agreements, but I am pushing it here. Anyone care to enlighten me as to another online tool that does a similar thing, without altavista's user agreement. It would be an easy rewrite for anyone.
A real nice hack would know the translations available depending on the article's language... and only show those. Anyone care to try?
www.realpanama.org
A non-profit site about prisoners in panamanian jails.
This is both a sort of contribution to multilingual sites, and a request for more help. And what it definitely is: _not_ an elegant "hack", it is just a cheap html trick.
I apologize if anyone has thought of this before and posted it somewhere around here. I couldn't find it.
After Euan finished helping me install his excellent switchlanguage script, I realized my world-wide audience would need a little more help than I can provide. I can only translate my articles to and from English and Spanish, and that's more than enough work for me...
No automated translator is really that good, specially if free, but it does help in a crunch. So, if anyone wanted to translate your page... are you sure they are going to bother to cut and paste your URL, run over to altavista's babelfish and give it a go?
Most of us would just put in the altavista code for babelfish's javascript to make sure they stay in-site.
Text Formatted Code
<script language="JavaScript1.2" src="http://www.altavista.com/static/scripts/translate_spanish.js"></script>This of course load's Babelfish's image, which, if repeated on every article, is not a nice thing, assuming you, like me, want a specific article translated, not the whole page including header and blocks! You are not supposed to change their image.
(In all fairness I DO use their image when the user is in English language preference... minor code change to Euan's hack).
Put this somewhere in your storytext.thtml file, preferably at the bottom:
Text Formatted Code
<table width="100%"><tr align="center">
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=es_en&target=translate&url={article_url}%26mode=print">Spanish-English</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=es_fr&target=translate&url={article_url}%26mode=print">Espagnol-Français</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_fr&target=translate&url={article_url}%26mode=print">Anglais-français</a></td>
</tr><tr align="center">
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_nl&target=translate&url={article_url}%26mode=print">Engels-Nederlands</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_it&target=translate&url={article_url}%26mode=print">Inglese-italiano</a></td>
<td><a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=en_ru&target=translate&url={article_url}%26mode=print">English-Russian</a></td>
</tr>
</table>
Obviously you add css, etc. to it to make it look nice. That table is very basic and simple. Even better, make nice buttons instead of text, or even an imagemap. That is easy.
As it is, the table has links to six different translations of the article's URL as I need them on my site. Spanish source only allows for English or French translations. If your article is in English, then you have plenty more options. Visit www.babelfish.altavista.com for all the possibilities. Usually they involve starting language code (i.e., en for English), and translated language code (i.e., fr for French).
Your featured story will not show this table. You need to add the same code to your featuredstorytext.thtml. I am lazy and haven't done it yet myself.
Now, because babelfish is slow, specially if you give it a lot of text, I choose to send them the Print version of the article only. You could remove the &mode=print tag to have the whole page translated at once.
See it in action in one of my articles at www.realpanama.org. Remember to switch the site to English before trying the english source translations!
I would really enjoy to see this as a plugin by someone.
My biggest problem right now is that I wanted to use the url_rewrite feature to make my site google-friendly, but that somehow breaks the babelfish translation. No clue why, probably the '&mode=print' has something to do with it.
Problem #2. I am probably in violation of some Altavista usage agreement by doing this(not showing their image), and you might be too. I do respect rights and agreements, but I am pushing it here. Anyone care to enlighten me as to another online tool that does a similar thing, without altavista's user agreement. It would be an easy rewrite for anyone.
A real nice hack would know the translations available depending on the article's language... and only show those. Anyone care to try?
www.realpanama.org
A non-profit site about prisoners in panamanian jails.
17
9
Quote
Status: offline
realpanama
Forum User
Newbie
Registered: 05/09/05
Posts: 5
Hey, what do you know. I found the answer to my URL_REWRITE problem.
Instead of "%26mode=print"
Substitute for a simple "/print"
That sorted it out. Now url-rewritten pages can be easily translated by babelfish.
Therefore the code to a translation link will look something like this for URL_REWRITE=True
Cheers,
Admin
www.realpanama.org
www.panacarcel.com
Sites about Panamanian Prison conditions.
Instead of "%26mode=print"
Substitute for a simple "/print"
That sorted it out. Now url-rewritten pages can be easily translated by babelfish.
Therefore the code to a translation link will look something like this for URL_REWRITE=True
Text Formatted Code
<a href="http://babelfish.altavista.com/babelfish/tr?doit=done&lp=es_en&target=translate&url={article_url}/print">Spanish-English</a>Cheers,
Admin
www.realpanama.org
www.panacarcel.com
Sites about Panamanian Prison conditions.
18
13
Quote
All times are EST. The time is now 04:08 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content