Gossamer Forum
Home : Products : Links 2.0 : Customization :

Automatic Language Translation?

(Page 2 of 5)
> > > >
Quote Reply
Re: Automatic Language Translation? In reply to
ok.. subroutine to decode the encode urls.. makes ALOT OF THINGS easier to compare..

Code:
sub urldecode {
my($todecode) = shift;
$todecode =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
return $todecode;
}

learn how to use it yourself...

UH UH UH.. NO COMPLAINING! Wink

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
Oh come on man, this is crap....

I need help. Where do I put the code?

WHERE?!?!?!?!?!?

Why can't you JUST HELP ME!!!!!!!!!!!

Smile Smile Smile Smile Smile Smile Smile Smile Smile


P.S. Just kidding, as if you didn't know. Smile

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Automatic Language Translation? In reply to
Thanks for the codes, Jerry.

Bmxer,

I am using the following codes in the translate.cgi file:

Code:
sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

if ($in{'$db_key'}) {
&translate_it;
}
elsif ($in{$db_key} =~ /^\d+$/) {
my (%rec) = &get_record ($in{$db_key});
($rec{$db_key} eq $in{$db_key}) ?
&site_html_translate_form (%rec) :
&site_html_translate_failure ("Unkown Link ID: $in{$db_key}");
}
}

AFTER the codes you have for the libraries.
Then I just made the main part of the original translate.cgi into a sub-routine,sub translate_it.

I am able to pass the id of the Link to the translate.html template file, using the following URL:

Code:
http://www.myserver.com/cgi-bin/translate.cgi?ID=<%ID%>

in the link.html template file. I get the translate main page (translate.html). However, when I submit the "form" with a language specified, I get an Internal Error Message. The syntax of the file is fine. Just not processing the right way. I even tried just taking out the text box and added a hidden field for url, but that didn't work either. The value of the "url" appears in the source code, but when I click on Translate Resource, I get the Internal Server Error.

Hmmm....

Wink

Regards,


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 20, 1999).]
Quote Reply
Re: Automatic Language Translation? In reply to
Widgetz,
I still don't get what you guys are talking about, why do i need to decode the url, is it so i can put the url on the form page.

Eliot,
If you changed the main part to translate_it, wouldn't you have to change the local %in = &parse_form part to &translate_it

[This message has been edited by Bmxer (edited September 20, 1999).]
Quote Reply
Re: Automatic Language Translation? In reply to
decode urls to compare.. etc..

like would you rather compare

http%3e%2f%2fwww%2epdamania%2ecom%2f

with

http://www.pdamania.com/

or printing the original url back.. (i know what i'm saying.. there are a ton of annoying bugs that i fixed with that decode thing)

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
Bmxer,

Nope...That doesn't work. If I take out those codes and place them in the sub translate it routine, I get an Internal Server Error.

Jerry,

The codes you gave work. However, I am still having a problem getting the $url to pass with the form I created.

Edit:

I take it back...There are still problems with cleaning up the URL, which is causing an Internal Server Error. I did use the sub urldecode routine rather than urlencode routine. (But I found out the problem...I was using POST rather than GET in the form. Now at least I get the query string to show in the browser location.) Dah! Smile

Here is what I get when I select a language and hit the Translate Resource button:

Code:
http://www.anthrotech.com/cgibin/wwwvl/translate.cgi?url=http%3A%2F%2Fanthap.oakland.edu%2F&language=german

But thanks for your time and effort, Jerry. I appreciate it.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 20, 1999).]

[This message has been edited by Eliot (edited September 20, 1999).]
Quote Reply
Re: Automatic Language Translation? In reply to
here is also one that i plan on integrating with url enhancements..

http://www.pdamania.com/sql/global.cgi

this one allows you to switch any language to any language..

