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



Dave
Deleted

May 2, 2000, 9:24 PM


Views: 1329
ho to set up language recognition ?

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


Views: 1329
Re: ho to set up language recognition ?

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


Views: 1329
Re: ho to set up language recognition ?

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


Views: 1329
Re: ho to set up language recognition ?

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.