GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  REST::GOOGLE::TRANSLATE (3)

.ds Aq ’

NAME

REST::Google::Translate - OO interface to Google Translate (aka Languages) API

CONTENTS

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.

Note: Google says that you should supply a valid HTTP referer header each time you perform a request to their AJAX API, so new() raises warning unless referer is specified.

__PACKAGE__->new() q argument should contain a phrase for translation. 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



Note: You can left protocol version number unspecified while making your searches since v=1.0 is passed by default.

responseData To access translated text you should use responseData method as follows



        $translated_text = $res->responseData->translatedText



SEE ALSO

REST::Google - the base class for this module;

<http://code.google.com/apis/ajaxlanguage/documentation/#fonje> - Google Translate AJAX API documentation;

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 REST::GOOGLE::TRANSLATE (3) 2016-04-04

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.