NAME
WWW::Babelfish - Perl extension for translation via babelfish
SYNOPSIS
use WWW::Babelfish;
$obj = new WWW::Babelfish( 'agent' => 'Mozilla/8.0', 'proxy' => 'myproxy' );
die( "Babelfish server unavailable\n" ) unless defined($obj);
$french_text = $obj->translate( 'source' => 'English',
'destination' => 'French',
'text' => 'My hovercraft is full of eels',
'delimiter' => "\n\t",
'ofh' => \*STDOUT );
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
-
Translates some text using Babelfish.
Parameters:
source: Source language destination: Destination language text: If this is a reference, translate interprets it as an open filehandle to read from. Otherwise, it is treated as a string to translate. delimiter: Paragraph delimiter for the text; the default is "\n\n". Note that this is a string, not a regexp. ofh: Output filehandle; if provided, the translation will be written to this filehandle.
If no ofh parameter is given, translate will return the text; otherwise it will return 1. On failure it returns undef.
- error
-
Returns a (hopefully) meaningful error string.
NOTES
Babelfish translates 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. Formatting may get lost in the process.
AUTHOR
Dan Urist, durist@world.std.com
SEE ALSO
perl(1).