like.. if you wanted to translate a french site to german.. instead of it always being one of them english

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
That would be great implemented with the translate url thing, so like Altavista, two features.
Quote Reply
Re: Automatic Language Translation? In reply to
I did it sort of weirdly, I have only one page now, and the errors are displayed their if theres an error, and the form is also their, so now i can pass the url to the form and all it says is Invalid Language, which i changed to be universal like "Please select a language, but I still have that thing, if their are no %in things, go to the page and its cool because nothings printed up, but the form. ie. http://lookhard.hypermart.net/...//www.macromedia.com
http://lookhard.hypermart.net/...n/Look/translate.cgi
Quote Reply
Re: Automatic Language Translation? In reply to
Very nice, Bmxer! I like it much better than Altavista, because you can actually browse through linked pages without having to return back to the form.

It would be nice, however, if you had translate_error.html file that printed error messages from Altavista rather than being redirected to Altavista.

Some other things to consider is debugging hotspots and Image Maps. I noticed that when I went through different pages and clicked on hotspots in Image Maps, I was taken back to your form, Bmxer.

Great job.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 21, 1999).]
Quote Reply
Re: Automatic Language Translation? In reply to
I didn't even know i had image maps, do you mean when the users goes all over and crap, to let him go back to the form and still have that url there? Well, i just thought of doing it this way today, before i went to school. Do you have the errors displayed on the form? I mean the invalid url and language errors. Yes it would be nice to somehow get their errors, and put them up on our own thing. Have you see Widgetz's translate words thing, I love that, its a very cool mod though in debug stage.
Quote Reply
Re: Automatic Language Translation? In reply to
yes...the global.cgi file is very nice.

Smile

The errors I am referring to are image maps located on other web pages outside of your site. When you click on a hotspot, you are taken back to the Translate form.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Automatic Language Translation? In reply to
That can't be my problem, because i've tried translating Yahoo before and i saw that since they don't put their url for basically anything and only put /r/ar, it actually shows
http://lookhard.hypermart.net/look-bin/Look/r/ar
even their news shows like this
http://lookhard.hypermart.net/homer/?http://fullcoverage.yahoo.com/FC/us/Severe_Weather/
. Oh crap, i just saw it on your site because i remembered yours has a map, and it does, oh, is that what urldecode is for, when people go to my site, or when they type it in the url box, because i think the thing was all those %2E. So i don't know, but have you gotten yours to pass the variables, because i went with your way but it wasn't working which turned me on to this way, but you said it does get that url for the specified ID?

[This message has been edited by Bmxer (edited September 21, 1999).]
Quote Reply
Re: Automatic Language Translation? In reply to
OK guys....great! "complicated" idea your working on......
I created a simple solution to use translate.go's free service......
basically just call a static template form into the header of every page which allows user to select which language to translate that particular page. After they submit....it calls translate.cgi in my cgi bin to store the %ENV{'HTTP_REFFERER'} and pass that to go's translator...from there they can view every page on my site translated via go's service.......
I could help if anybody is interested.
Quote Reply
Re: Automatic Language Translation? In reply to
Hello rdmille,

Of course, I think we would all be interested in seeing how you have implemented a trasnlation utility. Smile

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Automatic Language Translation? In reply to
ok.. i have no clue what you guys are doing.. Smile

anyways.. yea.. if you guys really need help.. i'll help.. but right now it seems you guys are getting it..

maybe if you explain.. i can get some code up for you..

i'm just gonna add a few more things to global.cgi and i'll be done.. i need to allow urls.. and also.. make customized error messages (which is easy..)

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
What i was doing was just doing it regular with the url being printed on the translate_form page, with out it saying invalid url, i achieved this by only using one template with <%url%> in the field, but also using <%if error%> <%error%> <%endif%> and that does print out the error on the page also, but this is only a work around. I would rather it print out the url in the text box, and have the languages their, and i don't know if you can do this, but i'd like to defeat things like Yahoo and be able to print their url out, instead of it printing my url out and their directory. Anyway, nice script, have you started mailing out geturl.cgi's yet?
Quote Reply
Re: Automatic Language Translation? In reply to
Did something like this.
(with site_html.pl....which I use)
********************************************
<table width="150" border="0" cellpadding="0" cellspacing="0">
<form action="$db_cgi_path/translator.cgi" method=POST>
<tr>
<td align="absmiddle">
<select name="lp" >
<option value="en_fr">French
<option value="en_sp" selected>Spanish
<option value="en_ge">German
<option value="en_it">Italian
<option value="en_pt">Portuguese
</select>
<input type="HIDDEN" name="form" value="http://translator.go.com/">
<input type="HIDDEN" name="input_type" value="url" checked>
</td>
<td align="absmiddle"><input type=image width=19 height=19 border=0 value="Translate" src="/images/gobutton.gif" align=absmiddle name="submit2"></td>
</tr>
</form>
</table>
****************************************
change layout to suite your needs.....

