NAME

Lingua::Translate::Babelfish - Translation back-end for Altavista's Babelfish, version 0.01

SYNOPSIS

 use Lingua::Translate;

 Lingua::Translate::config
     (
       backend => "Babelfish",
       babelfish_uri =>
           'http://babelfish.yahoo.com/translate_txt',
       ua => LWP::UserAgent->new(),
     );

 my $xl8r = Lingua::Translate->new(src => "de", dest => "en");

 # prints "My hovercraft is full of eels"
 print $xl8r->translate("Mein Luftkissenfahrzeug ist voll von den Aalen");

DESCRIPTION

Lingua::Translate::Babelfish is a translation back-end for Lingua::Translate that contacts babelfish.altavisa.com to do the real work.

It is normally invoked by Lingua::Translate; there should be no need to call it directly. If you do call it directly, you will lose the ability to easily switch your programs over to alternate back-ends that are later produced.

CONSTRUCTOR

new(src => $lang, dest => lang, option => $value)

Creates a new translation handle. This method contacts Babelfish to determine whether the requested language pair is available.

src

Source language, in RFC-3066 form. See I18N::LangTags for a discussion of RFC-3066 language tags.

dest

Destination Language

ua

Other options that may be passed to the config() function (see below) may also be passed as arguments to this constructor.

METHODS

The following methods may be called on Lingua::Translate::Babelfish objects.

translate($text) : $translated

Translates the given text. die's on any kind of error.

If too large a block of text is given to translate, it is broken up to the nearest sentence, which may fail if you have extremely long sentences that wouldn't normally be found in normal language, unless you were either sending in some text that has no punctuation at all in it or for some reason some person was rambling on and on about totally irrelevant things such as cheese, one of the finest foods produced by mankind, or simply was the sort of person who don't like ending sentences but instead merely keep going with one big sentence with the hope that it keeps readers going, though its usual effect is merely to confuse.

The previous paragraph gets translated by Babelfish OK.

available() : @list

Returns a list of available language pairs, in the form of "XX_YY", where XX is the source language and YY is the destination. If you want the english name of a language tag, call I18N::LangTags::List::name() on it. See I18N::LangTags::List.

agent() : LWP::UserAgent

Returns the LWP::UserAgent object used to contact Babelfish.

CONFIGURATION FUNCTIONS

The following are functions, and not method calls. You will probably not need them with normal use of the module.

config(option => $value)

This function sets defaults for use when constructing objects.

babelfish_uri

The uri to use when contacting Babelfish.

The default value is "http://babelfish.yahoo.com/translate_txt?"

agent

The User-Agent to pretend to be when contacting Babelfish.

The default value is "Lingua::Translate::Babelfish/", plus the version number of the package.

chunk_size

The size to break chunks into before handing them off to Babelfish. The default value is "1000" (bytes).

retries

The number of times to retry contacting Babelfish if the first attempt fails. The default value is "2".

BUGS/TODO

Strings are sent and received in UTF8 without any processing.

SEE ALSO

Lingua::Translate, LWP::UserAgent, Unicode::MapUTF8

The original interface to the fish - WWW::Babelfish, by Daniel J. Urist <durist@world.std.com>

AUTHOR

Sam Vilain, <enki@snowcra.sh>