NAME
REST::Google::Translate - OO interface to Google Translate API
SYNOPSIS
use REST::Google::Translate;
REST::Google::Translate->http_referer('http://example.com');
my $res = REST::Google::Translate->new(
q => 'hello world',
langpair => 'en|it'
);
die "response status failure" if $res->responseStatus != 200;
my $translated = $res->responseData->translatedText;
printf "Italian translation: %s\n", $translated;
DESCRIPTION
REST::Google::Translate
provides OO interface to Google REST (aka AJAX) API for languages translation.
METHODS
- __PACKAGE__->http_referer()
-
Get/set HTTP
Referer
header. - __PACKAGE__->new()
-
The constructor use it's arguments to build a valid HTTP GET request to Google Translate service, so it takes the same arguments as the web service takes. Please refer to 'Google Translate AJAX API' documentation for complete list of arguments for Google Translation service. E.g.:
my $res = REST::Google::Translate->new( q => 'hello world', lanpair => 'en|ru' );
The code above will perform a following HTTP GET request:
http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=hello%20world&langpair=en%7Cru
Note: You can left protocol version number unspecified while making your searches since
v=1.0
is passed by default.
SEE ALSO
REST::Google - the base class for this module
http://code.google.com/p/rest-google/ - this project on Google code;
http://code.google.com/apis/ajaxlanguage/documentation/#fonje - Google Translate AJAX API
LICENSE AND COPYRIGHT
Copyright 2008, Eugen Sobchenko <ejs@cpan.org> and Sergey Sinkovskiy <glorybox@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.