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


 use Lingua::Translate;
       backend => "Babelfish",
       babelfish_uri =>
       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");


Lingua::Translate::Babelfish is a translation back-end for Lingua::Translate that contacts 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.


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.

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

Destination Language


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


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 the I18N::LangTags::List manpage.

agent() : LWP::UserAgent

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


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.

The uri to use when contacting Babelfish.

The default value is ``''

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

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

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

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


Strings are sent and received in UTF8 without any processing.


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

The original interface to the fish - the WWW::Babelfish manpage, by Daniel J. Urist <>


Sam Vilain, <>