# expects.
use vars qw!%lang_code $lang_regex!;
%lang_code = (
- 'fr' => 'fr',
- 'sp' => 'es',
- 'es' => 'es',
- 'po' => 'pt',
- 'pt' => 'pt',
- 'it' => 'it',
- 'ge' => 'de',
- 'de' => 'de',
- 'gr' => 'de',
- 'en' => 'en',
- 'zh' => 'zh',
- 'ja' => 'ja',
- 'jp' => 'ja',
- 'ko' => 'ko',
- 'kr' => 'ko',
- 'ru' => 'ru'
- );
+ 'fr' => 'fr',
+ 'sp' => 'es',
+ 'es' => 'es',
+ 'po' => 'pt',
+ 'pt' => 'pt',
+ 'it' => 'it',
+ 'ge' => 'de',
+ 'de' => 'de',
+ 'gr' => 'de',
+ 'en' => 'en',
+ 'zh' => 'zh',
+ 'ja' => 'ja',
+ 'jp' => 'ja',
+ 'ko' => 'ko',
+ 'kr' => 'ko',
+ 'nl' => 'nl',
+ 'ru' => 'ru'
+ );
# Here's how we recognize the language you're asking for. It looks
# like RTSL saves you a few keystrokes in #perl, huh?
my $ua = new LWP::UserAgent;
$ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
- $ua->agent("Mozilla/4.5 " . $ua->agent); # Let's pretend
+ # Let's pretend
+ $ua->agent("Mozilla/5.0 " . $ua->agent);
$ua->timeout(5);
my $req =
# Accept-Charset: iso-8859-1
# $req->header('Accept-Charset' => 'iso-8859-1');
# print $req->header('Accept-Charset');
+ $req->header('Accept-Language' => 'en');
$req->content_type('application/x-www-form-urlencoded');
return translate($phrase, "${from}_${to}", $req, $ua);
&main::DEBUG("$translated\n===remove to first ':', optional Help\n");
$translated =~ s/\n/ /g;
- # FIXME should we do unicode->iso
+ # FIXME: should we do unicode->iso (no. use utf8!)
} else {
$translated = ":("; # failure
}
if (0) {
if (-t STDIN) {
- #my $result = babel::babelfish('en','sp','hello world');
- #my $result = babel::babelfish('en','sp','The cheese is old and moldy, where is the bathroom?');
- my $result = babel::babelfish('en','gr','doesn\'t seem to translate things longer than 40 characters');
- $result =~ s/; /\n/g;
- print "Babelfish says: \"$result\"\n";
+ #my $result = babel::babelfish('en','sp','hello world');
+ #my $result = babel::babelfish('en','sp','The cheese is old and moldy, where is the bathroom?');
+ my $result = babel::babelfish('en','gr','doesn\'t seem to translate things longer than 40 characters');
+ $result =~ s/; /\n/g;
+ print "Babelfish says: \"$result\"\n";
}
}