File manager - Edit - /usr/local/cpanel/3rdparty/perl/542/cpanel-lib/REST/Google/Translate.pod
Back
=head1 NAME REST::Google::Translate - OO interface to Google Translate (aka Languages) API =head1 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; =head1 DESCRIPTION C<REST::Google::Translate> provides OO interface to Google REST (aka AJAX) API for languages translation. =head1 METHODS =over =item __PACKAGE__->http_referer() Get/set HTTP C<Referer> header. I<Note:> Google says that you should supply a valid HTTP referer header each time you perform a request to their AJAX API, so C<new()> raises warning unless referer is specified. =item __PACKAGE__->new() C<q> argument should contain a phrase for translation. C<langpair> is used to specify translation languages. According to Google API documentation the langpair languages should be separated by "|" (pipe) sign. For complete list of language pairs and other arguments please refer to 'Google Translate AJAX API' documentation. E.g.: my $res = REST::Google::Translate->new( q => 'hello world', langpair => 'en|it' ); 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%7Cit I<Note:> You can left protocol version number unspecified while making your searches since C<v=1.0> is passed by default. =item responseData To access translated text you should use C<responseData> method as follows $translated_text = $res->responseData->translatedText =back =head1 SEE ALSO L<REST::Google> - the base class for this module; L<http://code.google.com/apis/ajaxlanguage/documentation/#fonje> - Google Translate AJAX API documentation; =head1 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.
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings