CC: | durist [...] frii.com |
Subject: | text containing umlauts does not get translated properly |
With WWW::Babelfish 0.13 I wasn't able to translate texts or words
containing German umlauts, e.g. "für" did not translate into "for".
However, it worked when I used my browser.
I'm anything but an expert for charset issues, but by comparing a
tcpdump of the request my browser sent with that one issued by a test
script...
perl -MWWW::Babelfish -e 'print WWW::Babelfish->new->translate(qw(source
German destination English text),"für")'
... I finally found out that adding a "Accept-Charset: utf-8" header
helps to make that work.
You'll find a patch attached.
Regards,
fany
Subject: | Babelfish_utf8.patch |
--- Babelfish.pm.orig 2005-08-07 04:58:35.000000000 +0200
+++ Babelfish.pm 2006-03-25 18:07:22.000000000 +0100
@@ -42,7 +42,8 @@
translaterequest => sub {
my($langpair, $text) = @_;
my $req = POST ( 'http://babelfish.altavista.com/babelfish/tr?il=en',
- [ 'doit' => 'done', 'urltext' => encode("utf8",$text), 'lp' => $langpair, 'Submit' => 'Translate', 'enc' => 'utf8' ]);
+ [ 'doit' => 'done', 'urltext' => encode("utf8",$text), 'lp' => $langpair, 'Submit' => 'Translate', 'enc' => 'utf8' ],
+ qw(Accept-Charset utf-8) );
return $req;
},