NAME
WWW::Babelfish - Perl extension for translation via babelfish
SYNOPSIS
use WWW::Babelfish;
$obj = new WWW::Babelfish( 'agent' => 'Mozilla/8.0' );
die( "Babelfish server unavailable\n" ) unless defined($obj);
$french_text = $obj->translate( 'source' => 'English',
'destination' => 'French',
'text' => 'My hovercraft is full of eels');
die("Could not translate: " . $obj->error) unless defined($french_text);
@languages = $obj->languages;
DESCRIPTION
Perl interface to the WWW babelfish translation server.
METHODS
- new
-
Creates a new WWW::Babelfish object. It can take a named argument for user agent.
- languages
-
Returns a plain array of the languages available for translation.
- translate
-
Takes named arguments for a source language, a destination language, and a source text. Returns translated text.
- error
-
Returns a (hopefully) meaningful error string.
NOTES
Babelfish only seems to translate about 1000 characters at a time. This module tries to break the source text into reasonable logical chunks of less than 1000 characters, feeds them to Babelfish and then reassembles them. Any formatting is likely to get lost in the process.
CAVEATS
The translate function is an all-or-nothing proposition; if we time out too many times or can't connect to Babelfish, no partial translation is returned.
AUTHOR
Dan Urist, durist@world.std.com
SEE ALSO
perl(1).