WWW::Babelfish - Perl extension for translation via babelfish
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;
Perl interface to the WWW babelfish translation server.
Creates a new WWW::Babelfish object. It can take a named argument for user agent.
Returns a plain array of the languages available for translation.
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.
Returns a (hopefully) meaningful error string.
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.
Dan Urist, durist@world.std.com
perl(1).
To install WWW::Babelfish, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Babelfish
CPAN shell
perl -MCPAN -e shell install WWW::Babelfish
For more information on module installation, please visit the detailed CPAN module installation guide.