Then........

Create the very simple translator.cgi
******************************************
#!/usr/bin/perl

$refer=$ENV{'HTTP_REFERER'};
$formdata=<STDIN>;
$formdata=~s/\s+$//;
$formdata.="&$ENV{'QUERY_STRING'}";
$formdata=~s/^&//;
$formdata=~s/\s+$//;
foreach(split(/&/,$formdata))
{
($name, $value)=split(/=/, $_);
$name=~s/\+/ /g;
$name=~s/%([0-9|A-F]{2})/pack(C,hex($1))/eg;
$value=~s/\+/ /g;
$value=~s/%([0-9|A-F]{2})/pack(C,hex($1))/eg;
$data{$name}=$value;
}

$translate ="$data{'form'}?systran&lp=$data{'lp'}&input_type=url&url=$refer";
print "Location: $translate\n\n";
*************************************
upload
chmodd
re-build
you should be done!
hope this helps those that aren't as talented as the some of the other great posters on this board.
Quote Reply
Re: Automatic Language Translation? In reply to
so you just wanted to make a mockup of altavista? Smile

plus.. eliot.. i made the language equal the actual word for a reason Wink

[so it wouldn't look like altavista]

anyways.. yea.. global.cgi is not based on translate.cgi at all.. i just did it cause i noticed how easy it was to do..

it's 100% bugfree right now.. except i have to add 2 features that's all..

no i have not mailed geturl.cgi..

the bug from awhile ago. (mondayish) i haven't taken a look at.. you will notice my spider.db never decreases.. and then it keeps adding it into add.db.. OVER AND OVER AND OVER.. which is really annoying me right now

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
I don't want to create a text area for people to fillin the url to translate, although it nice. I want to translate my exisiting web site into other languages.

Like Widgetz's translate.cgi, but so that the user can go back to english if need be.

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Automatic Language Translation? In reply to
yea.. that's what i did with my translate.cgi.. i used the referer.. i put this in..

Code:
$url = $ENV{'HTTP_REFERER'} &#0124; &#0124; "http://$ENV{'HTTP_HOST'}/";

and then i checked to see if the url was in my domain only... not some person using my script..

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
going back to english is easy.. you just have to parse the current url with the links on the page.. i already did this..

an easy alternative is just to use a pulldown menu.. you could do javascript..

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
Bmxer et al,

What I have been able to do is pass the field variables via the following URL:

Code:
http://www.myserver.com/cgi-bin/links/translate.cgi?ID=<%ID%>

in the link.html file. It does go to the translate form. What I have done is add a hidden field for URL and then a drop-down menu for the languages.

When I click on Translate Resource, I get an Internal Server Error. I am using the urldecode routine that Jerry provided.

I think that I need to re-write some of the codes to make this work.

Any ideas you have, Jerry or anyone else, would be greatly appreciated.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Automatic Language Translation? In reply to
urldecode will work without errors...

jerry
Quote Reply
Re: Automatic Language Translation? In reply to
hey, Widgetz... when i click on the link to italian.pdamania.com, it spits this link:

http://%20italian.pdamania.com%20/translate.cgi?url=http%3A%2F%2Fwww.pdamania.com%2Findex.html&language=italian

i took out the 2 %20's, and it took me to the right page... maybe that's UBB... after that, i clicked on Software, which gave the link of:

http://italian.pdamania.com/translate.cgi?url=http%3a%2f%2f216%2e65%2e106%2e208%2fSoftware%2f&language=italian

which returned
Quote:
Fetch error
Sorry there was a problem fetching http://.
on altavista. so i manually de-encoded it, and it told me 'invalid language'

it gave me the same crap for french and spanish, too.

--tom
> > > >