CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
ho to set up language recognition ?

 



Dave
Deleted

May 2, 2000, 9:24 PM

Post #1 of 4 (635 views)
ho to set up language recognition ? Can't Post

hello,
could anybody please tell me how to realize a language recognition like altavista does with the search results ?
thanks in advance
dave


Jasmine
Administrator

May 3, 2000, 6:17 AM

Post #2 of 4 (635 views)
Re: ho to set up language recognition ? [In reply to] Can't Post

One way to try to figure out the language of an individual person visiting your site is to look at the $ENV{'REMOTE_HOST'} variable, which (sometimes) offers the visitor's dialup location.

For example, if you see that the visitor is using a .de dialup, chances are that person may speak German.

Because of the possible performance issues with resolving ips each time a call to your server is made, your server admin may have turned off the $ENV{'REMOTE_HOST'} variable. To get around this, you can use the following code to get the remote host info anyway:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


if ($ENV{'REMOTE_ADDR'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$Address = pack('C4',$1,$2,$3,$4);
$DNS_Address = (gethostbyaddr($Address,2))[0];
$ENV{'REMOTE_HOST'} = $DNS_Address if $DNS_Address;
}
$ENV{'REMOTE_HOST'} =~ tr/[A-Z]/[a-z]/;
</pre><HR></BLOCKQUOTE>

Good luck!


Dave
Deleted

May 3, 2000, 7:51 AM

Post #3 of 4 (635 views)
Re: ho to set up language recognition ? [In reply to] Can't Post

thanks a lot but my problem is how to recognize the language of an html document, not of the user who's reading it. so i'd like to to the same as altavista.com does
(look only for italian documents...) ...
do you have an idea ?
thanks
dave


turkscripts
Deleted

May 7, 2000, 6:51 PM

Post #4 of 4 (635 views)
Re: ho to set up language recognition ? [In reply to] Can't Post

One way to do is to look at the the domain name for the country extension. If the domain name ends with .it, it is most probably an italian web site.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives